diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-12-19 10:12:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-12-19 12:05:40 +0300 |
commit | f7611126b6f1382f60e84433a1d1a05c5679d29a (patch) | |
tree | a50d0b4c6adb7586ee57bce6d6bd1efd8cc0b76e | |
parent | 4440739699bb237da8126168117e501aec770e89 (diff) |
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.
-rw-r--r-- | release/scripts/startup/bl_ui/properties_paint_common.py | 24 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 17 |
2 files changed, 24 insertions, 17 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index ee9fb3805b2..5f866699744 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -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,10 +160,12 @@ 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="") - col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") - if brush.use_custom_icon: - layout.prop(brush, "icon_filepath", text="") + if brush is not None: + col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") + + if brush.use_custom_icon: + layout.prop(brush, "icon_filepath", text="") class ColorPalettePanel(BrushPanel): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 99e50f8ccef..07ebacfb77f 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -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,12 +1377,13 @@ class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePenci if context.mode == 'PAINT_GPENCIL': brush = tool_settings.gpencil_paint.brush - gp_settings = brush.gpencil_settings + if brush is not None: + 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="") - if brush.use_custom_icon: - layout.row().prop(brush, "icon_filepath", text="") + if brush.use_custom_icon: + layout.row().prop(brush, "icon_filepath", text="") class VIEW3D_PT_tools_grease_pencil_brush_settings(Panel, View3DPanel, GreasePencilPanel): |