[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58474] branches/soc-2013-ui_replay/source /blender/editors: Added shortcuts to buttons in regions of type RGN_TYPE_TOOLS.

Vincent Akkermans vincent at ack-err.net
Sun Jul 21 16:27:20 CEST 2013


Revision: 58474
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58474
Author:   ack-err
Date:     2013-07-21 14:27:19 +0000 (Sun, 21 Jul 2013)
Log Message:
-----------
Added shortcuts to buttons in regions of type RGN_TYPE_TOOLS. 

To do:
* take care of overlapping text
* add a preference to turn showing the shortcuts off

Modified Paths:
--------------
    branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface.c
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c

Modified: branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h	2013-07-21 14:26:27 UTC (rev 58473)
+++ branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h	2013-07-21 14:27:19 UTC (rev 58474)
@@ -129,6 +129,7 @@
 /* block->flag bits 12-15 are identical to but->flag bits */
 
 #define UI_BLOCK_LIST_ITEM   (1 << 19)
+#define UI_BLOCK_SHORTCUTS	 (1 << 20)
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL     (1 << 0)   /* cancel all menus cascading */

Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface.c	2013-07-21 14:26:27 UTC (rev 58473)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface.c	2013-07-21 14:27:19 UTC (rev 58474)
@@ -969,7 +969,7 @@
 		ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
 	}
 
-	if (block->flag & UI_BLOCK_LOOP) {
+	if (block->flag & UI_BLOCK_SHORTCUTS) {
 		ui_menu_block_set_keymaps(C, block);
 	}
 	
@@ -2233,7 +2233,12 @@
 		block->aspect = 2.0f / fabsf(getsizex * block->winmat[0][0]);
 		block->auto_open = TRUE;
 		block->flag |= UI_BLOCK_LOOP; /* tag as menu */
+		block->flag |= UI_BLOCK_SHORTCUTS;
 	}
+	/* Add shortcuts to toolbar */
+	if (region && region->type && region->type->regionid == RGN_TYPE_TOOLS) {
+		block->flag |= UI_BLOCK_SHORTCUTS;
+	}
 
 	return block;
 }

Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c	2013-07-21 14:26:27 UTC (rev 58473)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c	2013-07-21 14:27:19 UTC (rev 58474)
@@ -1135,6 +1135,7 @@
 {
 	//int transopts;  // UNUSED
 	char *cpoin = NULL;
+	unsigned char button_shortcut_color[4];
 	
 	/* for underline drawing */
 	float font_xofs, font_yofs;
@@ -1214,7 +1215,7 @@
 #endif
 
 	/* cut string in 2 parts - only for menu entries */
-	if ((but->block->flag & UI_BLOCK_LOOP)) {
+	if ((but->block->flag & UI_BLOCK_SHORTCUTS)) {
 		if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) {
 			cpoin = strchr(but->drawstr, '|');
 			if (cpoin) *cpoin = 0;
@@ -1261,6 +1262,12 @@
 	if (cpoin) {
 		fstyle->align = UI_STYLE_TEXT_RIGHT;
 		rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 0.25f * U.widget_unit;
+		/* If this is not a menu, and therefore a normal button, then change the alpha of the shortcut */
+		if (!(but->block->flag & UI_BLOCK_LOOP)) {
+			memcpy(button_shortcut_color, wcol->text, 4);
+			button_shortcut_color[3] /= 2;
+			glColor4ubv(button_shortcut_color);
+		}
 		uiStyleFontDraw(fstyle, rect, cpoin + 1);
 		*cpoin = '|';
 	}




More information about the Bf-blender-cvs mailing list