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:
@@ -29,8 +29,9 @@ class UnifiedPaintPanel:
|
||||
def get_brush_mode(context):
|
||||
""" Get the correct mode for this context. For any context where this returns None,
|
||||
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.
|
||||
return None
|
||||
|
||||
@@ -54,14 +55,13 @@ class UnifiedPaintPanel:
|
||||
if space_data.show_uvedit:
|
||||
return 'UV_SCULPT'
|
||||
return 'PAINT_2D'
|
||||
|
||||
if space_type in {'VIEW_3D', 'PROPERTIES'}:
|
||||
if context.mode == 'PAINT_TEXTURE':
|
||||
if tool_settings.image_paint and tool_settings.image_paint.detect_data():
|
||||
return context.mode
|
||||
elif space_type in {'VIEW_3D', 'PROPERTIES'}:
|
||||
if mode == 'PAINT_TEXTURE':
|
||||
if tool_settings.image_paint:
|
||||
return mode
|
||||
else:
|
||||
return None
|
||||
return context.mode
|
||||
return mode
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
@@ -91,7 +91,7 @@ class UnifiedPaintPanel:
|
||||
return tool_settings.gpencil_paint
|
||||
elif mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
|
||||
return tool_settings.gpencil_sculpt
|
||||
return False
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def prop_unified(
|
||||
@@ -160,6 +160,8 @@ class BrushSelectPanel(BrushPanel):
|
||||
row.column().template_ID(settings, "brush", new="brush.add")
|
||||
col = row.column()
|
||||
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="")
|
||||
|
||||
if brush.use_custom_icon:
|
||||
|
@@ -400,6 +400,11 @@ class VIEW3D_PT_tools_brush_settings(Panel, View3DPaintBrushPanel):
|
||||
bl_context = ".paint_common"
|
||||
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):
|
||||
layout = self.layout
|
||||
|
||||
@@ -491,8 +496,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
brush = context.tool_settings.image_paint.brush
|
||||
ob = context.active_object
|
||||
return (brush is not None and ob is not None)
|
||||
return (brush is not None and context.active_object is not None)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -1373,6 +1377,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePenci
|
||||
|
||||
if context.mode == 'PAINT_GPENCIL':
|
||||
brush = tool_settings.gpencil_paint.brush
|
||||
if brush is not None:
|
||||
gp_settings = brush.gpencil_settings
|
||||
|
||||
col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")
|
||||
|
Reference in New Issue
Block a user