forked from bartvdbraak/blender
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.
This commit is contained in:
parent
c8d121bf35
commit
d7a8a60688
@ -590,12 +590,52 @@ class _defs_edit_mesh:
|
|||||||
|
|
||||||
@ToolDef.from_fn
|
@ToolDef.from_fn
|
||||||
def bevel():
|
def bevel():
|
||||||
def draw_settings(_context, layout, tool):
|
def draw_settings(context, layout, tool, *, extra=False):
|
||||||
props = tool.operator_properties("mesh.bevel")
|
props = tool.operator_properties("mesh.bevel")
|
||||||
layout.prop(props, "offset_type")
|
region_type = context.region.type
|
||||||
layout.prop(props, "segments")
|
|
||||||
layout.prop(props, "profile", slider=True)
|
if extra == False:
|
||||||
layout.prop(props, "vertex_only")
|
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(
|
return dict(
|
||||||
idname="builtin.bevel",
|
idname="builtin.bevel",
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Header, Menu, Panel
|
from bpy.types import Header, Menu, Panel
|
||||||
|
|
||||||
|
|
||||||
class TOPBAR_HT_upper_bar(Header):
|
class TOPBAR_HT_upper_bar(Header):
|
||||||
bl_space_type = 'TOPBAR'
|
bl_space_type = 'TOPBAR'
|
||||||
|
|
||||||
@ -78,6 +77,30 @@ class TOPBAR_HT_upper_bar(Header):
|
|||||||
unlink="scene.view_layer_remove")
|
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):
|
class TOPBAR_PT_tool_fallback(Panel):
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'HEADER'
|
bl_region_type = 'HEADER'
|
||||||
@ -790,6 +813,7 @@ classes = (
|
|||||||
TOPBAR_MT_window,
|
TOPBAR_MT_window,
|
||||||
TOPBAR_MT_help,
|
TOPBAR_MT_help,
|
||||||
TOPBAR_PT_tool_fallback,
|
TOPBAR_PT_tool_fallback,
|
||||||
|
TOPBAR_PT_tool_settings_extra,
|
||||||
TOPBAR_PT_gpencil_layers,
|
TOPBAR_PT_gpencil_layers,
|
||||||
TOPBAR_PT_gpencil_primitive,
|
TOPBAR_PT_gpencil_primitive,
|
||||||
TOPBAR_PT_gpencil_fill,
|
TOPBAR_PT_gpencil_fill,
|
||||||
|
Loading…
Reference in New Issue
Block a user