[Bf-blender-cvs] [8b6b42b] master: UI: tweak menu padding and make separator line more visible.

Brecht Van Lommel noreply at git.blender.org
Fri Jan 17 17:06:53 CET 2014


Commit: 8b6b42b694322c374f4cc9eebd3760b742826eca
Author: Brecht Van Lommel
Date:   Fri Jan 17 00:23:00 2014 +0100
https://developer.blender.org/rB8b6b42b694322c374f4cc9eebd3760b742826eca

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

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_logic/logic_window.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d3b8229..3a48e94 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -270,6 +270,7 @@ typedef enum {
 	PROGRESSBAR   = (51 << 9),
 	SEARCH_MENU_UNLINK   = (52 << 9),
 	NODESOCKET    = (53 << 9),
+	SEPRLINE      = (54 << 9),
 } eButType;
 
 #define BUTTYPE     (63 << 9)
@@ -771,7 +772,7 @@ enum {
 /* not apart of the corner flags but mixed in some functions  */
 #define UI_RB_ALPHA (UI_CNR_ALL + 1)
 
-uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
+uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, struct uiStyle *style);
 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
 void uiBlockLayoutResolve(uiBlock *block, int *x, int *y);
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 2492456..ab275c8 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 2e02e44..62e1c4a 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 c884235..34c124b 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 de295f6..c8b0716 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 =

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list