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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-06-09 18:36:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-09 18:38:32 +0300
commit7fdde7fd86f2448700e6473ae4bc5f8b1d4b1208 (patch)
treeb32a5003a4261adb1a291bc01c3a444c8943119b /source
parentec8a20fec0d103a799b9d9c86b0b55fba3b02b84 (diff)
UI: use draw_header function for popover buttons
Add 'is_popover' for panel draw functions to check if they're in a popup. This puts dyntopo toggle next to the popover.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_layout.c34
-rw-r--r--source/blender/makesdna/DNA_screen_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_ui.c5
3 files changed, 31 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 339b333a5fb..73008aa11f6 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2044,12 +2044,23 @@ void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const
name = CTX_IFACE_(pt->translation_context, pt->label);
}
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
+ const bool ok = (pt->poll == NULL) || pt->poll(C, pt);
+ if (ok && (pt->draw_header != NULL)) {
+ layout = uiLayoutRow(layout, true);
+ Panel panel = {
+ .type = pt,
+ .layout = layout,
+ .flag = PNL_POPOVER,
+ };
+ pt->draw_header(C, &panel);
+ }
uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, NULL, NULL, true);
but->type = UI_BTYPE_POPOVER;
- if (pt->poll && (pt->poll(C, pt) == false)) {
+ if (!ok) {
but->flag |= UI_BUT_DISABLED;
}
}
@@ -4236,14 +4247,19 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
}
-static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout)
+static void ui_paneltype_draw_impl(
+ bContext *C, PanelType *pt, uiLayout *layout, bool show_header)
{
Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
panel->type = pt;
- if (pt->draw_header) {
- panel->layout = uiLayoutRow(layout, false);
- pt->draw_header(C, panel);
- panel->layout = NULL;
+ panel->flag = PNL_POPOVER;
+
+ if (show_header) {
+ if (pt->draw_header) {
+ panel->layout = uiLayoutRow(layout, false);
+ pt->draw_header(C, panel);
+ panel->layout = NULL;
+ }
}
panel->layout = layout;
@@ -4261,7 +4277,7 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout)
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);
+ ui_paneltype_draw_impl(C, pt_iter, layout, true);
}
}
} while ((pt_iter = pt_iter->next));
@@ -4276,7 +4292,7 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout)
CTX_store_set(C, layout->context);
}
- ui_paneltype_draw_impl(C, pt, layout);
+ ui_paneltype_draw_impl(C, pt, layout, false);
if (layout->context) {
CTX_store_set(C, NULL);
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 9213893ae66..91bf1bbddbd 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -390,6 +390,7 @@ enum {
/*PNL_TABBED = (1 << 3), */ /*UNUSED*/
PNL_OVERLAP = (1 << 4),
PNL_PIN = (1 << 5),
+ PNL_POPOVER = (1 << 6),
};
/* Panel->snap - for snapping to screen edges */
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index e02421b9270..ebee502515f 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -1132,6 +1132,11 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pin", "");
/* XXX, should only tag region for redraw */
RNA_def_property_update(prop, NC_WINDOW, NULL);
+
+ prop = RNA_def_property(srna, "is_popover", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_POPOVER);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Popover", "");
}
static void rna_def_uilist(BlenderRNA *brna)