fix [#36699] ASCII-character "|" blocks parenting
don't split '|' for rna-property search buttons (but keep for operator search).
This commit is contained in:
parent
f81f6c5019
commit
90ff86a6d9
|
@ -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];
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue