interface, replace '|' with define UI_SEP_CHAR

This commit is contained in:
Campbell Barton 2013-09-11 05:06:27 +00:00
parent 90ff86a6d9
commit 3579dfe23a
5 changed files with 18 additions and 14 deletions

@ -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

@ -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;

@ -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;
}

@ -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;
}
}

@ -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;
}
}