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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-01-17 03:23:00 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-01-17 20:06:11 +0400
commit8b6b42b694322c374f4cc9eebd3760b742826eca (patch)
treebae4917614f2c3e1c02c02e7dc6216a16712fa6c /source/blender/editors/interface
parentac74718e6f525429165664bcf30be5ff8db59581 (diff)
UI: tweak menu padding and make separator line more visible.
Adds some padding to the left of the icon, adds more space around the separator line and make it more visible, and add some spacing at the top and bottom of the menu. Ref T37794 Reviewed By: dingto, billrey Differential Revision: https://developer.blender.org/D223
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c6
-rw-r--r--source/blender/editors/interface/interface_handlers.c15
-rw-r--r--source/blender/editors/interface/interface_layout.c25
-rw-r--r--source/blender/editors/interface/interface_regions.c22
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c10
6 files changed, 57 insertions, 23 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 24924564ab4..ab275c8395b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -214,7 +214,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
uiStyleFontSet(&style->widget);
for (bt = block->buttons.first; bt; bt = bt->next) {
- if (bt->type != SEPR) {
+ if (!ELEM(bt->type, SEPR, SEPRLINE)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
if (j > i) i = j;
@@ -2553,7 +2553,7 @@ void uiBlockEndAlign(uiBlock *block)
int ui_but_can_align(uiBut *but)
{
- return !ELEM4(but->type, LABEL, OPTION, OPTIONN, SEPR);
+ return !ELEM5(but->type, LABEL, OPTION, OPTIONN, SEPR, SEPRLINE);
}
static void ui_block_do_align_but(uiBut *first, short nr)
@@ -2855,7 +2855,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
}
/* keep track of UI_interface.h */
- if (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR)) {}
+ if (ELEM10(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR, SEPRLINE)) {}
else if (but->type >= SEARCH_MENU) {}
else but->flag |= UI_BUT_UNDO;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 2e02e442a66..62e1c4ad60b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -309,7 +309,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
static bool ui_but_editable(uiBut *but)
{
- return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+ return ELEM6(but->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX, PROGRESSBAR);
}
static uiBut *ui_but_prev(uiBut *but)
@@ -2144,7 +2144,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM5(actbut->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX))
return;
for (but = actbut->next; but; but = but->next) {
@@ -2172,7 +2172,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM5(actbut->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX))
return;
for (but = actbut->prev; but; but = but->prev) {
@@ -5218,7 +5218,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
uiBlockSetDirection(block, UI_CENTER);
- layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
@@ -5263,7 +5263,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
uiBlockSetDirection(block, UI_CENTER);
- layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
@@ -5849,6 +5849,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* quiet warnings for unhandled types */
case SEPR:
+ case SEPRLINE:
case BUT_EXTRA:
break;
}
@@ -6003,7 +6004,7 @@ static bool ui_is_but_interactive(const uiBut *but, const bool labeledit)
/* note, LABEL is included for highlights, this allows drags */
if ((but->type == LABEL) && but->dragpoin == NULL)
return false;
- if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
+ if (ELEM4(but->type, ROUNDBOX, SEPR, SEPRLINE, LISTBOX))
return false;
if (but->flag & UI_HIDDEN)
return false;
@@ -7570,7 +7571,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH
for (but = block->buttons.first; but; but = but->next) {
bool doit = false;
- if (!ELEM(but->type, LABEL, SEPR))
+ if (!ELEM3(but->type, LABEL, SEPR, SEPRLINE))
count++;
/* exception for rna layer buts */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index c884235c219..34c124b293e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -83,6 +83,7 @@ typedef struct uiLayoutRoot {
int opcontext;
int emw, emh;
+ int padding;
uiMenuHandleFunc handlefunc;
void *argv;
@@ -1751,9 +1752,11 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
void uiItemS(uiLayout *layout)
{
uiBlock *block = layout->root->block;
+ bool is_menu = ui_block_is_menu(block);
+ int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
uiBlockSetCurLayout(block, layout);
- uiDefBut(block, SEPR, 0, "", 0, 0, 0.3f * UI_UNIT_X, 0.3f * UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, (is_menu) ? SEPRLINE : SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
}
/* level items */
@@ -2851,7 +2854,20 @@ static void ui_layout_free(uiLayout *layout)
MEM_freeN(layout);
}
-uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, uiStyle *style)
+static void ui_layout_add_padding_button(uiLayoutRoot *root)
+{
+ if (root->padding) {
+ /* add an invisible button for padding */
+ uiBlock *block = root->block;
+ uiLayout *prev_layout = block->curlayout;
+
+ block->curlayout = root->layout;
+ uiDefBut(block, SEPR, 0, "", 0, 0, root->padding, root->padding, NULL, 0.0, 0.0, 0, 0, "");
+ block->curlayout = prev_layout;
+ }
+}
+
+uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style)
{
uiLayout *layout;
uiLayoutRoot *root;
@@ -2860,6 +2876,7 @@ uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int siz
root->type = type;
root->style = style;
root->block = block;
+ root->padding = padding;
root->opcontext = WM_OP_INVOKE_REGION_WIN;
layout = MEM_callocN(sizeof(uiLayout), "uiLayout");
@@ -2888,6 +2905,8 @@ uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int siz
block->curlayout = layout;
root->layout = layout;
BLI_addtail(&block->layouts, root);
+
+ ui_layout_add_padding_button(root);
return layout;
}
@@ -2944,6 +2963,8 @@ void uiBlockLayoutResolve(uiBlock *block, int *x, int *y)
block->curlayout = NULL;
for (root = block->layouts.first; root; root = root->next) {
+ ui_layout_add_padding_button(root);
+
/* NULL in advance so we don't interfere when adding button */
ui_layout_end(block, root->layout, x, y);
ui_layout_free(root->layout);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index de295f6e789..c8b07163114 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -74,6 +74,7 @@
#define B_NOP -1
#define MENU_TOP 8
+#define MENU_PADDING (int)(0.2f * UI_UNIT_Y)
/*********************** Menu Data Parsing ********************* */
@@ -1482,13 +1483,13 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
if (dir1 == UI_LEFT) {
xof = butrct.xmin - block->rect.xmax;
- if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center;
- else yof = butrct.ymax - block->rect.ymax + center;
+ if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center - MENU_PADDING;
+ else yof = butrct.ymax - block->rect.ymax + center + MENU_PADDING;
}
else if (dir1 == UI_RIGHT) {
xof = butrct.xmax - block->rect.xmin;
- if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center;
- else yof = butrct.ymax - block->rect.ymax + center;
+ if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center - MENU_PADDING;
+ else yof = butrct.ymax - block->rect.ymax + center + MENU_PADDING;
}
else if (dir1 == UI_TOP) {
yof = butrct.ymax - block->rect.ymin;
@@ -1846,6 +1847,8 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
/* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */
uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
}
+
+ uiItemS(layout);
}
/* create items */
@@ -2442,7 +2445,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
for (bt = block->buttons.first; bt; bt = bt->next)
offset[0] = min_ii(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)));
- offset[1] = 1.5 * UI_UNIT_Y;
+ offset[1] = 2.1 * UI_UNIT_Y;
}
block->minbounds = minwidth;
@@ -2462,7 +2465,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
block->minbounds = minwidth;
- uiTextBoundsBlock(block, 2.5 * UI_UNIT_X);
+ uiTextBoundsBlock(block, 3.0f * UI_UNIT_X);
}
/* if menu slides out of other menu, override direction */
@@ -2481,10 +2484,11 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
uiStyle *style = UI_GetStyleDraw();
uiPopupBlockHandle *handle;
uiPopupMenu *pup;
+
pup = MEM_callocN(sizeof(uiPopupMenu), __func__);
pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_NUMSELECT; /* default menus to numselect */
- pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+ pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, MENU_PADDING, style);
pup->slideout = but ? ui_block_is_menu(but->block) : false;
pup->but = but;
uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
@@ -2549,7 +2553,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
- pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+ pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, MENU_PADDING, style);
/* note, this intentionally differs from the menu & submenu default because many operators
* use popups like this to select one of their options - where having invoke doesn't make sense */
@@ -2570,6 +2574,8 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
but = uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
but->drawflag = UI_BUT_TEXT_LEFT;
}
+
+ uiItemS(pup->layout);
}
return pup;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index a61a2949e73..fe3fb726115 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3485,7 +3485,7 @@ static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v)
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
- layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, UI_GetStyle()), 0);
+ layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_GetStyle()), 0);
uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 0f0ce394403..3d089e5269e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1360,6 +1360,11 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
const bool show_menu_icon = ui_but_draw_menu_icon(but);
const float icon_size = ICON_SIZE_FROM_BUTRECT(rect);
+ /* menu item - add some more padding so menus don't feel cramped. it must
+ * be part of the button so that this area is still clickable */
+ if (but->block && ui_block_is_menu(but->block))
+ rect->xmin += 0.3f * U.widget_unit;
+
widget_draw_icon(but, but->icon + but->iconadd, alpha, rect, show_menu_icon);
rect->xmin += icon_size;
@@ -2356,7 +2361,7 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol)
col[0] = wcol->text[0];
col[1] = wcol->text[1];
col[2] = wcol->text[2];
- col[3] = 7;
+ col[3] = 30;
glEnable(GL_BLEND);
glColor4ubv(col);
@@ -3308,7 +3313,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case LABEL:
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
break;
- case SEPR:
+ case SEPRLINE:
ui_draw_separator(rect, &tui->wcol_menu_item);
break;
default:
@@ -3333,6 +3338,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
case SEPR:
+ case SEPRLINE:
break;
case BUT: