Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class VIEW3D_PT_snappanel_toolshelf(Panel):
- bl_label = "Snap"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'TOOLS'
- #bl_options = {'HIDE_HEADER'}
- #show_text = ToolSelectPanelHelper._layout_generator_detect_from_region(layout, context.region, scale_y)
- #show_text = False
- @staticmethod
- def ts_width(layout, region, scale_y):
- """
- Choose an appropriate layout for the toolbar.
- """
- # Currently this just checks the width,
- # we could have different layouts as preferences too.
- system = bpy.context.preferences.system
- view2d = region.view2d
- view2d_scale = (
- view2d.region_to_view(1.0, 0.0)[0] -
- view2d.region_to_view(0.0, 0.0)[0]
- )
- width_scale = region.width * view2d_scale / system.ui_scale
- if width_scale > 160.0:
- show_text = True
- else:
- show_text = False
- return show_text
- def draw(self, _context):
- layout = self.layout
- show_text = self.ts_width(layout, region, scale_y)
- print(show_text)
- if show_text is True:
- layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor", icon = "SELECTIONTOCURSOR").use_offset = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement