Fix T60354: Paint color shown when not used
authorCampbell Barton <ideasman42@gmail.com>
Wed, 9 Jan 2019 23:10:21 +0000 (10:10 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 9 Jan 2019 23:12:23 +0000 (10:12 +1100)
Add 'has_color' check to avoid duplicated tool checks.

Also abbreviate text descriptions.

release/scripts/startup/bl_ui/properties_paint_common.py
release/scripts/startup/bl_ui/space_topbar.py
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_brush.c

index 51db0a99b7d52c5e80b800365fdead5b7c950730..9f12f2258d377ec416312322830224379bccf966 100644 (file)
@@ -113,7 +113,7 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal
 
     col = layout.column()
 
-    if brush.image_tool in {'DRAW', 'FILL'}:
+    if capabilities.has_color:
         if brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}:
             if not brush.use_gradient:
                 panel.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
@@ -318,6 +318,8 @@ def brush_basic_wpaint_settings(layout, context, brush, *, compact=False):
 
 
 def brush_basic_vpaint_settings(layout, context, brush, *, compact=False):
+    capabilities = brush.vertex_paint_capabilities
+
     row = layout.row(align=True)
     UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
     UnifiedPaintPanel.prop_unified_size(row, context, brush, "use_pressure_size")
@@ -326,8 +328,10 @@ def brush_basic_vpaint_settings(layout, context, brush, *, compact=False):
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength")
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
-    layout.separator()
-    layout.prop(brush, "blend", text="" if compact else "Blend")
+
+    if capabilities.has_color:
+        layout.separator()
+        layout.prop(brush, "blend", text="" if compact else "Blend")
 
 
 def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
@@ -346,7 +350,7 @@ def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "strength", text="Strength")
     UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
-    if brush.image_tool in {'DRAW', 'FILL'}:
+    if capabilities.has_color:
         layout.separator()
         layout.prop(brush, "blend", text="" if compact else "Blend")
 
index 94965e5d03d9b99721a8d805873b47d7a22dff0f..06a6e3dc5ac525d2da80d56e59ba00e5ed0bcf4e 100644 (file)
@@ -257,7 +257,9 @@ class _draw_left_context_mode:
                 UnifiedPaintPanel,
                 brush_basic_texpaint_settings,
             )
-            UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
+            capabilities = brush.image_paint_capabilities
+            if capabilities.has_color:
+                UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
             brush_basic_texpaint_settings(layout, context, brush, compact=True)
 
         @staticmethod
@@ -276,7 +278,9 @@ class _draw_left_context_mode:
                 UnifiedPaintPanel,
                 brush_basic_vpaint_settings,
             )
-            UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
+            capabilities = brush.vertex_paint_capabilities
+            if capabilities.has_color:
+                UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
             brush_basic_vpaint_settings(layout, context, brush, compact=True)
 
         @staticmethod
@@ -453,7 +457,9 @@ class _draw_left_context_mode:
                 UnifiedPaintPanel,
                 brush_basic_texpaint_settings,
             )
-            UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
+            capabilities = brush.image_paint_capabilities
+            if capabilities.has_color:
+                UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="")
             brush_basic_texpaint_settings(layout, context, brush, compact=True)
 
 
index 20231e2d03698308fe5e504d6d86fa5284c6a16d..0deff2ab6d2714d376952e3f8b87f19479473ddd 100644 (file)
@@ -724,6 +724,7 @@ extern StructRNA RNA_VertexPaint;
 extern StructRNA RNA_VertexWeightEditModifier;
 extern StructRNA RNA_VertexWeightMixModifier;
 extern StructRNA RNA_VertexWeightProximityModifier;
+extern StructRNA RNA_VertexpaintToolCapabilities;
 extern StructRNA RNA_View3DOverlay;
 extern StructRNA RNA_View3DShading;
 extern StructRNA RNA_ViewLayer;
index 03081ff606d912fe09b2e9ca76c39f0d11227587..79350b577088af4f1df1c96fe9d9fcece0c62288 100644 (file)
@@ -310,6 +310,18 @@ static bool rna_ImapaintToolCapabilities_has_space_attenuation_get(PointerRNA *p
                br->imagepaint_tool != PAINT_TOOL_FILL;
 }
 
+static bool rna_ImapaintToolCapabilities_has_color_get(PointerRNA *ptr)
+{
+       Brush *br = (Brush *)ptr->data;
+       return ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL);
+}
+
+static bool rna_VertexpaintToolCapabilities_has_color_get(PointerRNA *ptr)
+{
+       Brush *br = (Brush *)ptr->data;
+       return ELEM(br->vertexpaint_tool, VPAINT_TOOL_DRAW);
+}
+
 static bool rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr)
 {
        Brush *br = (Brush *)ptr->data;
@@ -377,6 +389,11 @@ static PointerRNA rna_Imapaint_tool_capabilities_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_ImapaintToolCapabilities, ptr->id.data);
 }
 
