[Bf-blender-cvs] [f775fff2462] greasepencil-object: Cleanup: Split GP Sculpt and Weight Paint panels into separate classes
Joshua Leung
noreply at git.blender.org
Wed Dec 13 10:10:31 CET 2017
Commit: f775fff246254c13c3fc3e0e93e9e9b5194acfc0
Author: Joshua Leung
Date: Wed Dec 13 22:08:24 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rBf775fff246254c13c3fc3e0e93e9e9b5194acfc0
Cleanup: Split GP Sculpt and Weight Paint panels into separate classes
This resolves the need for the draw_header() + empty bl_label
hacks used to try and get this changing dynamically.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.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 09e6d858d5d..e92f834c39a 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -433,7 +433,7 @@ class GreasePencilBrushOptionsPanel:
class GreasePencilStrokeSculptPanel:
# subclass must set
# bl_space_type = 'IMAGE_EDITOR'
- bl_label = " " # NOTE: This is left blank as the text varies dynamically (see below)
+ bl_label = "Sculpt Strokes"
bl_category = "Tools"
bl_region_type = 'TOOLS'
@@ -448,19 +448,10 @@ class GreasePencilStrokeSculptPanel:
if not is_3d_view:
return bool(gpd.use_stroke_edit_mode)
else:
- return bool(gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode)
+ return bool(gpd.is_stroke_sculpt_mode)
return False
- @staticmethod
- def draw_header(self, context):
- layout = self.layout
- gpd = context.gpencil_data
- if gpd is not None and gpd.is_stroke_weight_mode:
- layout.label("Weight Paint")
- else:
- layout.label("Sculpt Strokes")
-
@staticmethod
def draw(self, context):
layout = self.layout
@@ -469,10 +460,7 @@ class GreasePencilStrokeSculptPanel:
tool = settings.tool
brush = settings.brush
- if gpd.is_stroke_sculpt_mode:
- layout.template_icon_view(settings, "tool", show_labels=True)
- if gpd.is_stroke_weight_mode:
- layout.template_icon_view(settings, "weight_tool", show_labels=True)
+ layout.template_icon_view(settings, "tool", show_labels=True)
col = layout.column()
col.prop(brush, "size", slider=True)
@@ -481,33 +469,72 @@ class GreasePencilStrokeSculptPanel:
row.prop(brush, "use_pressure_strength", text="")
col.prop(brush, "use_falloff")
- if gpd.is_stroke_sculpt_mode:
- if tool in {'SMOOTH', 'RANDOMIZE'}:
- row = layout.row(align=True)
- row.prop(settings, "affect_position", text="Position", icon='MESH_DATA', toggle=True)
- row.prop(settings, "affect_strength", text="Strength", icon='COLOR', toggle=True)
- row.prop(settings, "affect_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
-
- layout.separator()
+ if tool in {'SMOOTH', 'RANDOMIZE'}:
+ row = layout.row(align=True)
+ row.prop(settings, "affect_position", text="Position", icon='MESH_DATA', toggle=True)
+ row.prop(settings, "affect_strength", text="Strength", icon='COLOR', toggle=True)
+ row.prop(settings, "affect_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
- if tool == 'THICKNESS':
- layout.row().prop(brush, "direction", expand=True)
- elif tool == 'PINCH':
- row = layout.row(align=True)
- row.prop_enum(brush, "direction", 'ADD', text="Pinch")
- row.prop_enum(brush, "direction", 'SUBTRACT', text="Inflate")
- elif settings.tool == 'TWIST':
- row = layout.row(align=True)
- row.prop_enum(brush, "direction", 'SUBTRACT', text="CW")
- row.prop_enum(brush, "direction", 'ADD', text="CCW")
+ layout.separator()
+ if tool == 'THICKNESS':
+ layout.row().prop(brush, "direction", expand=True)
+ elif tool == 'PINCH':
row = layout.row(align=True)
- row.prop(settings, "use_select_mask")
+ row.prop_enum(brush, "direction", 'ADD', text="Pinch")
+ row.prop_enum(brush, "direction", 'SUBTRACT', text="Inflate")
+ elif settings.tool == 'TWIST':
row = layout.row(align=True)
- row.prop(settings, "selection_alpha", slider=True)
+ row.prop_enum(brush, "direction", 'SUBTRACT', text="CW")
+ row.prop_enum(brush, "direction", 'ADD', text="CCW")
- if tool == 'SMOOTH':
- layout.prop(brush, "affect_pressure")
+ row = layout.row(align=True)
+ row.prop(settings, "use_select_mask")
+ row = layout.row(align=True)
+ row.prop(settings, "selection_alpha", slider=True)
+
+ if tool == 'SMOOTH':
+ layout.prop(brush, "affect_pressure")
+
+
+class GreasePencilWeightPaintPanel:
+ # subclass must set
+ # bl_space_type = 'IMAGE_EDITOR'
+ bl_label = "Weight Paint"
+ bl_category = "Tools"
+ bl_region_type = 'TOOLS'
+
+ @classmethod
+ def poll(cls, context):
+ if context.gpencil_data is None:
+ return False
+
+ gpd = context.gpencil_data
+ if context.editable_gpencil_strokes:
+ is_3d_view = context.space_data.type == 'VIEW_3D'
+ if not is_3d_view:
+ return bool(gpd.use_stroke_edit_mode)
+ else:
+ return bool(gpd.is_stroke_weight_mode)
+
+ return False
+
+ @staticmethod
+ def draw(self, context):
+ layout = self.layout
+ gpd = context.gpencil_data
+ settings = context.tool_settings.gpencil_sculpt
+ tool = settings.tool
+ brush = settings.brush
+
+ layout.template_icon_view(settings, "weight_tool", show_labels=True)
+
+ col = layout.column()
+ col.prop(brush, "size", slider=True)
+ row = col.row(align=True)
+ row.prop(brush, "strength", slider=True)
+ row.prop(brush, "use_pressure_strength", text="")
+ col.prop(brush, "use_falloff")
class GreasePencilMultiFramePanel:
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index dfc7c1b52ae..327349297db 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -25,6 +25,7 @@ from .properties_grease_pencil_common import (
GreasePencilAnimationPanel,
GreasePencilInterpolatePanel,
GreasePencilStrokeSculptPanel,
+ GreasePencilWeightPaintPanel,
GreasePencilMultiFramePanel,
GreasePencilBrushPanel,
GreasePencilBrushOptionsPanel,
@@ -2072,6 +2073,11 @@ class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel)
bl_space_type = 'VIEW_3D'
+# Grease Pencil weight painting tools
+class VIEW3D_PT_tools_grease_pencil_weight_paint(GreasePencilWeightPaintPanel, Panel):
+ bl_space_type = 'VIEW_3D'
+
+
# Grease Pencil multiframe falloff tools
class VIEW3D_PT_tools_grease_pencil_falloff(GreasePencilMultiFramePanel, Panel):
bl_space_type = 'VIEW_3D'
@@ -2126,13 +2132,14 @@ classes = (
VIEW3D_PT_tools_transform,
VIEW3D_PT_tools_object,
VIEW3D_PT_tools_add_object,
+ VIEW3D_PT_tools_grease_pencil_draw,
VIEW3D_PT_tools_grease_pencil_edit,
VIEW3D_PT_tools_grease_pencil_sculpt,
+ VIEW3D_PT_tools_grease_pencil_weight_paint,
VIEW3D_PT_tools_grease_pencil_falloff,
VIEW3D_PT_tools_grease_pencil_brush,
VIEW3D_PT_tools_grease_pencil_brush_option,
VIEW3D_PT_tools_grease_pencil_brushcurves,
- VIEW3D_PT_tools_grease_pencil_draw,
VIEW3D_PT_tools_relations,
VIEW3D_PT_tools_animation,
VIEW3D_PT_tools_grease_pencil_animation,
More information about the Bf-blender-cvs
mailing list