Tool System: use enum for gp sculpt/weight paint
Fixes T57525
This commit is contained in:
parent
3437cd9ac2
commit
b657e9875c
@ -2984,10 +2984,12 @@ def km_grease_pencil_stroke_sculpt_mode(params):
|
||||
# Selection
|
||||
*_grease_pencil_selection(params),
|
||||
# Painting
|
||||
("gpencil.brush_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
||||
{"properties": [("wait_for_input", False)]}),
|
||||
("gpencil.brush_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
|
||||
{"properties": [("wait_for_input", False), ("keep_brush", True)]}),
|
||||
{"properties": [("wait_for_input", False)]}),
|
||||
("gpencil.brush_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("wait_for_input", False), ("keep_brush", True)]}),
|
||||
{"properties": [("wait_for_input", False)]}),
|
||||
# Brush strength
|
||||
("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength')]}),
|
||||
@ -3016,9 +3018,9 @@ def km_grease_pencil_stroke_weight_mode(params):
|
||||
*_grease_pencil_selection(params),
|
||||
# Painting
|
||||
("gpencil.brush_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
|
||||
{"properties": [("wait_for_input", False), ("keep_brush", True)]}),
|
||||
{"properties": [("wait_for_input", False)]}),
|
||||
("gpencil.brush_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("wait_for_input", False), ("keep_brush", True)]}),
|
||||
{"properties": [("wait_for_input", False)]}),
|
||||
# Brush strength
|
||||
("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.weight_brush.strength')]}),
|
||||
|
@ -247,10 +247,10 @@ class GreasePencilStrokeSculptPanel:
|
||||
layout.use_property_decorate = False
|
||||
|
||||
settings = context.tool_settings.gpencil_sculpt
|
||||
tool = settings.tool
|
||||
tool = settings.sculpt_tool
|
||||
brush = settings.brush
|
||||
|
||||
layout.template_icon_view(settings, "tool", show_labels=True)
|
||||
layout.template_icon_view(settings, "sculpt_tool", show_labels=True)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(brush, "size", slider=True)
|
||||
@ -271,7 +271,7 @@ class GreasePencilStrokeSculptPanel:
|
||||
row = layout.row(align=True)
|
||||
row.prop_enum(brush, "direction", value='ADD', text="Pinch")
|
||||
row.prop_enum(brush, "direction", value='SUBTRACT', text="Inflate")
|
||||
elif settings.tool == 'TWIST':
|
||||
elif tool == 'TWIST':
|
||||
row = layout.row(align=True)
|
||||
row.prop_enum(brush, "direction", value='ADD', text="CCW")
|
||||
row.prop_enum(brush, "direction", value='SUBTRACT', text="CW")
|
||||
@ -283,7 +283,7 @@ class GreasePencilSculptOptionsPanel:
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
settings = context.tool_settings.gpencil_sculpt
|
||||
tool = settings.tool
|
||||
tool = settings.sculpt_tool
|
||||
|
||||
return bool(tool in {'SMOOTH', 'RANDOMIZE', 'SMOOTH'})
|
||||
|
||||
@ -294,7 +294,7 @@ class GreasePencilSculptOptionsPanel:
|
||||
layout.use_property_decorate = False
|
||||
|
||||
settings = context.tool_settings.gpencil_sculpt
|
||||
tool = settings.tool
|
||||
tool = settings.sculpt_tool
|
||||
brush = settings.brush
|
||||
|
||||
if tool in {'SMOOTH', 'RANDOMIZE'}:
|
||||
@ -350,7 +350,7 @@ class GreasePencilAppearancePanel:
|
||||
elif ob.mode in {'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}:
|
||||
settings = context.tool_settings.gpencil_sculpt
|
||||
brush = settings.brush
|
||||
tool = settings.tool
|
||||
tool = settings.sculpt_tool
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(brush, "use_cursor", text="Show Brush")
|
||||
@ -361,7 +361,7 @@ class GreasePencilAppearancePanel:
|
||||
elif tool == 'PINCH':
|
||||
col.prop(brush, "cursor_color_add", text="Pinch")
|
||||
col.prop(brush, "cursor_color_sub", text="Inflate")
|
||||
elif settings.tool == 'TWIST':
|
||||
elif tool == 'TWIST':
|
||||
col.prop(brush, "cursor_color_add", text="CCW")
|
||||
col.prop(brush, "cursor_color_sub", text="CW")
|
||||
else:
|
||||
@ -572,7 +572,7 @@ class GPENCIL_MT_pie_sculpt(Menu):
|
||||
# W - Launch Sculpt Mode
|
||||
col = pie.column()
|
||||
# col.label(text="Tool:")
|
||||
col.prop(settings, "tool", text="")
|
||||
col.prop(settings, "sculpt_tool", text="")
|
||||
col.operator("gpencil.brush_paint", text="Sculpt", icon='SCULPTMODE_HLT')
|
||||
|
||||
# E - Common Settings
|
||||
@ -582,7 +582,7 @@ class GPENCIL_MT_pie_sculpt(Menu):
|
||||
row.prop(brush, "strength", slider=True)
|
||||
# row.prop(brush, "use_pressure_strength", text="", icon_only=True)
|
||||
col.prop(brush, "use_falloff")
|
||||
if settings.tool in {'SMOOTH', 'RANDOMIZE'}:
|
||||
if settings.sculpt_tool in {'SMOOTH', 'RANDOMIZE'}:
|
||||
row = col.row(align=True)
|
||||
row.prop(settings, "use_edit_position", text="Position", icon='MESH_DATA', toggle=True)
|
||||
row.prop(settings, "use_edit_strength", text="Strength", icon='COLOR', toggle=True)
|
||||
|
@ -1389,7 +1389,7 @@ class _defs_gpencil_sculpt:
|
||||
if ob and ob.mode == 'GPENCIL_SCULPT':
|
||||
tool_settings = context.tool_settings
|
||||
settings = tool_settings.gpencil_sculpt
|
||||
tool = settings.tool
|
||||
tool = settings.sculpt_tool
|
||||
brush = settings.brush
|
||||
|
||||
layout.prop(brush, "size", slider=True)
|
||||
@ -1402,130 +1402,16 @@ class _defs_gpencil_sculpt:
|
||||
row.separator()
|
||||
row.prop(brush, "direction", expand=True, text="")
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def smooth(*, draw_settings):
|
||||
return dict(
|
||||
text="Smooth",
|
||||
icon="ops.gpencil.sculpt_smooth",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='SMOOTH', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def thickness(*, draw_settings):
|
||||
return dict(
|
||||
text="Thickness",
|
||||
icon="ops.gpencil.sculpt_thickness",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='THICKNESS', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def strength(*, draw_settings):
|
||||
return dict(
|
||||
text="Strength",
|
||||
icon="ops.gpencil.sculpt_strength",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='STRENGTH', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def grab(*, draw_settings):
|
||||
return dict(
|
||||
text="Grab",
|
||||
icon="ops.gpencil.sculpt_grab",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='GRAB', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def push(*, draw_settings):
|
||||
return dict(
|
||||
text="Push",
|
||||
icon="ops.gpencil.sculpt_push",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='PUSH', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def twist(*, draw_settings):
|
||||
return dict(
|
||||
text="Twist",
|
||||
icon="ops.gpencil.sculpt_twist",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='TWIST', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def pinch(*, draw_settings):
|
||||
return dict(
|
||||
text="Pinch",
|
||||
icon="ops.gpencil.sculpt_pinch",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='PINCH', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def randomize(*, draw_settings):
|
||||
return dict(
|
||||
text="Randomize",
|
||||
icon="ops.gpencil.sculpt_randomize",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='RANDOMIZE', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def clone(*, draw_settings):
|
||||
return dict(
|
||||
text="Clone",
|
||||
icon="ops.gpencil.sculpt_clone",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='CLONE', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
@staticmethod
|
||||
def generate_from_brushes(context):
|
||||
return generate_from_enum_ex(
|
||||
context,
|
||||
icon_prefix="ops.gpencil.sculpt_",
|
||||
type=bpy.types.GPencilSculptSettings,
|
||||
attr="sculpt_tool",
|
||||
tooldef_keywords={
|
||||
"draw_settings": _defs_gpencil_sculpt.draw_settings_common,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@ -1543,18 +1429,16 @@ class _defs_gpencil_weight:
|
||||
row.prop(brush, "strength", slider=True)
|
||||
row.prop(brush, "use_pressure_strength", text="")
|
||||
|
||||
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
||||
def paint(*, draw_settings):
|
||||
return dict(
|
||||
text="Draw",
|
||||
icon="ops.gpencil.sculpt_weight",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("gpencil.brush_paint",
|
||||
dict(mode='WEIGHT', wait_for_input=False),
|
||||
dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
@staticmethod
|
||||
def generate_from_brushes(context):
|
||||
return generate_from_enum_ex(
|
||||
context,
|
||||
icon_prefix="ops.gpencil.sculpt_",
|
||||
type=bpy.types.GPencilSculptSettings,
|
||||
attr="weight_tool",
|
||||
tooldef_keywords={
|
||||
"draw_settings": _defs_gpencil_weight.draw_settings_common,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@ -1911,18 +1795,10 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||
'GPENCIL_SCULPT': [
|
||||
*_tools_gpencil_select,
|
||||
None,
|
||||
_defs_gpencil_sculpt.smooth,
|
||||
_defs_gpencil_sculpt.thickness,
|
||||
_defs_gpencil_sculpt.strength,
|
||||
_defs_gpencil_sculpt.grab,
|
||||
_defs_gpencil_sculpt.push,
|
||||
_defs_gpencil_sculpt.twist,
|
||||
_defs_gpencil_sculpt.pinch,
|
||||
_defs_gpencil_sculpt.randomize,
|
||||
_defs_gpencil_sculpt.clone,
|
||||
_defs_gpencil_sculpt.generate_from_brushes,
|
||||
],
|
||||
'GPENCIL_WEIGHT': [
|
||||
_defs_gpencil_weight.paint,
|
||||
_defs_gpencil_weight.generate_from_brushes,
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -1188,18 +1188,10 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
|
||||
|
||||
const bool is_weight_mode = ob->mode == OB_MODE_GPENCIL_WEIGHT;
|
||||
/* set the brush using the tool */
|
||||
#if 0
|
||||
GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
|
||||
eGP_EditBrush_Types mode = RNA_enum_get(op->ptr, "mode");
|
||||
const bool keep_brush = RNA_boolean_get(op->ptr, "keep_brush");
|
||||
|
||||
if (!keep_brush) {
|
||||
if (is_weight_mode) {
|
||||
gset->weighttype = mode;
|
||||
}
|
||||
else {
|
||||
gset->brushtype = mode;
|
||||
}
|
||||
}
|
||||
eGP_EditBrush_Types mode = is_weight_mode ? gset->weighttype : gset->brushtype;
|
||||
#endif
|
||||
tGP_BrushEditData *gso;
|
||||
|
||||
/* setup operator data */
|
||||
@ -2099,22 +2091,6 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
|
||||
/* Operator --------------------------------------------- */
|
||||
static const EnumPropertyItem prop_gpencil_sculpt_brush_items[] = {
|
||||
{GP_EDITBRUSH_TYPE_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth stroke points" },
|
||||
{GP_EDITBRUSH_TYPE_THICKNESS, "THICKNESS", 0, "Thickness", "Adjust thickness of strokes" },
|
||||
{GP_EDITBRUSH_TYPE_STRENGTH, "STRENGTH", 0, "Strength", "Adjust color strength of strokes" },
|
||||
{GP_EDITBRUSH_TYPE_GRAB, "GRAB", 0, "Grab", "Translate the set of points initially within the brush circle" },
|
||||
{GP_EDITBRUSH_TYPE_PUSH, "PUSH", 0, "Push", "Move points out of the way, as if combing them" },
|
||||
{GP_EDITBRUSH_TYPE_TWIST, "TWIST", 0, "Twist", "Rotate points around the midpoint of the brush" },
|
||||
{GP_EDITBRUSH_TYPE_PINCH, "PINCH", 0, "Pinch", "Pull points towards the midpoint of the brush" },
|
||||
{GP_EDITBRUSH_TYPE_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Introduce jitter/randomness into strokes" },
|
||||
{GP_EDITBRUSH_TYPE_CLONE, "CLONE", 0, "Clone", "Paste copies of the strokes stored on the clipboard" },
|
||||
{GP_EDITBRUSH_TYPE_WEIGHT, "WEIGHT", 0, "Weight", "Weight Paint" },
|
||||
{0, NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
void GPENCIL_OT_brush_paint(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
@ -2133,9 +2109,6 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_sculpt_brush_items, 0, "Mode", "Brush mode");
|
||||
RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
@ -2143,10 +2116,4 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
|
||||
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input",
|
||||
"Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_boolean(ot->srna, "keep_brush", false, "Keep Brush",
|
||||
"Keep current brush activated");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
/* ************************************************ */
|
||||
|
@ -127,6 +127,7 @@ extern const EnumPropertyItem rna_enum_brush_image_tool_items[];
|
||||
extern const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[];
|
||||
extern const EnumPropertyItem rna_enum_particle_edit_disconnected_hair_brush_items[];
|
||||
extern const EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[];
|
||||
extern const EnumPropertyItem rna_enum_gpencil_weight_brush_items[];
|
||||
|
||||
extern const EnumPropertyItem rna_enum_uv_sculpt_tool_items[];
|
||||
|
||||
|
@ -78,12 +78,12 @@ const EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[] = {
|
||||
{ 0, NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
#ifndef RNA_RUNTIME
|
||||
static EnumPropertyItem rna_enum_gpencil_weight_brush_items[] = {
|
||||
const EnumPropertyItem rna_enum_gpencil_weight_brush_items[] = {
|
||||
{GP_EDITBRUSH_TYPE_WEIGHT, "WEIGHT", ICON_GPBRUSH_WEIGHT, "Weight", "Weight Paint for Vertex Groups"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
#ifndef RNA_RUNTIME
|
||||
static const EnumPropertyItem rna_enum_gpencil_lock_axis_items[] = {
|
||||
{GP_LOCKAXIS_VIEW, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Align strokes to current view plane"},
|
||||
{GP_LOCKAXIS_Y, "AXIS_Y", ICON_AXIS_FRONT, "Front (X-Z)", "Project strokes to plane locked to Y"},
|
||||
@ -1193,7 +1193,7 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
|
||||
RNA_def_struct_path_func(srna, "rna_GPencilSculptSettings_path");
|
||||
RNA_def_struct_ui_text(srna, "GPencil Sculpt Settings", "Properties for Grease Pencil stroke sculpting tool");
|
||||
|
||||
prop = RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
|
||||
prop = RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "brushtype");
|
||||
RNA_def_property_enum_items(prop, rna_enum_gpencil_sculpt_brush_items);
|
||||
RNA_def_property_ui_text(prop, "Tool", "");
|
||||
|
@ -182,6 +182,9 @@ static void toolsystem_ref_link__refresh_image_uv_sculpt(bContext *C, Scene *sce
|
||||
RNA_property_update(C, &ptr, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* \see #toolsystem_ref_link
|
||||
*/
|
||||
static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref)
|
||||
{
|
||||
bToolRef_Runtime *tref_rt = tref->runtime;
|
||||
@ -200,9 +203,43 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
|
||||
if (tref_rt->data_block[0]) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_PARTICLE))
|
||||
|
||||
if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_GPENCIL_SCULPT))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_gpencil_sculpt_brush_items;
|
||||
const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
|
||||
if (i != -1) {
|
||||
const int value = items[i].value;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
ts->gp_sculpt.brushtype = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_GPENCIL_WEIGHT))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_gpencil_weight_brush_items;
|
||||
const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
|
||||
if (i != -1) {
|
||||
const int value = items[i].value;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
ts->gp_sculpt.weighttype = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_PARTICLE))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items;
|
||||
const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
|
||||
@ -218,8 +255,8 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((tref->space_type == SPACE_IMAGE) &&
|
||||
(tref->mode == SI_MODE_UV))
|
||||
else if ((tref->space_type == SPACE_IMAGE) &&
|
||||
(tref->mode == SI_MODE_UV))
|
||||
{
|
||||
/* Note that switching uv-sculpt boolean is a hack at the moment.
|
||||
* It would be best to make this either an operator or a higher level mode (like mesh-object sculpt mode). */
|
||||
@ -410,6 +447,8 @@ void WM_toolsystem_ref_set_from_runtime(
|
||||
/**
|
||||
* Sync the internal active state of a tool back into the tool system,
|
||||
* this is needed for active brushes where the real active state is not stored in the tool system.
|
||||
*
|
||||
* \see #toolsystem_ref_link
|
||||
*/
|
||||
void WM_toolsystem_ref_sync_from_context(
|
||||
Main *bmain, WorkSpace *workspace, bToolRef *tref)
|
||||
@ -431,6 +470,30 @@ void WM_toolsystem_ref_sync_from_context(
|
||||
if (ob == NULL) {
|
||||
/* pass */
|
||||
}
|
||||
else if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_GPENCIL_SCULPT) &&
|
||||
(ob->mode & OB_MODE_GPENCIL_SCULPT))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_gpencil_sculpt_brush_items;
|
||||
const int i = RNA_enum_from_value(items, ts->gp_sculpt.brushtype);
|
||||
const EnumPropertyItem *item = &items[i];
|
||||
if (!STREQ(tref_rt->data_block, item->identifier)) {
|
||||
STRNCPY(tref_rt->data_block, item->identifier);
|
||||
STRNCPY(tref->idname, item->name);
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_GPENCIL_WEIGHT) &&
|
||||
(ob->mode & OB_MODE_GPENCIL_WEIGHT))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_gpencil_weight_brush_items;
|
||||
const int i = RNA_enum_from_value(items, ts->gp_sculpt.weighttype);
|
||||
const EnumPropertyItem *item = &items[i];
|
||||
if (!STREQ(tref_rt->data_block, item->identifier)) {
|
||||
STRNCPY(tref_rt->data_block, item->identifier);
|
||||
STRNCPY(tref->idname, item->name);
|
||||
}
|
||||
}
|
||||
else if ((tref->space_type == SPACE_VIEW3D) &&
|
||||
(tref->mode == CTX_MODE_PARTICLE) &&
|
||||
(ob->mode & OB_MODE_PARTICLE_EDIT))
|
||||
@ -445,8 +508,7 @@ void WM_toolsystem_ref_sync_from_context(
|
||||
}
|
||||
else if ((tref->space_type == SPACE_IMAGE) &&
|
||||
(tref->mode == SI_MODE_UV) &&
|
||||
(ob->mode &
|
||||
OB_MODE_EDIT))
|
||||
(ob->mode & OB_MODE_EDIT))
|
||||
{
|
||||
const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
|
||||
const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
|
||||
|
Loading…
Reference in New Issue
Block a user