Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c50
2 files changed, 23 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 8d7d67fb69f..6bdcdf57f47 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -476,7 +476,6 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
wmOperatorType *ot = WM_operatortype_find("paint.brush_select", true);
PointerRNA op_props;
WM_operator_properties_create_ptr(&op_props, ot);
- RNA_enum_set(&op_props, "paint_mode", paint_mode);
RNA_enum_set(&op_props, tool_attr, items[i].value);
/* Check for direct access to the tool. */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index a48541c990f..85dc37b9838 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -449,31 +449,40 @@ static int brush_generic_tool_set(
}
}
+static const ePaintMode brush_select_paint_modes[] = {
+ PAINT_MODE_SCULPT,
+ PAINT_MODE_VERTEX,
+ PAINT_MODE_WEIGHT,
+ PAINT_MODE_TEXTURE_3D,
+ PAINT_MODE_GPENCIL,
+};
+
static int brush_select_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ePaintMode paint_mode = RNA_enum_get(op->ptr, "paint_mode");
const bool create_missing = RNA_boolean_get(op->ptr, "create_missing");
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
const char *tool_name = "Brush";
-
- if (paint_mode == PAINT_MODE_INVALID) {
- paint_mode = BKE_paintmode_get_active_from_context(C);
- if (paint_mode == PAINT_MODE_INVALID) {
- return OPERATOR_CANCELLED;
+ int tool = 0;
+
+ ePaintMode paint_mode = PAINT_MODE_INVALID;
+ for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
+ paint_mode = brush_select_paint_modes[i];
+ const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, op_prop_id);
+ if (RNA_property_is_set(op->ptr, prop)) {
+ tool = RNA_property_enum_get(op->ptr, prop);
+ break;
}
}
- Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
- const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
- const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
-
- if (op_prop_id == NULL) {
+ if (paint_mode == PAINT_MODE_INVALID) {
return OPERATOR_CANCELLED;
}
- const int tool = RNA_enum_get(op->ptr, op_prop_id);
+ Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
+ const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
RNA_enum_name_from_value(items, tool, &tool_name);
return brush_generic_tool_set(
bmain, paint, tool,
@@ -483,16 +492,6 @@ static int brush_select_exec(bContext *C, wmOperator *op)
static void PAINT_OT_brush_select(wmOperatorType *ot)
{
- /* Keep names matching 'rna_enum_object_mode_items' (besides active). */
- static const EnumPropertyItem paint_mode_items[] = {
- {PAINT_MODE_INVALID, "ACTIVE", 0, "Current", "Set brush for active paint mode"},
- {PAINT_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
- {PAINT_MODE_VERTEX, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
- {PAINT_MODE_WEIGHT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
- {PAINT_MODE_TEXTURE_3D, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
- {PAINT_MODE_GPENCIL, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Paint", ""},
- {0, NULL, 0, NULL, NULL}
- };
PropertyRNA *prop;
/* identifiers */
@@ -508,11 +507,8 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
/* props */
/* All properties are hidden, so as not to show the redo panel. */
- prop = RNA_def_enum(ot->srna, "paint_mode", paint_mode_items, PAINT_MODE_INVALID, "Paint Mode", "");
- RNA_def_property_flag(prop, PROP_HIDDEN);
-
- for (const EnumPropertyItem *item = paint_mode_items + 1; item->identifier; item++) {
- const ePaintMode paint_mode = item->value;
+ for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
+ const ePaintMode paint_mode = brush_select_paint_modes[i];
const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
prop = RNA_def_enum(ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
RNA_def_property_flag(prop, PROP_HIDDEN);