diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-27 10:39:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-27 10:43:08 +0300 |
commit | 1944bca49a22c18b059d84daf56908b6e15591ad (patch) | |
tree | 31241c6c10a0f3c9bdcaa61f54df7bad447efe42 /release | |
parent | 1f8360171cd80c0c1918486703926709cb5db7aa (diff) |
Tool System: use tools for node editor
Diffstat (limited to 'release')
4 files changed, 146 insertions, 13 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 6b8e459d16b..706eade89f1 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5050,6 +5050,46 @@ def km_image_editor_tool_uv_select_lasso(params): ) +def km_node_editor_tool_select(params): + return ( + "Node Tool: Select", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": ( + ("node.select", {"type": params.select_mouse, "value": 'PRESS'}, + {"properties": [("extend", False)]}), + ), + }, + ) + + +def km_node_editor_tool_select_box(params): + return ( + "Node Tool: Select Box", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": ( + ("node.select_box", {"type": params.tool_mouse, "value": 'PRESS'}, + {"properties": [("deselect", False), ("tweak", True)]}), + ("node.select_box", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True}, + {"properties": [("deselect", True), ("tweak", True)]}), + ), + }, + ) + + +def km_node_editor_tool_select_lasso(params): + return ( + "Node Tool: Select Lasso", + {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'}, + {"items": ( + ("node.select_lasso", {"type": params.tool_mouse, "value": 'PRESS'}, + {"properties": [("deselect", False)]}), + ("node.select_lasso", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True}, + {"properties": [("deselect", True)]}), + ), + }, + ) + + def km_3d_view_tool_object_cursor(params): return ( "3D View Tool: Object, Cursor", @@ -5902,6 +5942,9 @@ def generate_keymaps(params=None): km_image_editor_tool_uv_select_box(params), km_image_editor_tool_uv_select_circle(params), km_image_editor_tool_uv_select_lasso(params), + km_node_editor_tool_select(params), + km_node_editor_tool_select_box(params), + km_node_editor_tool_select_lasso(params), km_3d_view_tool_object_cursor(params), km_3d_view_tool_object_select(params), km_3d_view_tool_object_select_box(params), diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 789fc1b0a31..6ec264ff699 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -553,18 +553,6 @@ class NODE_PT_grease_pencil_tools(GreasePencilToolsPanel, Panel): # toolbar, but which may not necessarily be open -# Tool Shelf ------------------ - - -# Grease Pencil drawing tools -class NODE_PT_tools_grease_pencil_draw(AnnotationDrawingToolsPanel, Panel): - bl_space_type = 'NODE_EDITOR' - bl_region_type = 'TOOLS' - - -# ----------------------------- - - def node_draw_tree_view(layout, context): pass @@ -587,7 +575,6 @@ classes = ( NODE_UL_interface_sockets, NODE_PT_grease_pencil, NODE_PT_grease_pencil_tools, - NODE_PT_tools_grease_pencil_draw, ) diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 2ff5c9692ec..9349f776c99 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -293,6 +293,12 @@ class ToolSelectPanelHelper: if tool is not None: tool.refresh_from_context() return tool + elif space_type == 'NODE_EDITOR': + space_data = context.space_data + tool = context.workspace.tools.from_space_node(create=create) + if tool is not None: + tool.refresh_from_context() + return tool return None @staticmethod diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 1f2b4ca47ee..cefc900b8b3 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1164,6 +1164,49 @@ class _defs_gpencil_weight: ) +class _defs_node_select: + + @ToolDef.from_fn + def select(): + def draw_settings(context, layout, tool): + pass + return dict( + text="Select", + icon="ops.generic.select", + widget=None, + keymap="Node Tool: Select", + draw_settings=draw_settings, + ) + + @ToolDef.from_fn + def box(): + def draw_settings(context, layout, tool): + props = tool.operator_properties("node.select_box") + layout.prop(props, "deselect") + pass + return dict( + text="Select Box", + icon="ops.generic.select_box", + widget=None, + keymap="Node Tool: Select Box", + draw_settings=draw_settings, + ) + + @ToolDef.from_fn + def lasso(): + def draw_settings(context, layout, tool): + props = tool.operator_properties("node.select_lasso") + layout.prop(props, "deselect") + pass + return dict( + text="Select Lasso", + icon="ops.generic.select_lasso", + widget=None, + keymap="Node Tool: Select Lasso", + draw_settings=draw_settings, + ) + + class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'TOOLS' @@ -1243,6 +1286,59 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel): } +class NODE_PT_tools_active(ToolSelectPanelHelper, Panel): + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'TOOLS' + bl_label = "Tools" # not visible + bl_options = {'HIDE_HEADER'} + + # Satisfy the 'ToolSelectPanelHelper' API. + keymap_prefix = "Node Editor Tool:" + + @classmethod + def tools_from_context(cls, context, mode=None): + if mode is None: + if context.space_data is None: + mode = None + else: + mode = context.space_data.tree_type + for tools in (cls._tools[None], cls._tools.get(mode, ())): + for item in tools: + if not (type(item) is ToolDef) and callable(item): + yield from item(context) + else: + yield item + + @classmethod + def tools_all(cls): + yield from cls._tools.items() + + _tools_select = ( + ( + _defs_node_select.select, + _defs_node_select.box, + _defs_node_select.lasso, + ), + ) + + _tools_annotate = ( + ( + _defs_annotate.scribble, + _defs_annotate.line, + _defs_annotate.poly, + _defs_annotate.eraser, + ), + ) + + _tools = { + None: [ + *_tools_select, + None, + *_tools_annotate, + ], + } + + class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' @@ -1507,6 +1603,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): classes = ( IMAGE_PT_tools_active, + NODE_PT_tools_active, VIEW3D_PT_tools_active, ) |