Fix error drawing paint UI without a brush

Note that this removes image_paint.detect_data from
UnifiedPaintPanel.get_brush_mode, I can't see why it's needed,
it causes issues where the texture paint UI isn't used when it can be.
This commit is contained in:
Campbell Barton
2019-12-19 18:12:10 +11:00
parent 4440739699
commit f7611126b6
2 changed files with 24 additions and 17 deletions

View File

@@ -29,8 +29,9 @@ class UnifiedPaintPanel:
def get_brush_mode(context): def get_brush_mode(context):
""" Get the correct mode for this context. For any context where this returns None, """ Get the correct mode for this context. For any context where this returns None,
no brush options should be displayed.""" no brush options should be displayed."""
mode = context.mode
if context.mode == 'PARTICLE': if mode == 'PARTICLE':
# Particle brush settings currently completely do their own thing. # Particle brush settings currently completely do their own thing.
return None return None
@@ -54,14 +55,13 @@ class UnifiedPaintPanel:
if space_data.show_uvedit: if space_data.show_uvedit:
return 'UV_SCULPT' return 'UV_SCULPT'
return 'PAINT_2D' return 'PAINT_2D'
elif space_type in {'VIEW_3D', 'PROPERTIES'}:
if space_type in {'VIEW_3D', 'PROPERTIES'}: if mode == 'PAINT_TEXTURE':
if context.mode == 'PAINT_TEXTURE': if tool_settings.image_paint:
if tool_settings.image_paint and tool_settings.image_paint.detect_data(): return mode
return context.mode
else: else:
return None return None
return context.mode return mode
return None return None
@staticmethod @staticmethod
@@ -91,7 +91,7 @@ class UnifiedPaintPanel:
return tool_settings.gpencil_paint return tool_settings.gpencil_paint
elif mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}: elif mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
return tool_settings.gpencil_sculpt return tool_settings.gpencil_sculpt
return False return None
@staticmethod @staticmethod
def prop_unified( def prop_unified(
@@ -160,6 +160,8 @@ class BrushSelectPanel(BrushPanel):
row.column().template_ID(settings, "brush", new="brush.add") row.column().template_ID(settings, "brush", new="brush.add")
col = row.column() col = row.column()
col.menu("VIEW3D_MT_brush_context_menu", icon='DOWNARROW_HLT', text="") col.menu("VIEW3D_MT_brush_context_menu", icon='DOWNARROW_HLT', text="")
if brush is not None:
col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")
if brush.use_custom_icon: if brush.use_custom_icon:

View File

@@ -400,6 +400,11 @@ class VIEW3D_PT_tools_brush_settings(Panel, View3DPaintBrushPanel):
bl_context = ".paint_common" bl_context = ".paint_common"
bl_label = "Brush Settings" bl_label = "Brush Settings"
@classmethod
def poll(cls, context):
settings = cls.paint_settings(context)
return settings and settings.brush is not None
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -491,8 +496,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
brush = context.tool_settings.image_paint.brush brush = context.tool_settings.image_paint.brush
ob = context.active_object return (brush is not None and context.active_object is not None)
return (brush is not None and ob is not None)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -1373,6 +1377,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePenci
if context.mode == 'PAINT_GPENCIL': if context.mode == 'PAINT_GPENCIL':
brush = tool_settings.gpencil_paint.brush brush = tool_settings.gpencil_paint.brush
if brush is not None:
gp_settings = brush.gpencil_settings gp_settings = brush.gpencil_settings
col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")