[Bf-blender-cvs] [06a786f12d5] blender2.8: UI: show toolbar shortcuts

Campbell Barton noreply at git.blender.org
Sun May 13 10:28:26 CEST 2018


Commit: 06a786f12d5b56fc71f4996aff767dea3fedba6e
Author: Campbell Barton
Date:   Sun May 13 10:25:18 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB06a786f12d5b56fc71f4996aff767dea3fedba6e

UI: show toolbar shortcuts

When toobar text is expanded, show shortcuts
(normally confined to menus).

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

M	source/blender/editors/include/UI_interface.h
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/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 89c75e955ce..c1aae483644 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -142,6 +142,8 @@ enum {
 #define UI_BLOCK_LIST_ITEM   (1 << 19)
 #define UI_BLOCK_RADIAL      (1 << 20)
 #define UI_BLOCK_POPOVER     (1 << 21)
+/** Always show keymaps, even for non-menus. */
+#define UI_BLOCK_SHOW_SHORTCUT_ALWAYS (1 << 22)
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL     (1 << 0)   /* cancel all menus cascading */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index ee511eff215..b63ba4166a7 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1096,7 +1096,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
 	uiBut *but;
 	char buf[128];
 
-	BLI_assert(block->flag & UI_BLOCK_LOOP);
+	BLI_assert(block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS));
 
 	/* only do it before bounding */
 	if (block->rect.xmin != block->rect.xmax)
@@ -1112,7 +1112,13 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
 	}
 	else {
 		for (but = block->buttons.first; but; but = but->next) {
-			if (but->dt != UI_EMBOSS_PULLDOWN) {
+			if (block->flag & UI_BLOCK_SHOW_SHORTCUT_ALWAYS) {
+				/* Skip icon-only buttons (as used in the toolbar). */
+				if (but->drawstr[0] == '\0') {
+					continue;
+				}
+			}
+			else if (but->dt != UI_EMBOSS_PULLDOWN) {
 				continue;
 			}
 
@@ -1216,7 +1222,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
 		ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
 	}
 
-	if (block->flag & UI_BLOCK_LOOP) {
+	if (block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) {
 		ui_menu_block_set_keymaps(C, block);
 	}
 	
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 3a8e53d3e90..da1f57409a8 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -3504,6 +3504,10 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s
 	if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU)
 		layout->space = 0;
 
+	if (type == UI_LAYOUT_TOOLBAR) {
+		block->flag |= UI_BLOCK_SHOW_SHORTCUT_ALWAYS;
+	}
+
 	if (dir == UI_LAYOUT_HORIZONTAL) {
 		layout->h = size;
 		layout->root->emh = em * UI_UNIT_Y;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d5631ab8eb3..6c558bcc961 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1868,7 +1868,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 #endif
 
 	/* cut string in 2 parts - only for menu entries */
-	if ((but->block->flag & UI_BLOCK_LOOP) &&
+	if ((but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) &&
 	    (but->editstr == NULL))
 	{
 		if (but->flag & UI_BUT_HAS_SEP_CHAR) {



More information about the Bf-blender-cvs mailing list