search box width's now scale with DPI setting.
was checking on: [#33294] too small place for material names this helps in some cases but doesn't resolve issue with very long names.
This commit is contained in:
@@ -615,7 +615,8 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int
|
||||
/* bfunc gets search item *poin as arg2, or if NULL the old string */
|
||||
void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
|
||||
/* height in pixels, it's using hardcoded values still */
|
||||
int uiSearchBoxhHeight(void);
|
||||
int uiSearchBoxHeight(void);
|
||||
int uiSearchBoxWidth(void);
|
||||
|
||||
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
|
||||
void uiBlockSetButmFunc(uiBlock *block, uiMenuHandleFunc func, void *arg);
|
||||
|
||||
@@ -2826,6 +2826,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
|
||||
EnumPropertyItem *item;
|
||||
int i, totitem, free;
|
||||
|
||||
/* TODO, translate after getting the item, saves many lookups */
|
||||
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||
for (i = 0; i < totitem; i++) {
|
||||
if (item[i].identifier[0] && item[i].value == (int)max) {
|
||||
|
||||
@@ -826,11 +826,17 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
|
||||
return 1;
|
||||
}
|
||||
|
||||
int uiSearchBoxhHeight(void)
|
||||
int uiSearchBoxHeight(void)
|
||||
{
|
||||
return SEARCH_ITEMS * UI_UNIT_Y + 2 * MENU_TOP;
|
||||
}
|
||||
|
||||
int uiSearchBoxWidth(void)
|
||||
{
|
||||
/* was hardcoded at 150 */
|
||||
return 9 * UI_UNIT_X;
|
||||
}
|
||||
|
||||
/* ar is the search box itself */
|
||||
static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step)
|
||||
{
|
||||
@@ -1191,10 +1197,11 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
|
||||
}
|
||||
}
|
||||
else {
|
||||
const int searchbox_width = uiSearchBoxWidth();
|
||||
rect_fl.xmin = but->rect.xmin - 5; /* align text with button */
|
||||
rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */
|
||||
rect_fl.ymax = but->rect.ymin;
|
||||
rect_fl.ymin = rect_fl.ymax - uiSearchBoxhHeight();
|
||||
rect_fl.ymin = rect_fl.ymax - uiSearchBoxHeight();
|
||||
|
||||
ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
|
||||
ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
|
||||
@@ -1202,8 +1209,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
|
||||
BLI_rctf_translate(&rect_fl, ofsx, ofsy);
|
||||
|
||||
/* minimal width */
|
||||
if (BLI_rctf_size_x(&rect_fl) < 150) {
|
||||
rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */
|
||||
if (BLI_rctf_size_x(&rect_fl) < searchbox_width) {
|
||||
rect_fl.xmax = rect_fl.xmin + searchbox_width;
|
||||
}
|
||||
|
||||
/* copy to int, gets projected if possible too */
|
||||
|
||||
@@ -191,10 +191,12 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
}
|
||||
/* list view */
|
||||
else {
|
||||
const int searchbox_width = uiSearchBoxWidth();
|
||||
const int searchbox_height = uiSearchBoxHeight();
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
|
||||
uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -631,7 +631,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
|
||||
uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, "");
|
||||
uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
|
||||
|
||||
@@ -176,7 +176,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
|
||||
uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
|
||||
uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL);
|
||||
|
||||
@@ -793,7 +793,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op)
|
||||
uiButSetSearchFunc(but, operator_enum_search_cb, op->type, operator_enum_call_cb, NULL);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
|
||||
uiEndBlock(C, block);
|
||||
@@ -1566,7 +1566,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_
|
||||
uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
|
||||
|
||||
uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
|
||||
uiEndBlock(C, block);
|
||||
|
||||
Reference in New Issue
Block a user