[Bf-blender-cvs] [f087a225dcc] master: GPencil: Hide Brush panels for some tools

Antonio Vazquez noreply at git.blender.org
Wed Jun 9 12:53:06 CEST 2021


Commit: f087a225dcc445dfc56d34f15ae967e4121f9838
Author: Antonio Vazquez
Date:   Wed Jun 9 12:11:38 2021 +0200
Branches: master
https://developer.blender.org/rBf087a225dcc445dfc56d34f15ae967e4121f9838

GPencil: Hide Brush panels for some tools

Some tools don't use brush and the panel must be hidden.

Reviewed By: mendio

Differential Revision: https://developer.blender.org/D11518

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

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 2e89ddcb1d4..0da0716e850 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -179,21 +179,6 @@ class GreasePencilBrushFalloff:
     bl_label = "Falloff"
     bl_options = {'DEFAULT_CLOSED'}
 
-    @classmethod
-    def poll(cls, context):
-        ts = context.tool_settings
-        settings = None
-        if context.mode == 'PAINT_GPENCIL':
-            settings = ts.gpencil_paint
-        if context.mode == 'SCULPT_GPENCIL':
-            settings = ts.gpencil_sculpt_paint
-        elif context.mode == 'WEIGHT_GPENCIL':
-            settings = ts.gpencil_weight_paint
-        elif context.mode == 'VERTEX_GPENCIL':
-            settings = ts.gpencil_vertex_paint
-
-        return (settings and settings.brush and settings.brush.curve)
-
     def draw(self, context):
         layout = self.layout
         ts = context.tool_settings
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 604509b99f9..89bb2005f53 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1322,6 +1322,14 @@ class VIEW3D_PT_tools_particlemode_options_display(View3DPanel, Panel):
 
 # Grease Pencil drawing brushes
 
+def tool_use_brush(context):
+    from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+    tool = ToolSelectPanelHelper.tool_active_from_context(context)
+    if tool and tool.has_datablock is False:
+        return False
+
+    return True
+
 
 class GreasePencilPaintPanel:
     bl_context = ".greasepencil_paint"
@@ -1333,6 +1341,10 @@ class GreasePencilPaintPanel:
             if context.gpencil_data is None:
                 return False
 
+            # Hide for tools not using bruhses
+            if tool_use_brush(context) is False:
+                return False
+
             gpd = context.gpencil_data
             return bool(gpd.is_stroke_paint_mode)
         else:
@@ -1718,9 +1730,14 @@ class VIEW3D_PT_tools_grease_pencil_brush_paint_falloff(GreasePencilBrushFalloff
         if brush is None:
             return False
 
-        tool = brush.gpencil_tool
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        tool = ToolSelectPanelHelper.tool_active_from_context(context)
+        if tool and tool.idname  != 'builtin_brush.Tint':
+            return False
+
+        gptool = brush.gpencil_tool
 
-        return (settings and settings.brush and settings.brush.curve and tool == 'TINT')
+        return (settings and settings.brush and settings.brush.curve and gptool == 'TINT')
 
 
 # Grease Pencil stroke sculpting tools
@@ -2039,6 +2056,11 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
         if context.region.type == 'TOOL_HEADER':
             return False
 
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        tool = ToolSelectPanelHelper.tool_active_from_context(context)
+        if tool and tool.idname in('builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'):
+            return False
+
         if brush.gpencil_tool == 'TINT':
             return True
 
@@ -2095,6 +2117,11 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
         if ob is None or brush is None:
             return False
 
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        tool = ToolSelectPanelHelper.tool_active_from_context(context)
+        if tool and tool.idname in('builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'):
+            return False
+
         if brush.gpencil_tool == 'TINT':
             return True



More information about the Bf-blender-cvs mailing list