[Bf-blender-cvs] [d7a8a606889] master: UI: Add extra bevel options to popover from tool settings bar

Hans Goudey noreply at git.blender.org
Thu Dec 12 17:59:35 CET 2019


Commit: d7a8a606889fed58775c88bfdc079bee3c9333e2
Author: Hans Goudey
Date:   Thu Dec 12 11:56:20 2019 -0500
Branches: master
https://developer.blender.org/rBd7a8a606889fed58775c88bfdc079bee3c9333e2

UI: Add extra bevel options to popover from tool settings bar

Also adds a generic popover that can be used whenever an active tool has too
many settings than can fit in the horizontal area. The popover calls the active
tool's draw_settings with "extra" set to True.

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

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

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index f0c1b0d135f..639fb2a31a4 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -590,12 +590,52 @@ class _defs_edit_mesh:
 
     @ToolDef.from_fn
     def bevel():
-        def draw_settings(_context, layout, tool):
+        def draw_settings(context, layout, tool, *, extra=False):
             props = tool.operator_properties("mesh.bevel")
-            layout.prop(props, "offset_type")
-            layout.prop(props, "segments")
-            layout.prop(props, "profile", slider=True)
-            layout.prop(props, "vertex_only")
+            region_type = context.region.type
+
+            if extra == False:
+                if props.offset_type == 'PERCENT':
+                    layout.prop(props, "offset_pct")
+                else:
+                    offset_text = "Width"
+                    if props.offset_type == 'DEPTH':
+                        offset_text = "Depth"
+                    elif props.offset_type == 'OFFSET':
+                        offset_text = "Offset"
+                    layout.prop(props, "offset", text=offset_text)
+                if region_type == 'TOOL_HEADER':
+                    layout.prop(props, "offset_type", text="")
+                else:
+                    layout.prop(props, "offset_type")
+
+                layout.prop(props, "segments")
+                layout.prop(props, "profile", slider=True)
+
+                if region_type == 'TOOL_HEADER':
+                    layout.popover("TOPBAR_PT_tool_settings_extra", text="...")
+                else:
+                    extra = True
+
+            if extra or region_type != 'TOOL_HEADER':
+                layout.prop(props, "vertex_only")
+                layout.prop(props, "clamp_overlap")
+                layout.prop(props, "loop_slide")
+                layout.prop(props, "mark_seam")
+                layout.prop(props, "mark_sharp")
+                layout.prop(props, "harden_normals")
+
+                layout.prop(props, "material")
+
+                layout.prop(props, "miter_outer", text="Outer Miter")
+                layout.prop(props, "miter_inner", text="Inner Miter")
+                if props.miter_inner == 'ARC':
+                    layout.prop(props, "spread")
+
+                layout.prop(props, "use_custom_profile")
+                if props.use_custom_profile:
+                    tool_settings = context.tool_settings
+                    layout.template_curveprofile(tool_settings, "custom_bevel_profile_preset")
 
         return dict(
             idname="builtin.bevel",
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 09531cb5ef6..2e2c5adb970 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -20,7 +20,6 @@
 import bpy
 from bpy.types import Header, Menu, Panel
 
-
 class TOPBAR_HT_upper_bar(Header):
     bl_space_type = 'TOPBAR'
 
@@ -78,6 +77,30 @@ class TOPBAR_HT_upper_bar(Header):
             unlink="scene.view_layer_remove")
 
 
+class TOPBAR_PT_tool_settings_extra(Panel):
+    """
+    Popover panel for adding extra options that don't fit in the tool settings header
+    """
+    bl_idname = "TOPBAR_PT_tool_settings_extra"
+    bl_region_type = 'HEADER'
+    bl_space_type = 'TOPBAR'
+    bl_label = "Extra Options"
+
+    def draw(self, context):
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        layout = self.layout
+
+        # Get the active tool
+        space_type, mode = ToolSelectPanelHelper._tool_key_from_context(context)
+        cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
+        item, tool, _ = cls._tool_get_active(context, space_type, mode, with_icon=True)
+        if item is None:
+            return
+
+        # Draw the extra settings
+        item.draw_settings(context, layout, tool, extra=True)
+
+
 class TOPBAR_PT_tool_fallback(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'HEADER'
@@ -790,6 +813,7 @@ classes = (
     TOPBAR_MT_window,
     TOPBAR_MT_help,
     TOPBAR_PT_tool_fallback,
+    TOPBAR_PT_tool_settings_extra,
     TOPBAR_PT_gpencil_layers,
     TOPBAR_PT_gpencil_primitive,
     TOPBAR_PT_gpencil_fill,



More information about the Bf-blender-cvs mailing list