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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-11 08:56:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-11 08:56:35 +0400
commit90ff86a6d9b81ebd79e9f8c32323eb93f67584a4 (patch)
tree7ebbc73da64da19f4b21dc98947fce51ba55a7df /source
parentf81f6c5019bc84c0839210c75a608bcf17e91df7 (diff)
fix [#36699] ASCII-character "|" blocks parenting
don't split '|' for rna-property search buttons (but keep for operator search).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_regions.c25
-rw-r--r--source/blender/editors/interface/interface_widgets.c24
3 files changed, 33 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 0b02a1a5db4..6382130cbbd 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -538,7 +538,7 @@ extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *s
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];
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 832dd4d23ce..5512054d0f4 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -770,6 +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) */
int prv_rows, prv_cols;
} uiSearchboxData;
@@ -928,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 = 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 @@ 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 = 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 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
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 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
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 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
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) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b469dc994bc..edc67cacb26 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3495,7 +3495,7 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
/* 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 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
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 */