Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-12-20 03:33:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-12-20 03:33:08 +0300
commit756be8f4d8ff2ba3915b67c36c2e40f1652397da (patch)
tree7bc894c0303bdf64eccd21fef8a0211e1ac9b350 /source/blender
parenta91886e76ebd16afe07564713f73c340c940125e (diff)
UI: add method to draw menu contents
This supports expanding menu contents into an existing layout. Needed to fix T58937.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface_layout.c18
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c10
3 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index bb45fbd4615..80ac5e72868 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -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);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 9e9c244cfaf..afcbcbbdf52 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -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)
{
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 4d361920dcb..fdf2b5f311b 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -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");