[Bf-blender-cvs] [f3f65f3] UI-experiments UI-graphical-redesign: A first Menu/Popup redesign

Julian Eisel noreply at git.blender.org
Fri Jun 5 22:56:04 CEST 2015


Commit: f3f65f38b7a6501eee9b1a1bdba9df05c7157806
Author: Julian Eisel
Date:   Fri Jun 5 22:54:18 2015 +0200
Branches: UI-experiments UI-graphical-redesign
https://developer.blender.org/rBf3f65f38b7a6501eee9b1a1bdba9df05c7157806

A first Menu/Popup redesign

Based on this mockup by @venomgfx: http://wiki.blender.org/index.php/
User:Venomgfx/User_Interface#Menu_Item_.26_Menu_Back

Main changes:
* Draw background for menu title in a different color (currently
hardcoded darker) instead of using a separation line
* Align submenu triangle icons vertically and add some extra space for
them so that they are not squashed in to the line (means shortcut text
is now always vertically aligned as well)
* More modern submenu triangle icon drawing
* Draw separation lines a bit more visible
* Don't add extra icon padding if the menu doesn't contain any icons
(text in menus often used to have some padding on the left so that the
text is nicely aligned even when some entries had icons in front of it.
This is all fine but wasn't needed/looked weird if there isn't any menu
entry with an icon at all - e.g. 3D View "Select" menu, most of the RMB-
menus)
* Cleanup

Screenshots:
* https://developer.blender.org/F185706
* https://developer.blender.org/F185707
* https://developer.blender.org/F185708

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/armature/pose_group.c
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_intern.h
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_nla/nla_edit.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4bbd3cc..fadb476 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1341,7 +1341,8 @@ class VIEW3D_MT_object_specials(Menu):
                     props.input_scale = 0.05
                     props.header_text = "Clip End: %.2f"
 
-        layout.separator()
+        if obj.type in {'CAMERA', 'CURVE', 'FONT', 'EMPTY', 'LAMP'}:
+            layout.separator()
 
         props = layout.operator("object.isolate_type_render")
         props = layout.operator("object.hide_render_clear_all")
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 4d9df06..465fda7 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -164,7 +164,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
 		 */
 		if (strstr(op->idname, "assign")) {
 			uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0);
-			uiItemS(layout);
+			if (!BLI_listbase_is_empty(&pose->agroups)) {
+				uiItemS(layout);
+			}
 		}
 		
 		/* add entries for each group */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 8409022..0dc513b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -133,8 +133,9 @@ enum {
 
 /* block->flag bits 14-17 are identical to but->drawflag bits */
 
-#define UI_BLOCK_LIST_ITEM   (1 << 19)
-#define UI_BLOCK_RADIAL      (1 << 20)
+#define UI_BLOCK_LIST_ITEM      (1 << 19)
+#define UI_BLOCK_RADIAL         (1 << 20)
+#define UI_BLOCK_HAS_SUBMENU    (1 << 21)  /* the block has at least one button leading to a submenu */
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL     (1 << 0)   /* cancel all menus cascading */
@@ -179,6 +180,7 @@ enum {
 	UI_BUT_TIP_FORCE       = (1 << 28),  /* force show tooltips when holding option/alt if U's USER_TOOLTIPS is off */
 	UI_BUT_TEXTEDIT_UPDATE = (1 << 29),  /* when widget is in textedit mode, update value on each char stroke */
 	UI_BUT_SEARCH_UNLINK   = (1 << 30),  /* show unlink for search button */
+	UI_BUT_MENU_TITLE      = (1 << 31),  /* title of a menu - XXX maybe new BTYPE? */
 };
 
 #define UI_PANEL_WIDTH          340
@@ -632,6 +634,7 @@ int UI_icon_from_report_type(int type);
 
 uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
 uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip);
+uiBut *uiDefMenuTitleBut(uiBlock *block, const char *str);
 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip);
 uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip);
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 956f17c..c389642 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2235,6 +2235,12 @@ static void ui_but_string_set_internal(uiBut *but, const char *str, size_t str_l
 	memcpy(but->str, str, str_len);
 }
 
