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
This commit is contained in:
Antonio Vazquez
2021-06-09 12:11:38 +02:00
parent dd98f6b55c
commit f087a225dc
2 changed files with 29 additions and 17 deletions

View File

@@ -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

View File

@@ -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
return (settings and settings.brush and settings.brush.curve and tool == 'TINT')
gptool = brush.gpencil_tool
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