[Bf-blender-cvs] [46a6085c47a] master: UI: de-duplicate top-bar and panel paint scripts
Campbell Barton
noreply at git.blender.org
Wed Jan 2 04:59:51 CET 2019
Commit: 46a6085c47aedaeb9838a8ce10ff488913a44d87
Author: Campbell Barton
Date: Wed Jan 2 14:36:56 2019 +1100
Branches: master
https://developer.blender.org/rB46a6085c47aedaeb9838a8ce10ff488913a44d87
UI: de-duplicate top-bar and panel paint scripts
- Fixes missing check for unified brush in sculpt mode.
- Re-orders material first in gpencil paint mode
(matching color-first for other paint modes).
- Avoid minor differences (missing tablet pressure options from topbar).
- Don't repeat properties already displayed in the topbar
when opening the brush popover.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/properties_paint_common.py
M release/scripts/startup/bl_ui/space_topbar.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 8e29e03a8f6..cefe6ca1a34 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -254,29 +254,11 @@ class GreasePencilStrokeSculptPanel:
layout.template_icon_view(settings, "sculpt_tool", show_labels=True)
- row = layout.row(align=True)
- row.prop(brush, "size", slider=True)
- sub = row.row(align=True)
- sub.enabled = tool not in {'GRAB', 'CLONE'}
- sub.prop(brush, "use_pressure_radius", text="")
-
- row = layout.row(align=True)
- row.prop(brush, "strength", slider=True)
- row.prop(brush, "use_pressure_strength", text="")
-
- layout.prop(brush, "use_falloff")
-
- layout.use_property_split = False
- if tool in {'THICKNESS', 'STRENGTH'}:
- layout.row().prop(brush, "direction", expand=True)
- elif tool == 'PINCH':
- row = layout.row(align=True)
- row.prop_enum(brush, "direction", value='ADD', text="Pinch")
- row.prop_enum(brush, "direction", value='SUBTRACT', text="Inflate")
- elif tool == 'TWIST':
- row = layout.row(align=True)
- row.prop_enum(brush, "direction", value='ADD', text="CCW")
- row.prop_enum(brush, "direction", value='SUBTRACT', text="CW")
+ if not self.is_popover:
+ from .properties_paint_common import (
+ brush_basic_gpencil_sculpt_settings,
+ )
+ brush_basic_gpencil_sculpt_settings(layout, context, brush)
class GreasePencilSculptOptionsPanel:
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index f22279a1073..32c5acdf3b7 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -199,22 +199,8 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal
col.separator()
- if capabilities.has_radius:
- row = col.row(align=True)
- panel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
- panel.prop_unified_size(row, context, brush, "use_pressure_size")
-
- row = col.row(align=True)
-
- if capabilities.has_space_attenuation:
- row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
-
- panel.prop_unified_strength(row, context, brush, "strength", text="Strength")
- panel.prop_unified_strength(row, context, brush, "use_pressure_strength")
-
- if brush.image_tool in {'DRAW', 'FILL'}:
- col.separator()
- col.prop(brush, "blend", text="Blend")
+ if not panel.is_popover:
+ brush_basic_texpaint_settings(col, context, brush)
col = layout.column()
@@ -311,6 +297,187 @@ def brush_mask_texture_settings(layout, brush):
col.prop(mask_tex_slot, "offset")
col.prop(mask_tex_slot, "scale")
+# Basic Brush Options
+#
+# Share between topbar and brush panel.
+
+def brush_basic_wpaint_settings(layout, context, brush, *, compact=False):
+ row = layout.row(align=True)
+ UnifiedPaintPanel.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
+
+ 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")
+
+ 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")
+
+ layout.separator()
+ layout.prop(brush, "blend", text="" if compact else "Blend")
+
+
+def brush_basic_vpaint_settings(layout, context, brush, *, compact=False):
+ 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")
+
+ 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")
+
+ layout.separator()
+ layout.prop(brush, "blend", text="" if compact else "Blend")
+
+
+def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
+ capabilities = brush.image_paint_capabilities
+
+ 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")
+
+ 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")
+
+ if brush.image_tool in {'DRAW', 'FILL'}:
+ layout.separator()
+ layout.prop(brush, "blend", text="" if compact else "Blend")
+
+
+def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
+ tool_settings = context.tool_settings
+ capabilities = brush.sculpt_capabilities
+
+ row = layout.row(align=True)
+ ups = tool_settings.unified_paint_settings
+ if (
+ (ups.use_unified_size and ups.use_locked_size) or
+ ((not ups.use_unified_size) and brush.use_locked_size)
+ ):
+ UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
+ UnifiedPaintPanel.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
+ else:
+ UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
+ UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
+
+ UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size")
+
+ # strength, use_strength_pressure, and use_strength_attenuation
+ layout.separator()
+ 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")
+
+ if capabilities.has_strength_pressure:
+ UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength")
+
+ # direction
+ layout.separator()
+ layout.row().prop(brush, "direction", expand=True, **({"text": ""} if compact else {}))
+
+
+def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False):
+ gp_settings = brush.gpencil_settings
+
+ # Brush details
+ if brush.gpencil_tool == 'ERASE':
+ row = layout.row(align=True)
+ row.prop(brush, "size", text="Radius")
+ row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
+ row.prop(gp_settings, "use_occlude_eraser", text="", icon='XRAY')
+
+ if gp_settings.eraser_mode == 'SOFT':
+ row = layout.row(align=True)
+ row.prop(gp_settings, "pen_strength", slider=True)
+ row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
+ row = layout.row(align=True)
+ row.prop(gp_settings, "eraser_strength_factor")
+ row = layout.row(align=True)
+ row.prop(gp_settings, "eraser_thickness_factor")
+ elif brush.gpencil_tool == 'FILL':
+ col = layout.column(align=True)
+ col.prop(gp_settings, "fill_leak", text="Leak Size")
+ col.separator()
+ col.prop(brush, "size", text="Thickness")
+ col.prop(gp_settings, "fill_simplify_level", text="Simplify")
+
+ row = layout.row(align=True)
+ row.prop(gp_settings, "fill_draw_mode", text="Boundary Draw Mode")
+ row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
+
+ col = layout.column(align=True)
+ col.enabled = gp_settings.fill_draw_mode != 'STROKE'
+ col.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
+ sub = col.row(align=True)
+ sub.enabled = not gp_settings.show_fill
+ sub.prop(gp_settings, "fill_threshold", text="Threshold")
+ else: # brush.gpencil_tool == 'DRAW':
+ row = layout.row(align=True)
+ row.prop(brush, "size", text="Radius")
+ row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
+ row = layout.row(align=True)
+ row.prop(gp_settings, "pen_strength", slider=True)
+ row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
+
+
+def brush_basic_gpencil_sculpt_settings(layout, context, brush, *, compact=False):
+ tool_settings = context.tool_settings
+ settings = tool_settings.gpencil_sculpt
+ tool = settings.sculpt_tool
+
+ row = layout.row(align=True)
+ row.prop(brush, "size", slider=True)
+ sub = row.row(align=True)
+ sub.enabled = tool not in {'GRAB', 'CLONE'}
+ sub.prop(brush, "use_pressure_radius", text="")
+
+ row = layout.row(align=True)
+ row.prop(brush, "strength", slider=True)
+ row.prop(brush, "use_pressure_strength", text="")
+
+ layout.prop(brush, "use_falloff")
+
+ if compact:
+ if tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
+ row.separator()
+ row.prop(brush, "direction", expand=True, text="")
+ else:
+ use_property_split_prev = layout.use_property_split
+ layout.use_property_split = False
+ if tool in {'THICKNESS', 'STRENGTH'}:
+ layout.row().prop(brush, "direction", expand=True)
+ elif tool == 'PINCH':
+ row = layout.row(align=True)
+ row.prop_enum(brush, "direction", value='ADD', text="Pinch")
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list