+static PointerRNA rna_Vertexpaint_tool_capabilities_get(PointerRNA *ptr)
+{
+       return rna_pointer_inherit_refine(ptr, &RNA_VertexpaintToolCapabilities, ptr->id.data);
+}
+
 static PointerRNA rna_Brush_capabilities_get(PointerRNA *ptr)
 {
        return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilities, ptr->id.data);
@@ -865,8 +882,7 @@ static void rna_def_brush_capabilities(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "Brush");
        RNA_def_struct_nested(brna, srna, "Brush");
        RNA_def_struct_ui_text(srna, "Brush Capabilities",
-                              "Read-only indications of which brush operations "
-                              "are supported by the current brush");
+                              "Read-only indications of supported operations");
 
 #define BRUSH_CAPABILITY(prop_name_, ui_name_)                          \
        prop = RNA_def_property(srna, #prop_name_,                          \
@@ -894,8 +910,7 @@ static void rna_def_image_paint_capabilities(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "Brush");
        RNA_def_struct_nested(brna, srna, "Brush");
        RNA_def_struct_ui_text(srna, "Image Paint Capabilities",
-                              "Read-only indications of which brush operations "
-                              "are supported by the current image paint brush");
+                              "Read-only indications of supported operations");
 
 #define IMAPAINT_TOOL_CAPABILITY(prop_name_, ui_name_)                       \
        prop = RNA_def_property(srna, #prop_name_,                               \
@@ -908,10 +923,35 @@ static void rna_def_image_paint_capabilities(BlenderRNA *brna)
        IMAPAINT_TOOL_CAPABILITY(has_accumulate, "Has Accumulate");
        IMAPAINT_TOOL_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
        IMAPAINT_TOOL_CAPABILITY(has_radius, "Has Radius");
+       IMAPAINT_TOOL_CAPABILITY(has_color, "Has Color");
 
 #undef IMAPAINT_TOOL_CAPABILITY
 }
 
+static void rna_def_vertex_paint_capabilities(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       srna = RNA_def_struct(brna, "VertexpaintToolCapabilities", NULL);
+       RNA_def_struct_sdna(srna, "Brush");
+       RNA_def_struct_nested(brna, srna, "Brush");
+       RNA_def_struct_ui_text(srna, "Vertex Paint Capabilities",
+                              "Read-only indications of supported operations");
+
+#define VPAINT_TOOL_CAPABILITY(prop_name_, ui_name_)                       \
+       prop = RNA_def_property(srna, #prop_name_,                               \
+                               PROP_BOOLEAN, PROP_NONE);                        \
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);                        \
+       RNA_def_property_boolean_funcs(prop, "rna_VertexpaintToolCapabilities_"     \
+                                      #prop_name_ "_get", NULL);                \
+       RNA_def_property_ui_text(prop, ui_name_, NULL)
+
+       VPAINT_TOOL_CAPABILITY(has_color, "Has Color");
+
+#undef VPAINT_TOOL_CAPABILITY
+}
+
 static void rna_def_gpencil_options(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -1927,13 +1967,19 @@ static void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
        RNA_def_property_struct_type(prop, "SculptToolCapabilities");
        RNA_def_property_pointer_funcs(prop, "rna_Sculpt_tool_capabilities_get", NULL, NULL, NULL);
-       RNA_def_property_ui_text(prop, "Sculpt Capabilities", "Brush's capabilities in sculpt mode");
+       RNA_def_property_ui_text(prop, "Sculpt Capabilities", "");
 
        prop = RNA_def_property(srna, "image_paint_capabilities", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
        RNA_def_property_struct_type(prop, "ImapaintToolCapabilities");
        RNA_def_property_pointer_funcs(prop, "rna_Imapaint_tool_capabilities_get", NULL, NULL, NULL);
-       RNA_def_property_ui_text(prop, "Image Painting Capabilities", "Brush's capabilities in image paint mode");
+       RNA_def_property_ui_text(prop, "Image Paint Capabilities", "");
+
+       prop = RNA_def_property(srna, "vertex_paint_capabilities", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_struct_type(prop, "VertexpaintToolCapabilities");
+       RNA_def_property_pointer_funcs(prop, "rna_Vertexpaint_tool_capabilities_get", NULL, NULL, NULL);
+       RNA_def_property_ui_text(prop, "Vertex Paint Capabilities", "");
 
        prop = RNA_def_property(srna, "gpencil_settings", PROP_POINTER, PROP_NONE);
        RNA_def_property_struct_type(prop, "BrushGpencilSettings");
@@ -2009,6 +2055,7 @@ void RNA_def_brush(BlenderRNA *brna)
        rna_def_brush_capabilities(brna);
        rna_def_sculpt_capabilities(brna);
        rna_def_image_paint_capabilities(brna);
+       rna_def_vertex_paint_capabilities(brna);
        rna_def_gpencil_options(brna);
        rna_def_brush_texture_slot(brna);
        rna_def_operator_stroke_element(brna);