UI: support operator enums in Quick Favorites #107616

Merged
Philipp Oeser merged 5 commits from lichtwerk/blender:59244 into main 2023-05-08 09:14:52 +02:00
4 changed files with 3 additions and 6 deletions
Showing only changes of commit 15593ab0d5 - Show all commits

View File

@ -2896,7 +2896,6 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
const char *propname,
const char *name,
int icon,
wmOperatorCallContext *opcontext,
struct PointerRNA *r_opptr);

Doc-string should note this is optional (use the layout's when NULL). Realize doc-strings in wide use here, but it's the kind of thing that's useful to include.

Doc-string should note this is optional (use the layout's when NULL). _Realize doc-strings in wide use here, but it's the kind of thing that's useful to include._

removed this completely, seems the roots opcontext is already fine here?

removed this completely, seems the roots opcontext is already fine here?
void uiItemMenuEnumFullO(uiLayout *layout,
const struct bContext *C,

View File

@ -3555,7 +3555,6 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
const char *propname,
const char *name,
int icon,
wmOperatorCallContext *opcontext,
PointerRNA *r_opptr)

This is awkward, it's using a pointer, for an enum, for the purpose of being able to set it to NULL and use the layout's value.

It's more straightforward to set the context temporarily in layout->root->opcontext using accessor functions as is done in Python. While setting temporary values isn't so nice - this is only done from screen_user_menu_draw and avoids an additional non-obvious argument everywhere else.

This is awkward, it's using a pointer, for an enum, for the purpose of being able to set it to NULL and use the layout's value. It's more straightforward to set the context temporarily in ` layout->root->opcontext` using accessor functions as is done in Python. While setting temporary values isn't so nice - this is only done from `screen_user_menu_draw` and avoids an additional non-obvious argument everywhere else.

see above

see above
{
/* Caller must check */
@ -3572,7 +3571,7 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
MenuItemLevel *lvl = MEM_cnew<MenuItemLevel>("MenuItemLevel");
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
lvl->opcontext = opcontext ? *opcontext : layout->root->opcontext;
lvl->opcontext = layout->root->opcontext;
uiBut *but = ui_item_menu(
layout, name, icon, menu_item_enum_opname_menu, nullptr, lvl, nullptr, true);
@ -3615,7 +3614,7 @@ void uiItemMenuEnumFullO(uiLayout *layout,
return;
}
uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, nullptr, r_opptr);
uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, r_opptr);
}
void uiItemMenuEnumO(uiLayout *layout,

View File

@ -242,7 +242,6 @@ static void screen_user_menu_draw(const bContext *C_const, Menu *menu)
umi_op->op_prop_enum,
CTX_IFACE_(ot->translation_context, ui_name),
ICON_NONE,
&umi_op->opcontext,
NULL);
}
is_empty = false;

View File

@ -393,7 +393,7 @@ static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
PointerRNA opptr;
uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, NULL, &opptr);
uiItemMenuEnumFullO_ptr(layout, C, ot, propname, name, icon, &opptr);
return opptr;
}