[Bf-blender-cvs] [f91b797b2b6] blender2.8: Tool System: remove duplicate gpencil draw UI

Campbell Barton noreply at git.blender.org
Wed Nov 14 09:20:47 CET 2018


Commit: f91b797b2b6b9d02721c8bf7449602d9f839a15b
Author: Campbell Barton
Date:   Wed Nov 14 19:19:04 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBf91b797b2b6b9d02721c8bf7449602d9f839a15b

Tool System: remove duplicate gpencil draw UI

Tool properties showed options twice.

===================================================================

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_topbar.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index cea897ae8e9..86d2fe88c39 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1214,50 +1214,8 @@ class _defs_gpencil_paint:
             ),
         )
 
-    @staticmethod
-    def draw_color_selector(context, layout, gp_settings):
-        ma = gp_settings.material
-        row = layout.row(align=True)
-
-        icon_id = 0
-        if ma:
-            icon_id = ma.id_data.preview.icon_id
-            txt_ma = ma.name
-            maxw = 25
-            if len(txt_ma) > maxw:
-                txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
-        else:
-            txt_ma = ""
-
-        row.label(text="Material:")
-        sub = row.row()
-        sub.ui_units_x = 8
-        sub.popover(
-            panel="TOPBAR_PT_gpencil_materials",
-            text=txt_ma,
-            icon_value=icon_id,
-        )
-
-        row.prop(gp_settings, "use_material_pin", text="")
-
-    def draw_settings_common(context, layout, tool):
-        row = layout.row(align=True)
-        ts = context.scene.tool_settings
-        gp_settings = ts.gpencil_paint
-        brush = gp_settings.brush
-        gp_brush = brush.gpencil_settings
-        row.template_ID_preview(gp_settings, "brush", rows=3, cols=8, hide_buttons=True)
-
-        if brush and brush.gpencil_tool == 'DRAW':
-            row = layout.row(align=True)
-            row.prop(brush, "size", text="Radius")
-            row = layout.row(align=True)
-            row.prop(gp_brush, "pen_strength", slider=True)
-
-            _defs_gpencil_paint.draw_color_selector(context, layout, gp_brush)
-
-    @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
-    def line(*, draw_settings):
+    @ToolDef.from_fn
+    def line():
         return dict(
             text="Line",
             icon="ops.gpencil.primitive_line",
@@ -1267,11 +1225,10 @@ class _defs_gpencil_paint:
                  dict(type='LINE', wait_for_input=False),
                  dict(type='EVT_TWEAK_A', value='ANY')),
             ),
-            draw_settings=draw_settings,
         )
 
-    @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
-    def box(*, draw_settings):
+    @ToolDef.from_fn
+    def box():
         return dict(
             text="Box",
             icon="ops.gpencil.primitive_box",
@@ -1281,11 +1238,10 @@ class _defs_gpencil_paint:
                  dict(type='BOX', wait_for_input=False),
                  dict(type='EVT_TWEAK_A', value='ANY')),
             ),
-            draw_settings=draw_settings,
         )
 
-    @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
-    def circle(*, draw_settings):
+    @ToolDef.from_fn
+    def circle():
         return dict(
             text="Circle",
             icon="ops.gpencil.primitive_circle",
@@ -1295,7 +1251,6 @@ class _defs_gpencil_paint:
                  dict(type='CIRCLE', wait_for_input=False),
                  dict(type='EVT_TWEAK_A', value='ANY')),
             ),
-            draw_settings=draw_settings,
         )
 
 
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 5d2e98bdd8a..6fffba1fe39 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -297,8 +297,13 @@ class _draw_left_context_mode:
 
         @staticmethod
         def GPENCIL_PAINT(context, layout, tool):
+            if tool is None:
+                return
 
-            if (tool is None) or (not tool.has_datablock):
+            is_paint = True
+            if (tool.name in {"Line", "Box", "Circle"}):
+                is_paint = False
+            elif (not tool.has_datablock):
                 return
 
             paint = context.tool_settings.gpencil_paint
@@ -358,13 +363,15 @@ class _draw_left_context_mode:
                 row.prop(gp_settings, "fill_draw_mode", text="")
                 row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
 
-            else:  # bgpsettings.tool == 'DRAW':
+            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')
+                if is_paint:
+                    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')
+                if is_paint:
+                    row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
 
                 draw_color_selector()



More information about the Bf-blender-cvs mailing list