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:
authorJulian Eisel <julian@blender.org>2021-01-26 00:54:00 +0300
committerJulian Eisel <julian@blender.org>2021-01-26 01:10:16 +0300
commit77f73a92843965906189dd56dcc4d18eae2371cc (patch)
tree8ff43da506a34768f01380c5e5d8624dc37b3696 /source/blender/editors/interface/interface_region_search.c
parent14f61c619b0bd28386673672881a234e7e1ded11 (diff)
Fix library name clipping most of the data-block name in data-block menus
Issue is visible here https://developer.blender.org/F8626313. If there is enough space for both the item name and the library hint, display both. Otherwise, clip either the item name, the library hint, or both so that not more than 60% and 40% of the available width are used repectively. There are further improvements we could do, as noted in T84188, this just fixes the regression for the release. Part of T84188. There were multiple reports about this, see merged in and mentioned reports in T84188 and T78012.
Diffstat (limited to 'source/blender/editors/interface/interface_region_search.c')
-rw-r--r--source/blender/editors/interface/interface_region_search.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 7a665909c76..816162e9aa2 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -610,7 +610,15 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
char *name = data->items.names[a];
int icon = data->items.icons[a];
char *name_sep_test = NULL;
- const bool use_sep_char = data->use_sep || (state & UI_BUT_HAS_SEP_CHAR);
+
+ uiMenuItemSeparatorType separator_type = UI_MENU_ITEM_SEPARATOR_NONE;
+ if (data->use_sep) {
+ separator_type = UI_MENU_ITEM_SEPARATOR_SHORTCUT;
+ }
+ /* Only set for displaying additional hint (e.g. library name of a linked data-block). */
+ else if (state & UI_BUT_HAS_SEP_CHAR) {
+ separator_type = UI_MENU_ITEM_SEPARATOR_HINT;
+ }
ui_searchbox_butrect(&rect, data, a);
@@ -623,7 +631,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
}
/* Simple menu item. */
- ui_draw_menu_item(&data->fstyle, &rect, name, icon, state, use_sep_char, NULL);
+ ui_draw_menu_item(&data->fstyle, &rect, name, icon, state, separator_type, NULL);
}
else {
/* Split menu item, faded text before the separator. */
@@ -637,8 +645,13 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
const char name_sep_prev = *name_sep;
*name_sep = '\0';
int name_width = 0;
- ui_draw_menu_item(
- &data->fstyle, &rect, name, 0, state | UI_BUT_INACTIVE, false, &name_width);
+ ui_draw_menu_item(&data->fstyle,
+ &rect,
+ name,
+ 0,
+ state | UI_BUT_INACTIVE,
+ UI_MENU_ITEM_SEPARATOR_NONE,
+ &name_width);
*name_sep = name_sep_prev;
rect.xmin += name_width;
rect.xmin += UI_UNIT_X / 4;
@@ -650,7 +663,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
/* The previous menu item draws the active selection. */
ui_draw_menu_item(
- &data->fstyle, &rect, name_sep, icon, state & ~UI_ACTIVE, use_sep_char, NULL);
+ &data->fstyle, &rect, name_sep, icon, state & ~UI_ACTIVE, separator_type, NULL);
}
}
/* indicate more */
@@ -943,10 +956,16 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, text_pre),
data->items.icons[a],
state,
- false,
+ UI_MENU_ITEM_SEPARATOR_NONE,
+ NULL);
+ ui_draw_menu_item(&data->fstyle,
+ &rect_post,
+ data->items.names[a],
+ 0,
+ state,
+ data->use_sep ? UI_MENU_ITEM_SEPARATOR_SHORTCUT :
+ UI_MENU_ITEM_SEPARATOR_NONE,
NULL);
- ui_draw_menu_item(
- &data->fstyle, &rect_post, data->items.names[a], 0, state, data->use_sep, NULL);
}
}
/* indicate more */