From 1661eed7aecf197465a1202a411c84ace6daac4c Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 23 Feb 2024 11:37:46 -0800 Subject: [PATCH 1/2] UI: Change Display of Orphan Data User Count In Outliner "Orphaned Data" view, combine the user count and icon and change the tooltips to better explain the item status and actions. --- .../blender/editors/include/UI_interface_c.hh | 1 + source/blender/editors/interface/interface.cc | 5 ++++ .../editors/space_outliner/outliner_draw.cc | 27 +++++-------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index e7fa52e1f86..c3f9cb1566b 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -1710,6 +1710,7 @@ int UI_search_items_find_index(uiSearchItems *items, const char *name); * Adds a hint to the button which draws right aligned, grayed out and never clipped. */ void UI_but_hint_drawstr_set(uiBut *but, const char *string); +void UI_but_icon_indicator_set(uiBut *but, const const char *string); void UI_but_icon_indicator_number_set(uiBut *but, const int indicator_number); void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4]); diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 14da09df2aa..50043b717c6 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -6365,6 +6365,11 @@ void UI_but_hint_drawstr_set(uiBut *but, const char *string) ui_but_add_shortcut(but, string, false); } +void UI_but_icon_indicator_set(uiBut *but, const char *string) +{ + STRNCPY(but->icon_overlay_text.text, string); +} + void UI_but_icon_indicator_number_set(uiBut *but, const int indicator_number) { UI_icon_text_overlay_init_from_count(&but->icon_overlay_text, indicator_number); diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index f7974a2abea..56a8655182a 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1773,36 +1773,19 @@ static void outliner_draw_userbuts(uiBlock *block, uiBut *bt; ID *id = tselem->id; const char *tip = nullptr; - char buf[BLI_STR_FORMAT_INT32_GROUPED_SIZE] = ""; int but_flag = UI_BUT_DRAG_LOCK; if (ID_IS_LINKED(id)) { but_flag |= UI_BUT_DISABLED; } - BLI_str_format_int_grouped(buf, id->us); - bt = uiDefBut(block, - UI_BTYPE_BUT, - 1, - buf, - int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS), - te->ys, - UI_UNIT_X, - UI_UNIT_Y, - nullptr, - 0.0, - 0.0, - 0, - 0, - TIP_("Number of users of this data-block")); - UI_but_flag_enable(bt, but_flag); - if (id->flag & LIB_FAKEUSER) { - tip = TIP_("Data-block will be retained using a fake user"); + tip = TIP_("Item is protected from removal.\nClick to mark for deletion"); } else { - tip = TIP_("Data-block has no users and will be deleted"); + tip = TIP_("Iitem has no users and will be removed.\nClick to protect from deletion"); } + bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, LIB_FAKEUSER, @@ -1818,7 +1801,11 @@ static void outliner_draw_userbuts(uiBlock *block, 0, 0, tip); + UI_but_func_set(bt, restrictbutton_id_user_toggle, id, nullptr); + char overlay[5]; + BLI_str_format_integer_unit(overlay, id->us); + UI_but_icon_indicator_set(bt, overlay); UI_but_flag_enable(bt, but_flag); }); } -- 2.30.2 From 14622ad15a97a3d1d98688f5c4f5fc03086c6b2c Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 23 Feb 2024 15:10:14 -0800 Subject: [PATCH 2/2] Typo --- source/blender/editors/space_outliner/outliner_draw.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 56a8655182a..bdcba9be67e 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1783,7 +1783,7 @@ static void outliner_draw_userbuts(uiBlock *block, tip = TIP_("Item is protected from removal.\nClick to mark for deletion"); } else { - tip = TIP_("Iitem has no users and will be removed.\nClick to protect from deletion"); + tip = TIP_("Item has no users and will be removed.\nClick to protect from deletion"); } bt = uiDefIconButBitS(block, -- 2.30.2