Paint: remove brush select paint_mode
Instead check which property has been set.
This commit is contained in:
@@ -3597,27 +3597,27 @@ def km_sculpt(_params):
|
||||
{"properties": [("mode", 'ROTATION'), ("texmode", 'SECONDARY')]}),
|
||||
# Tools
|
||||
("paint.brush_select", {"type": 'X', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'DRAW')]}),
|
||||
{"properties": [("sculpt_tool", 'DRAW')]}),
|
||||
("paint.brush_select", {"type": 'S', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'SMOOTH')]}),
|
||||
{"properties": [("sculpt_tool", 'SMOOTH')]}),
|
||||
("paint.brush_select", {"type": 'P', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'PINCH')]}),
|
||||
{"properties": [("sculpt_tool", 'PINCH')]}),
|
||||
("paint.brush_select", {"type": 'I', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'INFLATE')]}),
|
||||
{"properties": [("sculpt_tool", 'INFLATE')]}),
|
||||
("paint.brush_select", {"type": 'G', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'GRAB')]}),
|
||||
{"properties": [("sculpt_tool", 'GRAB')]}),
|
||||
("paint.brush_select", {"type": 'L', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'LAYER')]}),
|
||||
{"properties": [("sculpt_tool", 'LAYER')]}),
|
||||
("paint.brush_select", {"type": 'T', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'FLATTEN')]}),
|
||||
{"properties": [("sculpt_tool", 'FLATTEN')]}),
|
||||
("paint.brush_select", {"type": 'C', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'CLAY')]}),
|
||||
{"properties": [("sculpt_tool", 'CLAY')]}),
|
||||
("paint.brush_select", {"type": 'C', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'CREASE')]}),
|
||||
{"properties": [("sculpt_tool", 'CREASE')]}),
|
||||
("paint.brush_select", {"type": 'K', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'SNAKE_HOOK')]}),
|
||||
{"properties": [("sculpt_tool", 'SNAKE_HOOK')]}),
|
||||
("paint.brush_select", {"type": 'M', "value": 'PRESS'},
|
||||
{"properties": [("paint_mode", 'SCULPT'), ("sculpt_tool", 'MASK'), ("toggle", True), ("create_missing", True)]}),
|
||||
{"properties": [("sculpt_tool", 'MASK'), ("toggle", True), ("create_missing", True)]}),
|
||||
# Menus
|
||||
("wm.context_menu_enum", {"type": 'E', "value": 'PRESS'},
|
||||
{"properties": [("data_path", 'tool_settings.sculpt.brush.stroke_method')]}),
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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";
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (paint_mode == PAINT_MODE_INVALID) {
|
||||
paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
if (paint_mode == PAINT_MODE_INVALID) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
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) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
const int tool = RNA_enum_get(op->ptr, op_prop_id);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user