Fix T83696: Add Additional menu to Effects panel
This adds the missing options for the effects as it is done in modifiers. Reviewed By: HooglyBoogly Maniphest Tasks: T83696 Differential Revision: https://developer.blender.org/D9838
This commit is contained in:
parent
8f3a401975
commit
6327771bc9
Notes:
blender-bot
2023-02-14 02:58:19 +01:00
Referenced by issue #83696, Add Additional options menu to Effects panel
|
@ -755,6 +755,7 @@ def km_property_editor(_params):
|
|||
# ShaderFX panels
|
||||
("object.shaderfx_remove", {"type": 'X', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("object.shaderfx_remove", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("object.shaderfx_copy", {"type": 'D', "value": 'PRESS', "shift": True}, None),
|
||||
# Constraint panels
|
||||
("constraint.delete", {"type": 'X', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("constraint.delete", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
|
|
|
@ -461,6 +461,7 @@ def km_property_editor(params):
|
|||
# ShaderFX panels
|
||||
("object.shaderfx_remove", {"type": 'BACK_SPACE', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("object.shaderfx_remove", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("objectshaderfx_copy", {"type": 'D', "value": 'PRESS', "ctrl": True}, None),
|
||||
# Constraint panels
|
||||
("constraint.delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
("constraint.delete", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}),
|
||||
|
|
|
@ -206,6 +206,7 @@ void OBJECT_OT_gpencil_modifier_copy(struct wmOperatorType *ot);
|
|||
|
||||
/* object_shader_fx.c */
|
||||
void OBJECT_OT_shaderfx_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shaderfx_copy(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shaderfx_remove(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shaderfx_move_up(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shaderfx_move_down(struct wmOperatorType *ot);
|
||||
|
|
|
@ -166,6 +166,7 @@ void ED_operatortypes_object(void)
|
|||
WM_operatortype_append(OBJECT_OT_shaderfx_move_up);
|
||||
WM_operatortype_append(OBJECT_OT_shaderfx_move_down);
|
||||
WM_operatortype_append(OBJECT_OT_shaderfx_move_to_index);
|
||||
WM_operatortype_append(OBJECT_OT_shaderfx_copy);
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_correctivesmooth_bind);
|
||||
WM_operatortype_append(OBJECT_OT_meshdeform_bind);
|
||||
|
|
|
@ -640,3 +640,57 @@ void OBJECT_OT_shaderfx_move_to_index(wmOperatorType *ot)
|
|||
RNA_def_int(
|
||||
ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the effect to", 0, INT_MAX);
|
||||
}
|
||||
|
||||
/************************ copy shader operator *********************/
|
||||
|
||||
static int shaderfx_copy_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_active_context(C);
|
||||
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
|
||||
|
||||
ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
|
||||
if (!nfx) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name));
|
||||
/* Make sure effect data has unique name. */
|
||||
BKE_shaderfx_unique_name(&ob->shader_fx, nfx);
|
||||
|
||||
BKE_shaderfx_copydata(fx, nfx);
|
||||
BLI_insertlinkafter(&ob->shader_fx, fx, nfx);
|
||||
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int shaderfx_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int retval;
|
||||
if (edit_shaderfx_invoke_properties(C, op, event, &retval)) {
|
||||
return shaderfx_copy_exec(C, op);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static bool shaderfx_copy_poll(bContext *C)
|
||||
{
|
||||
return edit_shaderfx_poll_generic(C, &RNA_ShaderFx, 0);
|
||||
}
|
||||
|
||||
void OBJECT_OT_shaderfx_copy(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Copy Effect";
|
||||
ot->description = "Duplicate effect at the same position in the stack";
|
||||
ot->idname = "OBJECT_OT_shaderfx_copy";
|
||||
|
||||
ot->invoke = shaderfx_copy_invoke;
|
||||
ot->exec = shaderfx_copy_exec;
|
||||
ot->poll = shaderfx_copy_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
||||
edit_shaderfx_properties(ot);
|
||||
}
|
||||
|
|
|
@ -124,6 +124,59 @@ PointerRNA *shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_
|
|||
|
||||
#define ERROR_LIBDATA_MESSAGE TIP_("External library data")
|
||||
|
||||
static void gpencil_shaderfx_ops_extra_draw(bContext *C, uiLayout *layout, void *fx_v)
|
||||
{
|
||||
PointerRNA op_ptr;
|
||||
uiLayout *row;
|
||||
ShaderFxData *fx = (ShaderFxData *)fx_v;
|
||||
|
||||
PointerRNA ptr;
|
||||
Object *ob = ED_object_active_context(C);
|
||||
RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, &ptr);
|
||||
uiLayoutSetContextPointer(layout, "shaderfx", &ptr);
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
|
||||
|
||||
uiLayoutSetUnitsX(layout, 4.0f);
|
||||
|
||||
/* Duplicate. */
|
||||
uiItemO(layout,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"),
|
||||
ICON_DUPLICATE,
|
||||
"OBJECT_OT_shaderfx_copy");
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
/* Move to first. */
|
||||
row = uiLayoutColumn(layout, false);
|
||||
uiItemFullO(row,
|
||||
"OBJECT_OT_shaderfx_move_to_index",
|
||||
IFACE_("Move to First"),
|
||||
ICON_TRIA_UP,
|
||||
NULL,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
RNA_int_set(&op_ptr, "index", 0);
|
||||
if (!fx->prev) {
|
||||
uiLayoutSetEnabled(row, false);
|
||||
}
|
||||
|
||||
/* Move to last. */
|
||||
row = uiLayoutColumn(layout, false);
|
||||
uiItemFullO(row,
|
||||
"OBJECT_OT_shaderfx_move_to_index",
|
||||
IFACE_("Move to Last"),
|
||||
ICON_TRIA_DOWN,
|
||||
NULL,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
RNA_int_set(&op_ptr, "index", BLI_listbase_count(&ob->shader_fx) - 1);
|
||||
if (!fx->next) {
|
||||
uiLayoutSetEnabled(row, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void shaderfx_panel_header(const bContext *UNUSED(C), Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -159,6 +212,9 @@ static void shaderfx_panel_header(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(row, ptr, "show_viewport", 0, "", ICON_NONE);
|
||||
uiItemR(row, ptr, "show_render", 0, "", ICON_NONE);
|
||||
|
||||
/* Extra operators. */
|
||||
uiItemMenuF(row, "", ICON_DOWNARROW_HLT, gpencil_shaderfx_ops_extra_draw, fx);
|
||||
|
||||
row = uiLayoutRow(row, false);
|
||||
uiLayoutSetEmboss(row, UI_EMBOSS_NONE);
|
||||
uiItemO(row, "", ICON_X, "OBJECT_OT_shaderfx_remove");
|
||||
|
|
Loading…
Reference in New Issue