From d8daeeb9300953ee175e06c8fc1aa3a44a72da20 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Mar 2019 16:19:37 +1100 Subject: [PATCH] UI: Avoid redundant text argument to UnifiedPaintPanel methods Now when the text argument is omitted, use the default name matching how regular properties work. Avoids passing in the same name which RNA has, matches UILayout.prop behavior. Also use keyword only for optional arguments. --- .../startup/bl_ui/properties_paint_common.py | 44 +++++++++---------- release/scripts/startup/bl_ui/space_image.py | 8 ++-- .../startup/bl_ui/space_toolsystem_toolbar.py | 6 +-- release/scripts/startup/bl_ui/space_topbar.py | 8 ++-- release/scripts/startup/bl_ui/space_view3d.py | 18 ++++---- 5 files changed, 41 insertions(+), 43 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 9a7f5d6437e..1a1f0fa3fb7 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -66,25 +66,25 @@ class UnifiedPaintPanel: col.prop(ups, "use_unified_color", text="Color") @staticmethod - def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False): + def prop_unified_size(parent, context, brush, prop_name, *, icon='NONE', text=None, slider=False): ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_size else brush parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) @staticmethod - def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False): + def prop_unified_strength(parent, context, brush, prop_name, *, icon='NONE', text=None, slider=False): ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_strength else brush parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) @staticmethod - def prop_unified_weight(parent, context, brush, prop_name, icon='NONE', text="", slider=False): + def prop_unified_weight(parent, context, brush, prop_name, *, icon='NONE', text=None, slider=False): ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_weight else brush parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) @staticmethod - def prop_unified_color(parent, context, brush, prop_name, text=""): + def prop_unified_color(parent, context, brush, prop_name, *, text=None): ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_color else brush parent.prop(ptr, prop_name, text=text) @@ -306,15 +306,15 @@ def brush_basic_wpaint_settings(layout, context, brush, *, compact=False): if capabilities.has_weight: row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") + UnifiedPaintPanel.prop_unified_weight(row, context, brush, "weight", slider=True) row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength") - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") layout.separator() layout.prop(brush, "blend", text="" if compact else "Blend") @@ -324,12 +324,12 @@ def brush_basic_vpaint_settings(layout, context, brush, *, compact=False): capabilities = brush.vertex_paint_capabilities row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength") - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") if capabilities.has_color: @@ -342,16 +342,16 @@ def brush_basic_texpaint_settings(layout, context, brush, *, compact=False): if capabilities.has_radius: row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") row = layout.row(align=True) if capabilities.has_space_attenuation: row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength") - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") if capabilities.has_color: layout.separator() @@ -363,7 +363,7 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False): capabilities = brush.sculpt_capabilities row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_locked_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_locked_size", text="") ups = tool_settings.unified_paint_settings if ( @@ -372,9 +372,9 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False): ): UnifiedPaintPanel.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius") else: - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") # strength, use_strength_pressure, and use_strength_attenuation layout.separator() @@ -383,10 +383,10 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False): if capabilities.has_space_attenuation: row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength") if capabilities.has_strength_pressure: - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") # direction layout.separator() diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index ac0e28f90cc..14de0d9826a 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1148,12 +1148,12 @@ class IMAGE_PT_uv_sculpt(Panel): col = layout.column() row = col.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") row = col.row(align=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength") - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", slider=True) + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") col = layout.column() col.prop(tool_settings, "uv_sculpt_lock_borders") diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index cc17f6cfbe8..242c90635df 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -981,10 +981,8 @@ class _defs_weight_paint: brush = context.tool_settings.weight_paint.brush if brush is not None: from .properties_paint_common import UnifiedPaintPanel - UnifiedPaintPanel.prop_unified_weight( - layout, context, brush, "weight", slider=True, text="Weight") - UnifiedPaintPanel.prop_unified_strength( - layout, context, brush, "strength", slider=True, text="Strength") + UnifiedPaintPanel.prop_unified_weight(layout, context, brush, "weight", slider=True) + UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True) props = tool.operator_properties("paint.weight_gradient") layout.prop(props, "type") diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 135982130b0..6e780df126d 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -441,12 +441,12 @@ class _draw_left_context_mode: from .properties_paint_common import UnifiedPaintPanel row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") - UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size") + UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size", text="") row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength") - UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength") + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", slider=True) + UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="") @staticmethod def PAINT(context, layout, tool): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 61fd6d0318b..fc8e098eac5 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -5747,8 +5747,8 @@ class VIEW3D_PT_paint_vertex_context_menu(Panel): layout = self.layout brush = context.tool_settings.vertex_paint.brush - UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", text="Size", slider=True) - UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", text="Strength") + UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength") class VIEW3D_PT_paint_texture_context_menu(Panel): @@ -5761,8 +5761,8 @@ class VIEW3D_PT_paint_texture_context_menu(Panel): layout = self.layout brush = context.tool_settings.image_paint.brush - UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", text="Size", slider=True) - UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", text="Strength") + UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength") class VIEW3D_PT_paint_weight_context_menu(Panel): @@ -5775,9 +5775,9 @@ class VIEW3D_PT_paint_weight_context_menu(Panel): layout = self.layout brush = context.tool_settings.weight_paint.brush - UnifiedPaintPanel.prop_unified_weight(layout, context, brush, "weight", text="Weight", slider=True) - UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", text="Size", slider=True) - UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", text="Strength") + UnifiedPaintPanel.prop_unified_weight(layout, context, brush, "weight", slider=True) + UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength") class VIEW3D_PT_sculpt_context_menu(Panel): @@ -5791,8 +5791,8 @@ class VIEW3D_PT_sculpt_context_menu(Panel): brush = context.tool_settings.sculpt.brush - UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", text="Size", slider=True) - UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", text="Strength") + UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True) + UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength") class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):