UI: support operator enums in Quick Favorites #107616
|
@ -2896,7 +2896,6 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
|
|||
const char *propname,
|
||||
const char *name,
|
||||
int icon,
|
||||
wmOperatorCallContext *opcontext,
|
||||
struct PointerRNA *r_opptr);
|
||||
|
||||
void uiItemMenuEnumFullO(uiLayout *layout,
|
||||
const struct bContext *C,
|
||||
|
|
|
@ -3555,7 +3555,6 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
|
|||
const char *propname,
|
||||
const char *name,
|
||||
int icon,
|
||||
wmOperatorCallContext *opcontext,
|
||||
PointerRNA *r_opptr)
|
||||
Campbell Barton
commented
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 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.
Philipp Oeser
commented
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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
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?