diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_common.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_topbar.py | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace.c | 13 |
3 files changed, 39 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 727b0fd85b4..e03b3eb585d 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -526,6 +526,7 @@ class ToolSelectPanelHelper: draw_settings = item.draw_settings if draw_settings is not None: draw_settings(context, layout, tool) + return 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_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 5003f6c0bb9..cc3d92547e3 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -96,7 +96,7 @@ class TOPBAR_HT_lower_bar(Header): # Active Tool # ----------- from .space_toolsystem_common import ToolSelectPanelHelper - ToolSelectPanelHelper.draw_active_tool_header(context, layout) + tool = ToolSelectPanelHelper.draw_active_tool_header(context, layout) # Object Mode Options # ------------------- @@ -107,17 +107,21 @@ class TOPBAR_HT_lower_bar(Header): # (obviously separated for from the users POV) draw_fn = getattr(_draw_left_context_mode, mode, None) if draw_fn is not None: - draw_fn(context, layout) + draw_fn(context, layout, tool) # Note: general mode options should be added to 'draw_right'. if mode == 'SCULPT': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_VERTEX': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_WEIGHT': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_TEXTURE': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'EDIT_ARMATURE': pass elif mode == 'EDIT_CURVE': @@ -128,7 +132,8 @@ class TOPBAR_HT_lower_bar(Header): pass elif mode == 'PARTICLE': # Disable, only shows "Brush" panel, which is already in the top-bar. - # layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + # if tool.has_datablock: + # layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") pass elif mode == 'GPENCIL_PAINT': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".greasepencil_paint", category="") @@ -182,7 +187,9 @@ class TOPBAR_HT_lower_bar(Header): class _draw_left_context_mode: @staticmethod - def SCULPT(context, layout): + def SCULPT(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.sculpt.brush if brush is None: return @@ -193,7 +200,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") layout.prop(brush, "direction", text="", expand=True) - def PAINT_TEXTURE(context, layout): + def PAINT_TEXTURE(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.vertex_paint.brush if brush is None: return @@ -204,7 +213,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PAINT_VERTEX(context, layout): + def PAINT_VERTEX(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.vertex_paint.brush if brush is None: return @@ -215,7 +226,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PAINT_WEIGHT(context, layout): + def PAINT_WEIGHT(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.weight_paint.brush if brush is None: return @@ -226,7 +239,7 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PARTICLE(context, layout): + def PARTICLE(context, layout, tool): # See: 'VIEW3D_PT_tools_brush', basically a duplicate settings = context.tool_settings.particle_edit brush = settings.brush diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 88b79e8ee32..db6a58fa85e 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -152,6 +152,12 @@ static int rna_WorkspaceTool_index_get(PointerRNA *ptr) return (tref->runtime) ? tref->runtime->index : 0; } +static int rna_WorkspaceTool_has_datablock_get(PointerRNA *ptr) +{ + bToolRef *tref = ptr->data; + return (tref->runtime) ? (tref->runtime->data_block[0] != '\0') : false; +} + #else /* RNA_RUNTIME */ static void rna_def_workspace_owner(BlenderRNA *brna) @@ -230,6 +236,13 @@ static void rna_def_workspace_tool(BlenderRNA *brna) RNA_def_property_enum_items(prop, rna_enum_space_type_items); RNA_def_property_ui_text(prop, "Space Type", ""); + RNA_define_verify_sdna(0); + prop = RNA_def_property(srna, "has_datablock", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Datablock", ""); + RNA_def_property_boolean_funcs(prop, "rna_WorkspaceTool_has_datablock_get", NULL); + RNA_define_verify_sdna(1); + RNA_api_workspace_tool(srna); } |