+static void ui_but_submenu_enable(uiBlock *block, uiBut *but)
+{
+	but->flag |= UI_BUT_ICON_SUBMENU;
+	block->flag |= UI_BLOCK_HAS_SUBMENU;
+}
+
 static void ui_but_string_free_internal(uiBut *but)
 {
 	if (but->str) {
@@ -3313,9 +3319,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
 		rows++;
 
 	/* Title */
-	uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_property_ui_name(but->rnaprop),
-	         0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
-	uiItemS(layout);
+	uiDefMenuTitleBut(block, RNA_property_ui_name(but->rnaprop));
 
 	/* note, item_array[...] is reversed on access */
 
@@ -3521,7 +3525,7 @@ static uiBut *ui_def_but_rna(
 	}
 	
 	if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) {
-		but->flag |= UI_BUT_ICON_SUBMENU;
+		ui_but_submenu_enable(block, but);
 	}
 
 	if (!RNA_property_editable(&but->rnapoin, prop)) {
@@ -4228,6 +4232,17 @@ uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char
 	return but;
 }
 
+uiBut *uiDefMenuTitleBut(uiBlock *block, const char *str)
+{
+	uiBut *but = ui_def_but(block, UI_BTYPE_LABEL, 0, str, 0, 0, UI_MENU_TITLE_WIDTH, UI_MENU_TITLE_HEIGHT,
+	                        NULL, 0.0, 0.0, 0.0, 0.0, "");
+	but->flag |= UI_BUT_MENU_TITLE;
+
+	ui_but_update(but);
+
+	return but;
+}
+
 uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip)
 {
 	uiBut *but = ui_def_but(block, UI_BTYPE_PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);
@@ -4235,7 +4250,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in
 	ui_def_but_icon(but, icon, UI_HAS_ICON);
 
 	but->drawflag |= UI_BUT_ICON_LEFT;
-	but->flag |= UI_BUT_ICON_SUBMENU;
+	ui_but_submenu_enable(block, but);
 
 	but->menu_create_func = func;
 	ui_but_update(but);
@@ -4267,7 +4282,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
 		but->drawflag |= UI_BUT_ICON_LEFT;
 	}
 	but->flag |= UI_HAS_ICON;
-	but->flag |= UI_BUT_ICON_SUBMENU;
+	ui_but_submenu_enable(block, but);
 
 	but->block_create_func = func;
 	ui_but_update(but);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a6cdd58..f173df8 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6453,6 +6453,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 	uiPopupMenu *pup;
 	uiLayout *layout;
 	bool is_array, is_array_component;
+	bool is_first_item = true; /* will the next added item be the first menu entry? */
 	uiStringInfo label = {BUT_GET_LABEL, NULL};
 
 /*	if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/
@@ -6475,6 +6476,9 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 
 	uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
 
+	/* adds a separator if it wouldn't be the first item (after title) */
+#define ADD_SEPARATOR_CONDITIONAL if (is_first_item == false) uiItemS(layout);
+
 	if (but->rnapoin.data && but->rnaprop) {
 		PointerRNA *ptr = &but->rnapoin;
 		PropertyRNA *prop = but->rnaprop;
@@ -6514,7 +6518,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 			/* keyframe settings */
 			uiItemS(layout);
 			
-			
+			is_first_item = false;
 		}
 		else if (but->flag & UI_BUT_DRIVEN) {
 			/* pass */
@@ -6530,6 +6534,8 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
 				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
 			}
+
+			is_first_item = false;
 		}
 		
 		if (but->flag & UI_BUT_ANIMATED) {
@@ -6543,11 +6549,13 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
 				               ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1);
 			}
+
+			is_first_item = false;
 		}
 
 		/* Drivers */
 		if (but->flag & UI_BUT_DRIVEN) {
-			uiItemS(layout);
+			ADD_SEPARATOR_CONDITIONAL
 
 			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"),
@@ -6566,12 +6574,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
 				        ICON_NONE, "ANIM_OT_paste_driver_button");
 			}
+
+			is_first_item = false;
 		}
 		else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
 			/* pass */
 		}
 		else if (is_anim) {
-			uiItemS(layout);
+			ADD_SEPARATOR_CONDITIONAL
 
 			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
@@ -6588,12 +6598,14 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
 				        ICON_NONE, "ANIM_OT_paste_driver_button");
 			}
+
+			is_first_item = false;
 		}
 		
 		/* Keying Sets */
 		/* TODO: check on modifyability of Keying Set when doing this */
 		if (is_anim) {
-			uiItemS(layout);
+			ADD_SEPARATOR_CONDITIONAL
 
 			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"),
@@ -6609,10 +6621,12 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"),
 				        ICON_NONE, "ANIM_OT_keyingset_button_remove");
 			}
+
+			is_first_item = false;
 		}
-		
-		uiItemS(layout);
-		
+
+		ADD_SEPARATOR_CONDITIONAL
+
 		/* Property Operators */
 		
 		/* Copy Property Value
@@ -6667,17 +6681,23 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 			but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"),
 			                        0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
 			UI_but_func_set(but2, remove_shortcut_func, but, NULL);
+
+			is_first_item = false;
 		}
 		/* only show 'add' if there's a suitable key map for it to go in */
 		else if (WM_keymap_guess_opname(C, but->optype->idname)) {
 			but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"),
 			                        0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
 			UI_but_func_set(but2, popup_add_shortcut_func, but, NULL);
+
+			is_first_item = false;
 		}
-		
-		uiItemS(layout);
+
+		ADD_SEPARATOR_CONDITIONAL
 	}
 
+#undef ADD_SEPARATOR_CONDITIONAL
+
 	/* Show header tools for header buttons. *

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list