diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-22 15:00:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-22 16:31:06 +0300 |
commit | 96a7ed8a159fec97ab19a6d19ffe6201a4ee2b35 (patch) | |
tree | ad7164dbc343e62551de15e96c3bdb4841560453 /release | |
parent | 298f8042efe12b4a8861a83c860b3adb0d56f1f6 (diff) |
Tool System: store operator properties in the tool
This replaces last-used property use which wasn't reliable since
properties were not considered 'set' - causing them to be ignored.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 15 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 22 |
2 files changed, 17 insertions, 20 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 717beac1289..8a494369cf5 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -237,14 +237,11 @@ class ToolSelectPanelHelper: """ Return the active Python tool definition and icon name. """ - workspace = context.workspace cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) if cls is not None: - tool_active_text = getattr( - ToolSelectPanelHelper._tool_active_from_context(context, space_type, mode), - "name", None) - + tool_active = ToolSelectPanelHelper._tool_active_from_context(context, space_type, mode) + tool_active_text = getattr(tool_active, "name", None) for item in ToolSelectPanelHelper._tools_flatten(cls.tools_from_context(context, mode)): if item is not None: if item.text == tool_active_text: @@ -252,8 +249,8 @@ class ToolSelectPanelHelper: icon_value = ToolSelectPanelHelper._icon_value_from_icon_handle(item.icon) else: icon_value = 0 - return (item, icon_value) - return None, 0 + return (item, tool_active, icon_value) + return None, None, 0 @staticmethod def _tool_get_by_name(context, space_type, text): @@ -517,14 +514,14 @@ class ToolSelectPanelHelper: workspace = context.workspace space_type = workspace.tools_space_type mode = workspace.tools_mode - item, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True) + item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True) if item is None: return # Note: we could show 'item.text' here but it makes the layout jitter when switcuing tools. layout.label(" ", icon_value=icon_value) draw_settings = item.draw_settings if draw_settings is not None: - draw_settings(context, layout) + draw_settings(context, layout, tool) # The purpose of this menu is to be a generic popup to select between tools diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 137ca779065..8bcd56ce561 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -293,9 +293,9 @@ class _defs_edit_mesh: @ToolDef.from_fn def rip_region(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): wm = context.window_manager - props = wm.operator_properties_last("mesh.rip_move") + props = tool.operator_properties("mesh.rip_move") props_macro = props.MESH_OT_rip layout.prop(props_macro, "use_fill") @@ -393,9 +393,9 @@ class _defs_edit_mesh: @ToolDef.from_fn def inset(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): wm = context.window_manager - props = wm.operator_properties_last("mesh.inset") + props = tool.operator_properties("mesh.inset") layout.prop(props, "use_outset") layout.prop(props, "use_individual") layout.prop(props, "use_even_offset") @@ -507,9 +507,9 @@ class _defs_edit_mesh: @ToolDef.from_fn def shrink_fatten(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): wm = context.window_manager - props = wm.operator_properties_last("transform.shrink_fatten") + props = tool.operator_properties("transform.shrink_fatten") layout.prop(props, "use_even_offset") return dict( @@ -537,9 +537,9 @@ class _defs_edit_mesh: @ToolDef.from_fn def knife(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): wm = context.window_manager - props = wm.operator_properties_last("mesh.knife_tool") + props = tool.operator_properties("mesh.knife_tool") layout.prop(props, "use_occlude_geometry") layout.prop(props, "only_selected") @@ -573,7 +573,7 @@ class _defs_edit_curve: @ToolDef.from_fn def draw(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): # Tool settings initialize operator options. tool_settings = context.tool_settings cps = tool_settings.curve_paint_settings @@ -765,9 +765,9 @@ class _defs_weight_paint: @ToolDef.from_fn def gradient(): - def draw_settings(context, layout): + def draw_settings(context, layout, tool): wm = context.window_manager - props = wm.operator_properties_last("paint.weight_gradient") + props = tool.operator_properties("paint.weight_gradient") layout.prop(props, "type") return dict( |