Brush Assets: Switch to a single "Brush" active tool #117491
|
@ -1383,17 +1383,23 @@ class _defs_particle:
|
|||
class _defs_sculpt:
|
||||
|
||||
@staticmethod
|
||||
def generate_from_brushes(context):
|
||||
return generate_from_enum_ex(
|
||||
context,
|
||||
idname_prefix="builtin_brush.",
|
||||
icon_prefix="brush.sculpt.",
|
||||
type=bpy.types.Brush,
|
||||
attr="sculpt_tool",
|
||||
# TODO(@ideasman42): we may want to enable this,
|
||||
# it causes awkward grouping with 2x column button layout.
|
||||
use_separators=False,
|
||||
)
|
||||
def generate_brush_tool(context):
|
||||
if not context:
|
||||
return ()
|
||||
brush = context.tool_settings.sculpt.brush
|
||||
if not brush:
|
||||
return ()
|
||||
tool = brush.sculpt_tool
|
||||
return [
|
||||
ToolDef.from_dict(
|
||||
dict(
|
||||
idname="builtin.brush",
|
||||
label=brush.name,
|
||||
icon="brush.sculpt.paint",
|
||||
data_block=tool
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
@ToolDef.from_fn
|
||||
def hide_border():
|
||||
|
@ -2442,18 +2448,23 @@ class _defs_gpencil_weight:
|
|||
class _defs_curves_sculpt:
|
||||
|
||||
@staticmethod
|
||||
def generate_from_brushes(context):
|
||||
return generate_from_enum_ex(
|
||||
context,
|
||||
idname_prefix="builtin_brush.",
|
||||
icon_prefix="ops.curves.sculpt_",
|
||||
type=bpy.types.Brush,
|
||||
attr="curves_sculpt_tool",
|
||||
icon_map={
|
||||
# Use the generic icon for selection painting.
|
||||
"ops.curves.sculpt_selection_paint": "ops.generic.select_paint",
|
||||
},
|
||||
)
|
||||
def generate_brush_tool(context):
|
||||
if not context:
|
||||
return ()
|
||||
brush = context.tool_settings.curves_sculpt.brush
|
||||
if not brush:
|
||||
return ()
|
||||
tool = brush.curves_sculpt_tool
|
||||
return [
|
||||
ToolDef.from_dict(
|
||||
dict(
|
||||
idname="builtin.brush",
|
||||
label=brush.name,
|
||||
icon="brush.sculpt.paint",
|
||||
data_block=tool
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class _defs_gpencil_vertex:
|
||||
|
@ -3089,7 +3100,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|||
_defs_particle.generate_from_brushes,
|
||||
],
|
||||
'SCULPT': [
|
||||
_defs_sculpt.generate_from_brushes,
|
||||
lambda context: (
|
||||
_defs_sculpt.generate_brush_tool(context)
|
||||
),
|
||||
None,
|
||||
(
|
||||
_defs_sculpt.mask_border,
|
||||
|
@ -3234,7 +3247,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|||
),
|
||||
],
|
||||
'SCULPT_CURVES': [
|
||||
_defs_curves_sculpt.generate_from_brushes,
|
||||
lambda context: (
|
||||
_defs_curves_sculpt.generate_brush_tool(context)
|
||||
),
|
||||
None,
|
||||
*_tools_annotate,
|
||||
],
|
||||
|
|
|
@ -1188,6 +1188,7 @@ static int brush_asset_select_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, nullptr);
|
||||
WM_toolsystem_ref_set_by_id(C, "builtin.brush");
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -849,36 +849,6 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/** The name of the active tool is "builtin_brush." concatenated with the returned string. */
|
||||
static blender::StringRefNull curves_active_tool_name_get(const eBrushCurvesSculptTool tool)
|
||||
{
|
||||
switch (tool) {
|
||||
case CURVES_SCULPT_TOOL_COMB:
|
||||
return "comb";
|
||||
case CURVES_SCULPT_TOOL_DELETE:
|
||||
return "delete";
|
||||
case CURVES_SCULPT_TOOL_SNAKE_HOOK:
|
||||
return "snake_hook";
|
||||
case CURVES_SCULPT_TOOL_ADD:
|
||||
return "add";
|
||||
case CURVES_SCULPT_TOOL_GROW_SHRINK:
|
||||
return "grow_shrink";
|
||||
case CURVES_SCULPT_TOOL_SELECTION_PAINT:
|
||||
return "selection_paint";
|
||||
case CURVES_SCULPT_TOOL_PINCH:
|
||||
return "pinch";
|
||||
case CURVES_SCULPT_TOOL_SMOOTH:
|
||||
return "smooth";
|
||||
case CURVES_SCULPT_TOOL_PUFF:
|
||||
return "puff";
|
||||
case CURVES_SCULPT_TOOL_DENSITY:
|
||||
return "density";
|
||||
case CURVES_SCULPT_TOOL_SLIDE:
|
||||
return "slide";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static bool brush_generic_tool_set(bContext *C,
|
||||
Main *bmain,
|
||||
Paint *paint,
|
||||
|
@ -910,26 +880,7 @@ static bool brush_generic_tool_set(bContext *C,
|
|||
BKE_paint_invalidate_overlay_all();
|
||||
|
||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
|
||||
|
||||
/* Tool System
|
||||
* This is needed for when there is a non-sculpt tool active (transform for e.g.).
|
||||
* In case we are toggling (and the brush changed to the toggle_brush), we need to get the
|
||||
* tool_name again. */
|
||||
int tool_result = brush_tool(brush, paint->runtime.tool_offset);
|
||||
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
||||
}
|
||||
else {
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
RNA_enum_name_from_value(items, tool_result, &tool_name);
|
||||
}
|
||||
|
||||
char tool_id[MAX_NAME];
|
||||
SNPRINTF(tool_id, "builtin_brush.%s", tool_name);
|
||||
WM_toolsystem_ref_set_by_id(C, tool_id);
|
||||
|
||||
WM_toolsystem_ref_set_by_id(C, "builtin.brush");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -976,14 +927,6 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
||||
}
|
||||
else {
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
RNA_enum_name_from_value(items, tool, &tool_name);
|
||||
}
|
||||
|
||||
if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -713,6 +713,7 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
|
|||
switch (tkey->mode) {
|
||||
/* Use the names of the enums for each brush tool. */
|
||||
case CTX_MODE_SCULPT:
|
||||
return "builtin.brush";
|
||||
case CTX_MODE_PAINT_VERTEX:
|
||||
case CTX_MODE_PAINT_WEIGHT:
|
||||
case CTX_MODE_PAINT_TEXTURE:
|
||||
|
@ -726,7 +727,7 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
|
|||
case CTX_MODE_VERTEX_GPENCIL_LEGACY:
|
||||
return "builtin_brush.Draw";
|
||||
case CTX_MODE_SCULPT_CURVES:
|
||||
return "builtin_brush.Density";
|
||||
return "builtin.brush";
|
||||
/* end temporary hack. */
|
||||
|
||||
case CTX_MODE_PARTICLE:
|
||||
|
|
Loading…
Reference in New Issue