Commit: 6d980020ba60859947a912e6870c3050a32ab0fd
Author: Brecht Van Lommel
Date:   Sat May 5 14:47:50 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB6d980020ba60859947a912e6870c3050a32ab0fd

UI: experiment to make popover buttons draw like enum menus.

Looks better for 3D viewport shading, but needs more tweaks to distinguish
it from other button types probably.

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

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/editors/interface/interface.c
M       source/blender/editors/interface/interface_layout.c
M       source/blender/editors/interface/interface_widgets.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index d73fdb2e750..a8108f7e5c3 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -53,8 +53,10 @@ class VIEW3D_HT_header(Header):
 
         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select 
Mode...
         row = layout
-        row.popover(space_type='VIEW_3D', region_type='HEADER', 
panel_type="VIEW3D_PT_shading", text="Shading")
-        row.popover(space_type='VIEW_3D', region_type='HEADER', 
panel_type="VIEW3D_PT_overlay", text="Overlay")
+        shading_type = view.shading.type
+        shading_item = 
bpy.types.View3DShading.bl_rna.properties['type'].enum_items[shading_type]
+        row.popover(space_type='VIEW_3D', region_type='HEADER', 
panel_type="VIEW3D_PT_shading", text=shading_item.name, icon=shading_item.icon)
+        row.popover(space_type='VIEW_3D', region_type='HEADER', 
panel_type="VIEW3D_PT_overlay", text="Overlays", icon='WIRE')
 
         layout.template_header_3D()
 
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 99387a47670..dcd267a90d3 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3200,7 +3200,7 @@ static uiBut *ui_def_but(
                 ELEM(but->type,
                      UI_BTYPE_MENU, UI_BTYPE_TEXT, UI_BTYPE_LABEL,
                      UI_BTYPE_BLOCK, UI_BTYPE_BUT_MENU, UI_BTYPE_SEARCH_MENU,
-                     UI_BTYPE_PROGRESS_BAR))
+                     UI_BTYPE_PROGRESS_BAR, UI_BTYPE_POPOVER))
        {
                but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
        }
diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index 347a45c6d2a..3a8e53d3e90 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1957,7 +1957,7 @@ void uiItemPopoverPanel_ptr(uiLayout *layout, bContext 
*C, PanelType *pt, const
        if (layout->root->type == UI_LAYOUT_MENU && !icon)
                icon = ICON_BLANK1;
 
-       uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, 
pt, NULL, NULL, false);
+       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)) {
                but->flag |= UI_BUT_DISABLED;
diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index 6622ef42a64..7fff9bd74b8 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1295,7 +1295,7 @@ static void widget_draw_icon_ex(
                
                if (but->drawflag & UI_BUT_ICON_LEFT) {
                        /* special case - icon_only pie buttons */
-                       if (ui_block_is_pie_menu(but->block) && but->type != 
UI_BTYPE_MENU && but->str && but->str[0] == '\0')
+                       if (ui_block_is_pie_menu(but->block) && 
!ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == 
'\0')
                                xs = rect->xmin + 2.0f * ofs;
                        else if (but->dt == UI_EMBOSS_NONE || but->type == 
UI_BTYPE_LABEL)
                                xs = rect->xmin + 2.0f * ofs;
@@ -1509,7 +1509,7 @@ float UI_text_clip_middle_ex(
 static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti 
*rect)
 {
        /* No margin for labels! */
-       const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU) ? 0 : 
(int)(UI_TEXT_CLIP_MARGIN + 0.5f);
+       const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, 
UI_BTYPE_POPOVER) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
        const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
        const size_t max_len = sizeof(but->drawstr);
        const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 
2.0f;
@@ -1525,7 +1525,7 @@ static void ui_text_clip_middle(uiFontStyle *fstyle, 
uiBut *but, const rcti *rec
 static void ui_text_clip_middle_protect_right(uiFontStyle *fstyle, uiBut *but, 
const rcti *rect, const char rsep)
 {
        /* No margin for labels! */
-       const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU) ? 0 : 
(int)(UI_TEXT_CLIP_MARGIN + 0.5f);
+       const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU, 
UI_BTYPE_POPOVER) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
        const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0);
        const size_t max_len = sizeof(but->drawstr);
        const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 
2.0f;
@@ -1966,7 +1966,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, 
uiWidgetColors *wcol, uiB
        ui_but_text_password_hide(password_str, but, false);
 
        /* check for button text label */
-       if (but->type == UI_BTYPE_MENU && (but->flag & UI_BUT_NODE_LINK)) {
+       if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & 
UI_BUT_NODE_LINK)) {
                rcti temp = *rect;
                temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
                widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false);
@@ -4451,6 +4451,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle 
*style, uiBut *but, rct
                                
                        case UI_BTYPE_MENU:
                        case UI_BTYPE_BLOCK:
+                       case UI_BTYPE_POPOVER:
                                if (but->flag & UI_BUT_NODE_LINK) {
                                        /* new node-link button, not active yet 
XXX */
                                        wt = 
widget_type(UI_WTYPE_MENU_NODE_LINK);
@@ -4473,10 +4474,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle 
*style, uiBut *but, rct
                                }
                                break;
 
-                       case UI_BTYPE_POPOVER:
-                               wt = widget_type(UI_WTYPE_PULLDOWN);
-                               break;
-
                        case UI_BTYPE_PULLDOWN:
                                wt = widget_type(UI_WTYPE_PULLDOWN);
                                break;

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

Reply via email to