Commit: 7fdde7fd86f2448700e6473ae4bc5f8b1d4b1208
Author: Campbell Barton
Date:   Sat Jun 9 17:36:28 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7fdde7fd86f2448700e6473ae4bc5f8b1d4b1208

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.

===================================================================

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/editors/interface/interface_layout.c
M       source/blender/makesdna/DNA_screen_types.h
M       source/blender/makesrna/intern/rna_ui.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index cb9ddd470ce..6b515f63c73 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -883,12 +883,13 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
         return (context.sculpt_object and context.tool_settings.sculpt)
 
     def draw_header(self, context):
+        is_popover = self.is_popover
         layout = self.layout
         layout.operator(
             "sculpt.dynamic_topology_toggle",
             icon='CHECKBOX_HLT' if 
context.sculpt_object.use_dynamic_topology_sculpting else 'CHECKBOX_DEHLT',
             text="",
-            emboss=False,
+            emboss=is_popover,
         )
 
     def draw(self, context):
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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to