diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-15 03:03:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-15 03:06:36 +0300 |
commit | 07541052a03740f358127b890197517433eb6d8d (patch) | |
tree | 98a9454e3e0ced32d31eedc7043a118a7274eea9 | |
parent | 62ac0996e76cf0ea1ceec3316b38dca98d0c4f6e (diff) |
Fix T60512: Weight paint brushes show weight when unused
-rw-r--r-- | release/scripts/startup/bl_ui/properties_paint_common.py | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 42 |
2 files changed, 47 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index ec12aa6c99f..2a249a475bc 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -302,8 +302,11 @@ def brush_mask_texture_settings(layout, brush): # Share between topbar and brush panel. def brush_basic_wpaint_settings(layout, context, brush, *, compact=False): - row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") + capabilities = brush.weight_paint_capabilities + + if capabilities.has_weight: + row = layout.row(align=True) + UnifiedPaintPanel.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight") row = layout.row(align=True) UnifiedPaintPanel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius") diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 5330bbb02ec..4aadcb04ad5 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -322,6 +322,12 @@ static bool rna_BrushCapabilitiesVertexPaint_has_color_get(PointerRNA *ptr) return ELEM(br->vertexpaint_tool, VPAINT_TOOL_DRAW); } +static bool rna_BrushCapabilitiesWeightPaint_has_weight_get(PointerRNA *ptr) +{ + Brush *br = (Brush *)ptr->data; + return ELEM(br->weightpaint_tool, WPAINT_TOOL_DRAW); +} + static bool rna_BrushCapabilities_has_spacing_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; @@ -394,6 +400,11 @@ static PointerRNA rna_Vertexpaint_tool_capabilities_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilitiesVertexPaint, ptr->id.data); } +static PointerRNA rna_Weightpaint_tool_capabilities_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilitiesWeightPaint, ptr->id.data); +} + static PointerRNA rna_Brush_capabilities_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilities, ptr->id.data); @@ -952,6 +963,30 @@ static void rna_def_vertex_paint_capabilities(BlenderRNA *brna) #undef VPAINT_TOOL_CAPABILITY } +static void rna_def_weight_paint_capabilities(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "BrushCapabilitiesWeightPaint", NULL); + RNA_def_struct_sdna(srna, "Brush"); + RNA_def_struct_nested(brna, srna, "Brush"); + RNA_def_struct_ui_text(srna, "Weight Paint Capabilities", + "Read-only indications of supported operations"); + +#define WPAINT_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_BrushCapabilitiesWeightPaint_" \ + #prop_name_ "_get", NULL); \ + RNA_def_property_ui_text(prop, ui_name_, NULL) + + WPAINT_TOOL_CAPABILITY(has_weight, "Has Weight"); + +#undef WPAINT_TOOL_CAPABILITY +} + static void rna_def_gpencil_options(BlenderRNA *brna) { StructRNA *srna; @@ -1981,6 +2016,12 @@ static void rna_def_brush(BlenderRNA *brna) 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, "weight_paint_capabilities", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "BrushCapabilitiesWeightPaint"); + RNA_def_property_pointer_funcs(prop, "rna_Weightpaint_tool_capabilities_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Weight Paint Capabilities", ""); + prop = RNA_def_property(srna, "gpencil_settings", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "BrushGpencilSettings"); RNA_def_property_pointer_sdna(prop, NULL, "gpencil_settings"); @@ -2056,6 +2097,7 @@ void RNA_def_brush(BlenderRNA *brna) rna_def_sculpt_capabilities(brna); rna_def_image_paint_capabilities(brna); rna_def_vertex_paint_capabilities(brna); + rna_def_weight_paint_capabilities(brna); rna_def_gpencil_options(brna); rna_def_brush_texture_slot(brna); rna_def_operator_stroke_element(brna); |