[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60032] trunk/blender/source/blender/ editors: interface, replace '|' with define UI_SEP_CHAR

Campbell Barton ideasman42 at gmail.com
Wed Sep 11 07:06:27 CEST 2013


Revision: 60032
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60032
Author:   campbellbarton
Date:     2013-09-11 05:06:27 +0000 (Wed, 11 Sep 2013)
Log Message:
-----------
interface, replace '|' with define UI_SEP_CHAR

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/interface/interface_widgets.c

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2013-09-11 04:56:35 UTC (rev 60031)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2013-09-11 05:06:27 UTC (rev 60032)
@@ -82,6 +82,10 @@
 
 /* Defines */
 
+/* char for splitting strings, aligning shortcuts in menus, users never see */
+#define UI_SEP_CHAR   '|'
+#define UI_SEP_CHAR_S "|"
+
 /* names */
 #define UI_MAX_DRAW_STR 400
 #define UI_MAX_NAME_STR 128

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2013-09-11 04:56:35 UTC (rev 60031)
+++ trunk/blender/source/blender/editors/interface/interface.c	2013-09-11 05:06:27 UTC (rev 60032)
@@ -837,7 +837,7 @@
 {
 
 	if (do_strip) {
-		char *cpoin = strchr(but->str, '|');
+		char *cpoin = strchr(but->str, UI_SEP_CHAR);
 		if (cpoin) {
 			*cpoin = '\0';
 		}
@@ -855,7 +855,7 @@
 		}
 		BLI_snprintf(but->strdata,
 		             sizeof(but->strdata),
-		             "%s|%s",
+		             "%s" UI_SEP_CHAR_S "%s",
 		             butstr_orig, shortcut_str);
 		MEM_freeN(butstr_orig);
 		but->str = but->strdata;

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2013-09-11 04:56:35 UTC (rev 60031)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2013-09-11 05:06:27 UTC (rev 60032)
@@ -196,7 +196,7 @@
 				s++;
 			}
 		}
-		else if (c == '|' || c == '\n' || c == '\0') {
+		else if (c == UI_SEP_CHAR || c == '\n' || c == '\0') {
 			if (nitem) {
 				*s = '\0';
 
@@ -770,7 +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) */
+	bool use_sep;   /* use the UI_SEP_CHAR char for splitting shortcuts (good for operators, bad for data) */
 	int prv_rows, prv_cols;
 } uiSearchboxData;
 
@@ -929,7 +929,7 @@
 	
 	if (data->active != -1) {
 		const char *name = data->items.names[data->active];
-		const char *name_sep = data->use_sep ? strchr(name, '|') : NULL;
+		const char *name_sep = data->use_sep ? strchr(name, UI_SEP_CHAR) : NULL;
 
 		BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen);
 		
@@ -1035,7 +1035,7 @@
 		
 		for (a = 0; a < data->items.totitem; a++) {
 			const char *name = data->items.names[a];
-			const char *name_sep = data->use_sep ? strchr(name, '|') : NULL;
+			const char *name_sep = data->use_sep ? strchr(name, UI_SEP_CHAR) : NULL;
 			if (STREQLEN(but->editstr, name, name_sep ? (name_sep - name) : data->items.maxstrlen)) {
 				data->active = a;
 				break;
@@ -2312,11 +2312,11 @@
 {
 	/* sometimes button contains hotkey, sometimes not, strip for proper compare */
 	int hash;
-	char *delimit = strchr(str, '|');
+	char *delimit = strchr(str, UI_SEP_CHAR);
 
-	if (delimit) *delimit = 0;
+	if (delimit) *delimit = '\0';
 	hash = BLI_ghashutil_strhash(str);
-	if (delimit) *delimit = '|';
+	if (delimit) *delimit = UI_SEP_CHAR;
 
 	return hash;
 }

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2013-09-11 04:56:35 UTC (rev 60031)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2013-09-11 05:06:27 UTC (rev 60032)
@@ -3133,7 +3133,7 @@
 					if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true,
 					                                 &name[len + 1], sizeof(name) - len - 1))
 					{
-						name[len] = '|';
+						name[len] = UI_SEP_CHAR;
 					}
 				}
 				

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-09-11 04:56:35 UTC (rev 60031)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-09-11 05:06:27 UTC (rev 60032)
@@ -1215,7 +1215,7 @@
 	/* cut string in 2 parts - only for menu entries */
 	if ((but->block->flag & UI_BLOCK_LOOP)) {
 		if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) {
-			cpoin = strchr(but->drawstr, '|');
+			cpoin = strchr(but->drawstr, UI_SEP_CHAR);
 			if (cpoin) *cpoin = 0;
 		}
 	}
@@ -1261,7 +1261,7 @@
 		fstyle->align = UI_STYLE_TEXT_RIGHT;
 		rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 0.25f * U.widget_unit;
 		uiStyleFontDraw(fstyle, rect, cpoin + 1);
-		*cpoin = '|';
+		*cpoin = UI_SEP_CHAR;
 	}
 }
 
@@ -3513,7 +3513,7 @@
 
 	/* cut string in 2 parts? */
 	if (use_sep) {
-		cpoin = strchr(name, '|');
+		cpoin = strchr(name, UI_SEP_CHAR);
 		if (cpoin) {
 			*cpoin = 0;
 			rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
@@ -3529,7 +3529,7 @@
 			fstyle->align = UI_STYLE_TEXT_RIGHT;
 			rect->xmax = _rect.xmax - 5;
 			uiStyleFontDraw(fstyle, rect, cpoin + 1);
-			*cpoin = '|';
+			*cpoin = UI_SEP_CHAR;
 		}
 	}
 	




More information about the Bf-blender-cvs mailing list