Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_view3d_toolbar.py
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def draw_vpaint_symmetry(layout, vpaint): | ||||
| row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True) | row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True) | ||||
| row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True) | row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True) | ||||
| col = layout.column() | col = layout.column() | ||||
| col.prop(vpaint, "radial_symmetry", text="Radial") | col.prop(vpaint, "radial_symmetry", text="Radial") | ||||
| # ********** default tools for object-mode **************** | # ********** default tools for object-mode **************** | ||||
| class ToolSelectPanelHelper: | |||||
| """ | |||||
| Generic Class, can be used for any toolbar. | |||||
| Keep in 'space_view3d_toolbar.py' for now so it's easier to test changes. | |||||
| Eventually move into a generic module for other space types to use. | |||||
| - keymap_prefix: | |||||
| The text prefix for each key-map for this spaces tools. | |||||
| - tools_all(): | |||||
| Returns all tools defined. | |||||
| - tools_from_context(context): | |||||
| Returns tools available in this context. | |||||
| Each tool is a pair: | |||||
| ``(tool_name, keymap_actions)`` | |||||
| For a separator in the toolbar, use ``None``. | |||||
| Where: | |||||
| ``tool_name`` | |||||
| is the name to display in the interface. | |||||
| ``keymap_actions`` | |||||
| are a triple of: ``(operator_id, operator_properties, keymap_item_args)`` | |||||
| """ | |||||
| @classmethod | |||||
| def _km_actionmouse_simple(cls, kc, text, actions): | |||||
| km_idname = cls.keymap_prefix + text | |||||
| km = kc.keymaps.new(km_idname, space_type=cls.bl_space_type, region_type='WINDOW') | |||||
| for op_idname, op_props_dict, kmi_kwargs in actions: | |||||
| kmi = km.keymap_items.new(op_idname, **kmi_kwargs) | |||||
| kmi_props = kmi.properties | |||||
| if op_props_dict: | |||||
| for prop_id, value in op_props_dict.items(): | |||||
| setattr(kmi_props, prop_id, value) | |||||
| return km, km_idname | |||||
| @classmethod | |||||
| def register(cls): | |||||
| wm = bpy.context.window_manager | |||||
| # XXX, should we be manipulating the user-keyconfig on load? | |||||
| # Perhaps this should only add when keymap items don't already exist. | |||||
| # | |||||
| # This needs some careful consideration. | |||||
| kc = wm.keyconfigs.user | |||||
| # {tool_name: (keymap, keymap_idname), ...} | |||||
| cls._tool_keymaps = {} | |||||
| for t in cls.tools_all(): | |||||
| text, actions = t | |||||
| km, km_idname = cls._km_actionmouse_simple(kc, text, actions) | |||||
| cls._tool_keymaps[text] = km, km_idname | |||||
| def draw(self, context): | |||||
| # XXX, this UI isn't very nice. | |||||
| # We might need to create new button types for this. | |||||
| # Since we probably want: | |||||
| # - tool-tips that include multiple key shortcuts. | |||||
| # - ability to click and hold to expose sub-tools. | |||||
| workspace = context.workspace | |||||
| km_idname_active = workspace.tool_active_keymap | |||||
| layout = self.layout | |||||
| for tool_items in self.tools_from_context(context): | |||||
| if tool_items: | |||||
| col = layout.box().column() | |||||
| for item in tool_items: | |||||
| if item is None: | |||||
| col = layout.box().column() | |||||
| continue | |||||
| text, actions = item | |||||
| km, km_idname = self._tool_keymaps[text] | |||||
| props = col.operator( | |||||
| "wm.operator_tool_set", | |||||
| text=text, | |||||
| emboss=km_idname_active == km_idname, | |||||
| ) | |||||
| props.name = km_idname | |||||
| class VIEW3D_PT_tools_active(ToolSelectPanelHelper, View3DPanel, Panel): | |||||
| bl_category = "Tools" | |||||
| bl_label = "Active Tool" | |||||
| # ToolSelectPanelHelper: | |||||
| keymap_prefix = "3D View Tool: " | |||||
| # for reuse | |||||
| _tools_transform = ( | |||||
| ("Translate", (("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)), | |||||
| ("Rotate", (("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)), | |||||
| ("Scale", (("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)), | |||||
| ) | |||||
| _tools = { | |||||
| None: [ | |||||
| ("Cursor", (("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='CLICK')),)), | |||||
| ("Select Border", ( | |||||
| ("view3d.select_border", dict(gesture_mode=3), dict(type='EVT_TWEAK_A', value='ANY')), | |||||
| ("view3d.select_border", dict(gesture_mode=4), dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)), | |||||
| )), | |||||
| ("Select Circle", ( | |||||
| ("view3d.select_circle", dict(gesture_mode=3), dict(type='ACTIONMOUSE', value='PRESS')), | |||||
| ("view3d.select_circle", dict(gesture_mode=4), dict(type='ACTIONMOUSE', value='PRESS', ctrl=True)), | |||||
| )), | |||||
| ("Select Lasso", ( | |||||
| ("view3d.select_lasso", dict(deselect=False), dict(type='EVT_TWEAK_A', value='ANY')), | |||||
| ("view3d.select_lasso", dict(deselect=True), dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)), | |||||
| )), | |||||
| ], | |||||
| 'OBJECT': [ | |||||
| *_tools_transform, | |||||
| ], | |||||
| 'POSE': [ | |||||
| *_tools_transform, | |||||
| ], | |||||
| 'EDIT_ARMATURE': [ | |||||
| *_tools_transform, | |||||
| ("Roll", ( | |||||
| ("transform.transform", | |||||
| dict(release_confirm=True, mode='BONE_ROLL'), | |||||
| dict(type='EVT_TWEAK_A', value='ANY')), | |||||
| )), | |||||
| None, | |||||
| ("Extrude Cursor", (("armature.click_extrude", dict(), dict(type='ACTIONMOUSE', value='PRESS')),)), | |||||
| ], | |||||
| 'EDIT_MESH': [ | |||||
| *_tools_transform, | |||||
| None, | |||||
| ("Extrude Cursor", (("mesh.dupli_extrude_cursor", dict(), dict(type='ACTIONMOUSE', value='PRESS')),)), | |||||
| ], | |||||
| 'EDIT_CURVE': [ | |||||
| *_tools_transform, | |||||
| None, | |||||
| ("Draw", (("curve.draw", dict(wait_for_input=False), dict(type='ACTIONMOUSE', value='PRESS')),)), | |||||
| ("Extrude Cursor", (("curve.vertex_add", dict(), dict(type='ACTIONMOUSE', value='PRESS')),)), | |||||
| ], | |||||
| } | |||||
| @classmethod | |||||
| def tools_from_context(cls, context): | |||||
| return (cls._tools[None], cls._tools.get(context.mode, ())) | |||||
| @classmethod | |||||
| def tools_all(cls): | |||||
| return [t for t_list in cls._tools.values() for t in t_list if t is not None] | |||||
| class VIEW3D_PT_tools_transform(View3DPanel, Panel): | class VIEW3D_PT_tools_transform(View3DPanel, Panel): | ||||
| bl_category = "Tools" | bl_category = "Tools" | ||||
| bl_context = "objectmode" | bl_context = "objectmode" | ||||
| bl_label = "Transform" | bl_label = "Transform" | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| ▲ Show 20 Lines • Show All 1,985 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| col = layout.column(align=True) | col = layout.column(align=True) | ||||
| col.label(text="Repeat:") | col.label(text="Repeat:") | ||||
| col.operator("screen.repeat_last") | col.operator("screen.repeat_last") | ||||
| col.operator("screen.repeat_history", text="History...") | col.operator("screen.repeat_history", text="History...") | ||||
| classes = ( | classes = ( | ||||
| VIEW3D_PT_tools_active, | |||||
| VIEW3D_PT_tools_transform, | VIEW3D_PT_tools_transform, | ||||
| VIEW3D_PT_tools_object, | VIEW3D_PT_tools_object, | ||||
| VIEW3D_PT_tools_add_object, | VIEW3D_PT_tools_add_object, | ||||
| VIEW3D_PT_tools_relations, | VIEW3D_PT_tools_relations, | ||||
| VIEW3D_PT_tools_animation, | VIEW3D_PT_tools_animation, | ||||
| VIEW3D_PT_tools_rigid_body, | VIEW3D_PT_tools_rigid_body, | ||||
| VIEW3D_PT_tools_transform_mesh, | VIEW3D_PT_tools_transform_mesh, | ||||
| VIEW3D_PT_tools_meshedit, | VIEW3D_PT_tools_meshedit, | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||