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-27 00:06:45 +0300
committerJulian Eisel <julian@blender.org>2021-01-27 00:17:17 +0300
commitd096d9c4d686471b9de2a993b76f5bd9fef9cb78 (patch)
treef61623f7e2b75d5c59553ab9ed2d4004399701dd /source/blender/editors/interface/interface_templates.c
parent656f6ae6436ae10cae4820a5c957041a20d56995 (diff)
UI: Tooltip for data-block selector menus, showing full name and library info
Long data-block names are clipped to fit into data-block selector menus. For linked data-blocks, there's also a hint indicating the source library, which takes further space and may get clipped too. So this commit adds a tooltip to the menu items, which displays the full, unclipped data-block name and the unclipped library name. Plus, the library path is shown too, which is also useful info. Adds helper functions for search menu item tooltips, so these are easier to add to other search menus in future. Part of T84188.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 003bb110baf..8127a32b271 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -208,6 +208,7 @@ static uiBlock *template_common_search_menu(const bContext *C,
void *search_arg,
uiButHandleFunc search_exec_fn,
void *active_item,
+ uiButSearchTooltipFn item_tooltip_fn,
const int preview_rows,
const int preview_cols,
float scale)
@@ -284,6 +285,7 @@ static uiBlock *template_common_search_menu(const bContext *C,
NULL,
search_exec_fn,
active_item);
+ UI_but_func_search_set_tooltip(but, item_tooltip_fn);
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
UI_block_direction_set(block, UI_DIR_DOWN);
@@ -485,6 +487,31 @@ static void id_search_cb_objects_from_scene(const bContext *C,
id_search_cb_tagged(C, arg_template, str, items);
}
+static ARegion *template_ID_search_menu_item_tooltip(
+ bContext *C, ARegion *region, const rcti *item_rect, void *arg, void *active)
+{
+ TemplateID *template_ui = arg;
+ ID *active_id = active;
+ StructRNA *type = RNA_property_pointer_type(&template_ui->ptr, template_ui->prop);
+
+ uiSearchItemTooltipData tooltip_data = {0};
+
+ tooltip_data.name = active_id->name + 2;
+ BLI_snprintf(tooltip_data.description,
+ sizeof(tooltip_data.description),
+ TIP_("Choose %s data-block to be assigned to this user"),
+ RNA_struct_ui_name(type));
+ if (ID_IS_LINKED(active_id)) {
+ BLI_snprintf(tooltip_data.hint,
+ sizeof(tooltip_data.hint),
+ TIP_("Source library: %s\n%s"),
+ active_id->lib->id.name + 2,
+ active_id->lib->filepath);
+ }
+
+ return UI_tooltip_create_from_search_item_generic(C, region, item_rect, &tooltip_data);
+}
+
/* ID Search browse menu, open */
static uiBlock *id_search_menu(bContext *C, ARegion *region, void *arg_litem)
{
@@ -512,6 +539,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *region, void *arg_litem)
&template_ui,
template_ID_set_property_exec_fn,
active_item_ptr.data,
+ template_ID_search_menu_item_tooltip,
template_ui.prv_rows,
template_ui.prv_cols,
template_ui.scale);
@@ -1632,6 +1660,7 @@ static uiBlock *template_search_menu(bContext *C, ARegion *region, void *arg_tem
&template_search,
template_search_exec_fn,
active_ptr.data,
+ NULL,
template_search.preview_rows,
template_search.preview_cols,
1.0f);