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.
This commit is contained in:
parent
b365cc017a
commit
6d980020ba
@ -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()
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user