Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-11 09:06:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-11 09:06:27 +0400
commit3579dfe23a4554d786f227a84a0dcac1a7e9e5c8 (patch)
treef6be2ceec215280efa74fb56990fd09775af2692 /source/blender
parent90ff86a6d9b81ebd79e9f8c32323eb93f67584a4 (diff)
interface, replace '|' with define UI_SEP_CHAR
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/interface/interface.c4
-rw-r--r--source/blender/editors/interface/interface_regions.c14
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c8
5 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 8b395505623..38aad640ee1 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -82,6 +82,10 @@ typedef struct uiLayout uiLayout;
/* 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
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index ec5a4d0027d..e30d9ce5b78 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -837,7 +837,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
{
if (do_strip) {
- char *cpoin = strchr(but->str, '|');
+ char *cpoin = strchr(but->str, UI_SEP_CHAR);
if (cpoin) {
*cpoin = '\0';
}
@@ -855,7 +855,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
}
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;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 5512054d0f4..35741618211 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -196,7 +196,7 @@ static MenuData *decompose_menu_string(const char *str)
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 @@ typedef struct uiSearchboxData {
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 @@ bool ui_searchbox_apply(uiBut *but, ARegion *ar)
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 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
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 @@ static int ui_popup_string_hash(const char *str)
{
/* 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;
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 78180965f9c..bd3103e499e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3133,7 +3133,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
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;
}
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index edc67cacb26..4be8812d68c 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1215,7 +1215,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* 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 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
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 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
/* 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 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
fstyle->align = UI_STYLE_TEXT_RIGHT;
rect->xmax = _rect.xmax - 5;
uiStyleFontDraw(fstyle, rect, cpoin + 1);
- *cpoin = '|';
+ *cpoin = UI_SEP_CHAR;
}
}