[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60031] trunk/blender/source/blender/ editors/interface: fix [#36699] ASCII-character "|" blocks parenting

Campbell Barton ideasman42 at gmail.com
Wed Sep 11 06:56:35 CEST 2013


Revision: 60031
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60031
Author:   campbellbarton
Date:     2013-09-11 04:56:35 +0000 (Wed, 11 Sep 2013)
Log Message:
-----------
fix [#36699] ASCII-character "|" blocks parenting
don't split '|' for rna-property search buttons (but keep for operator search).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_intern.h
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_widgets.c

Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h	2013-09-11 04:14:27 UTC (rev 60030)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h	2013-09-11 04:56:35 UTC (rev 60031)
@@ -538,7 +538,7 @@
 struct ThemeUI;
 void ui_widget_color_init(struct ThemeUI *tui);
 
-void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
+void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep);
 void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
 
 extern const unsigned char checker_stipple_sml[32 * 32 / 8];

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2013-09-11 04:14:27 UTC (rev 60030)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2013-09-11 04:56:35 UTC (rev 60031)
@@ -770,6 +770,7 @@
 	int active;     /* index in items array */
 	bool noback;    /* when menu opened with enough space for this */
 	bool preview;   /* draw thumbnail previews, rather than list */
+	bool use_sep;   /* use the '|' char for splitting shortcuts (good for operators, bad for data) */
 	int prv_rows, prv_cols;
 } uiSearchboxData;
 
@@ -928,7 +929,7 @@
 	
 	if (data->active != -1) {
 		const char *name = data->items.names[data->active];
-		const char *name_sep = strchr(name, '|');
+		const char *name_sep = data->use_sep ? strchr(name, '|') : NULL;
 
 		BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen);
 		
@@ -1034,7 +1035,7 @@
 		
 		for (a = 0; a < data->items.totitem; a++) {
 			const char *name = data->items.names[a];
-			const char *name_sep = strchr(name, '|');
+			const char *name_sep = data->use_sep ? strchr(name, '|') : NULL;
 			if (STREQLEN(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen)) {
 				data->active = a;
 				break;
@@ -1087,10 +1088,14 @@
 				ui_searchbox_butrect(&rect, data, a);
 				
 				/* widget itself */
-				if (data->preview)
-					ui_draw_preview_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a == data->active) ? UI_ACTIVE : 0);
-				else 
-					ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a == data->active) ? UI_ACTIVE : 0);
+				if (data->preview) {
+					ui_draw_preview_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a],
+					                     (a == data->active) ? UI_ACTIVE : 0);
+				}
+				else {
+					ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a],
+					                  (a == data->active) ? UI_ACTIVE : 0, data->use_sep);
+				}
 			}
 			
 			/* indicate more */
@@ -1114,7 +1119,8 @@
 				ui_searchbox_butrect(&rect, data, a);
 				
 				/* widget itself */
-				ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a == data->active) ? UI_ACTIVE : 0);
+				ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a],
+				                  (a == data->active) ? UI_ACTIVE : 0, data->use_sep);
 				
 			}
 			/* indicate more */
@@ -1194,6 +1200,11 @@
 		data->prv_rows = but->a1;
 		data->prv_cols = but->a2;
 	}
+
+	/* only show key shortcuts when needed (not rna buttons) [#36699] */
+	if (but->rnaprop == NULL) {
+		data->use_sep = true;
+	}
 	
 	/* compute position */
 	if (but->block->flag & UI_BLOCK_SEARCH_MENU) {

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-09-11 04:14:27 UTC (rev 60030)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-09-11 04:56:35 UTC (rev 60031)
@@ -3495,7 +3495,7 @@
 
 /* helper call to draw a menu item without button */
 /* state: UI_ACTIVE or 0 */
-void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
+void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep)
 {
 	uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
 	rcti _rect = *rect;
@@ -3512,21 +3512,25 @@
 	if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
 
 	/* cut string in 2 parts? */
-	cpoin = strchr(name, '|');
-	if (cpoin) {
-		*cpoin = 0;
-		rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
+	if (use_sep) {
+		cpoin = strchr(name, '|');
+		if (cpoin) {
+			*cpoin = 0;
+			rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
+		}
 	}
 	
 	glColor4ubv((unsigned char *)wt->wcol.text);
 	uiStyleFontDraw(fstyle, rect, name);
 	
 	/* part text right aligned */
-	if (cpoin) {
-		fstyle->align = UI_STYLE_TEXT_RIGHT;
-		rect->xmax = _rect.xmax - 5;
-		uiStyleFontDraw(fstyle, rect, cpoin + 1);
-		*cpoin = '|';
+	if (use_sep) {
+		if (cpoin) {
+			fstyle->align = UI_STYLE_TEXT_RIGHT;
+			rect->xmax = _rect.xmax - 5;
+			uiStyleFontDraw(fstyle, rect, cpoin + 1);
+			*cpoin = '|';
+		}
 	}
 	
 	/* restore rect, was messed with */




More information about the Bf-blender-cvs mailing list