[Bf-blender-cvs] [85ea14df2f8] blender2.8: UI: support for tool settings in the top-bar

Campbell Barton noreply at git.blender.org
Fri Apr 27 14:17:20 CEST 2018


Commit: 85ea14df2f88448472443ab9f4ed3db52ce3c1d8
Author: Campbell Barton
Date:   Fri Apr 27 14:13:16 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB85ea14df2f88448472443ab9f4ed3db52ce3c1d8

UI: support for tool settings in the top-bar

This uses the operators last used properties
to store settings to use on the next execution.

===================================================================

M	release/scripts/startup/bl_ui/space_toolsystem_common.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 094bc56cf9a..88a06ae3286 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -87,8 +87,13 @@ class ToolDef:
     icon = None
     # An optional manipulator group to activate when the tool is set or None for no widget.
     widget = None
-    # An optional triple of: ``(operator_id, operator_properties, keymap_item_args)``.
+    # Optional keymap for tool, either:
+    # - A function that populates a keymaps passed in as an argument.
+    # - A tuple filled with triple's of:
+    #   ``(operator_id, operator_properties, keymap_item_args)``.
     keymap = None
+    # Optional draw settings (operator options, toolsettings).
+    draw_settings = None
 
 
 class ToolSelectPanelHelper:
@@ -344,6 +349,10 @@ class ToolSelectPanelHelper:
         # Indent until we have better icon scaling.
         layout.label("      " + item.text, icon_value=icon_value)
 
+        draw_settings = item.draw_settings
+        if draw_settings is not None:
+            draw_settings(context, layout)
+
 
 # The purpose of this menu is to be a generic popup to select between tools
 # in cases when a single tool allows to select alternative tools.
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 0230a2d1c87..1baf564b777 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -314,10 +314,17 @@ class _defs_edit_mesh:
         widget = None
         keymap = (
             ("mesh.knife_tool",
-             dict(wait_for_input=False, use_occlude_geometry=True, only_selected=False),
+             dict(wait_for_input=False),
              dict(type='ACTIONMOUSE', value='PRESS')),
         )
 
+        @classmethod
+        def draw_settings(cls, context, layout):
+            wm = context.window_manager
+            props = wm.operator_properties_last("mesh.knife_tool")
+            layout.prop(props, "use_occlude_geometry")
+            layout.prop(props, "only_selected")
+
     class bisect(ToolDef):
         text = "Bisect"
         icon = "ops.mesh.bisect"
@@ -374,8 +381,6 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
     def tools_all(cls):
         yield from cls._tools.items()
 
-    # Internal Data
-
     # for reuse
     _tools_transform = (
         _defs_transform.translate,



More information about the Bf-blender-cvs mailing list