UI: add method to draw menu contents
This supports expanding menu contents into an existing layout. Needed to fix T58937.
This commit is contained in:
@@ -1190,6 +1190,7 @@ void uiItemsFullEnumO_items(
|
||||
void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
|
||||
void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */
|
||||
void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon); /* menu */
|
||||
void uiItemMContents(uiLayout *layout, const char *menuname); /* menu contents */
|
||||
void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
|
||||
void uiItemS(uiLayout *layout); /* separator */
|
||||
void uiItemS_ex(uiLayout *layout, float factor);
|
||||
|
||||
@@ -2263,10 +2263,7 @@ static uiBut *ui_item_menu(
|
||||
|
||||
void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
|
||||
{
|
||||
MenuType *mt;
|
||||
|
||||
mt = WM_menutype_find(menuname, false);
|
||||
|
||||
MenuType *mt = WM_menutype_find(menuname, false);
|
||||
if (mt == NULL) {
|
||||
RNA_warning("not found %s", menuname);
|
||||
return;
|
||||
@@ -2284,6 +2281,19 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
|
||||
mt->description ? TIP_(mt->description) : "", false);
|
||||
}
|
||||
|
||||
void uiItemMContents(uiLayout *layout, const char *menuname)
|
||||
{
|
||||
MenuType *mt = WM_menutype_find(menuname, false);
|
||||
if (mt == NULL) {
|
||||
RNA_warning("not found %s", menuname);
|
||||
return;
|
||||
}
|
||||
|
||||
uiBlock *block = layout->root->block;
|
||||
bContext *C = block->evil_C;
|
||||
UI_menutype_draw(C, mt, layout);
|
||||
}
|
||||
|
||||
/* popover */
|
||||
void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const char *name, int icon)
|
||||
{
|
||||
|
||||
@@ -294,6 +294,12 @@ static void rna_uiItemM(
|
||||
uiItemM(layout, menuname, name, icon);
|
||||
}
|
||||
|
||||
static void rna_uiItemM_contents(
|
||||
uiLayout *layout, const char *menuname)
|
||||
{
|
||||
uiItemMContents(layout, menuname);
|
||||
}
|
||||
|
||||
static void rna_uiItemPopoverPanel(
|
||||
uiLayout *layout, bContext *C,
|
||||
const char *panel_type, const char *name, const char *text_ctxt,
|
||||
@@ -741,6 +747,10 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
|
||||
|
||||
func = RNA_def_function(srna, "menu_contents", "rna_uiItemM_contents");
|
||||
parm = RNA_def_string(func, "menu", NULL, 0, "", "Identifier of the menu");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
parm = RNA_def_string(func, "panel", NULL, 0, "", "Identifier of the panel");
|
||||
|
||||
Reference in New Issue
Block a user