diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-09 15:21:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-09 15:21:39 +0300 |
commit | 09ce794dc8c6cf5e406532651576e6b86dfd9232 (patch) | |
tree | 24c079d0bec3e2dacb583011340d6093df142346 /source/blender | |
parent | 8f40af6dcd2fe46bebaa535ab32fb0403c1a4281 (diff) |
UI: initial support for parent panels in popovers
Currently this just includes the panels, no support for collapsing yet.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b3bd98c7b94..b4677d95361 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2075,10 +2075,12 @@ void uiItemPopoverPanelFromGroup( for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) { /* Causes too many panels, check context. */ - if (/* (*context == '\0') || */ STREQ(pt->context, context)) { - if ((*category == '\0') || STREQ(pt->category, category)) { - if (pt->poll == NULL || pt->poll(C, pt)) { - uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE); + if (pt->parent_id[0] == '\0') { + if (/* (*context == '\0') || */ STREQ(pt->context, context)) { + if ((*category == '\0') || STREQ(pt->category, category)) { + if (pt->poll == NULL || pt->poll(C, pt)) { + uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE); + } } } } @@ -3828,18 +3830,11 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout) } } -/** - * Used for popup panels only. - */ -void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) + +static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout) { Panel *panel = MEM_callocN(sizeof(Panel), "popover panel"); panel->type = pt; - - if (layout->context) { - CTX_store_set(C, layout->context); - } - if (pt->draw_header) { panel->layout = uiLayoutRow(layout, false); pt->draw_header(C, panel); @@ -3850,9 +3845,36 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) pt->draw(C, panel); panel->layout = NULL; + MEM_freeN(panel); + + PanelType *pt_iter = pt; + while (pt_iter->prev) { + pt_iter = pt_iter->prev; + } + do { + if (pt_iter != pt && STREQ(pt_iter->parent_id, pt->idname)) { + if (pt_iter->poll == NULL || pt_iter->poll(C, pt_iter)) { + uiItemS(layout); + uiItemL(layout, pt_iter->label, ICON_NONE); + ui_paneltype_draw_impl(C, pt_iter, layout); + } + } + } while ((pt_iter = pt_iter->next)); +} + +/** + * Used for popup panels only. + */ +void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) +{ + if (layout->context) { + CTX_store_set(C, layout->context); + } + + ui_paneltype_draw_impl(C, pt, layout); + if (layout->context) { CTX_store_set(C, NULL); } - MEM_freeN(panel); } |