From 6a49a51bcfc8f9b737484889f548923dca37382e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Apr 2024 10:29:26 -0700 Subject: [PATCH 1/4] UI: Tooltips for Bone Collection Active & Selected Hovering over the filled and open circles of Bone Collection items does not give any hints on what these indicate. This PR makes them say "Active" and "Selected". --- .../templates/interface_template_bone_collection_tree.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc index bda7d1cf8ee..9fed1eef3c0 100644 --- a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc @@ -24,6 +24,8 @@ #include "WM_api.hh" +#include "interface_intern.hh" + #include namespace blender::ui::bonecollections { @@ -229,16 +231,22 @@ class BoneCollectionItem : public AbstractTreeViewItem { * assigned to. And this happens for each redraw of each bone collection in the armature. */ { int icon; + const char *tip = nullptr; if (ANIM_armature_bonecoll_contains_active_bone(&armature_, &bone_collection_)) { icon = ICON_LAYER_ACTIVE; + tip = TIP_("Active"); } else if (has_any_selected_bones_) { icon = ICON_LAYER_USED; + tip = TIP_("Selected"); } else { icon = ICON_BLANK1; } uiItemL(sub, "", icon); + uiBlock *block = uiLayoutGetBlock(sub); + uiBut *but = ui_but_last(block); + but->tip = tip; } /* Visibility eye icon. */ -- 2.30.2 From f4300eab3ce11725b0df6abe30bce2fa1b4852e2 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Apr 2024 12:46:08 -0700 Subject: [PATCH 2/4] Set tooltip on the actual button, not row. --- .../templates/interface_template_bone_collection_tree.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc index 9fed1eef3c0..e345f0af169 100644 --- a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc @@ -243,9 +243,8 @@ class BoneCollectionItem : public AbstractTreeViewItem { else { icon = ICON_BLANK1; } - uiItemL(sub, "", icon); - uiBlock *block = uiLayoutGetBlock(sub); - uiBut *but = ui_but_last(block); + uiBut *but = uiItemL_ex(sub, "", icon, false, false); + but->type = UI_BTYPE_BUT; but->tip = tip; } -- 2.30.2 From 08c8cf9697f4c893e8bb0ae7c30af358b71367c5 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 5 Apr 2024 11:58:06 -0700 Subject: [PATCH 3/4] Allow setting tip when creating the label. --- source/blender/editors/include/UI_interface_c.hh | 7 ++++++- .../blender/editors/interface/interface_layout.cc | 14 ++++++++++++-- .../interface_template_bone_collection_tree.cc | 6 +----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index 48493f03db2..f758059a8a1 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -2925,7 +2925,12 @@ struct uiPropertySplitWrapper { uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout); void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ -uiBut *uiItemL_ex(uiLayout *layout, const char *name, int icon, bool highlight, bool redalert); +uiBut *uiItemL_ex(uiLayout *layout, + const char *name, + int icon, + bool highlight, + bool redalert, + const char *tip = nullptr); /** * Helper to add a label and creates a property split layout if needed. */ diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 0acfa11a015..74fd367efe8 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -3297,8 +3297,12 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) return but; } -uiBut *uiItemL_ex( - uiLayout *layout, const char *name, int icon, const bool highlight, const bool redalert) +uiBut *uiItemL_ex(uiLayout *layout, + const char *name, + int icon, + const bool highlight, + const bool redalert, + const char *tip) { uiBut *but = uiItemL_(layout, name, icon); @@ -3311,6 +3315,12 @@ uiBut *uiItemL_ex( UI_but_flag_enable(but, UI_BUT_REDALERT); } + if (tip) { + /* UI_BTYPE_LABEL doesn't show tooltips. */ + but->type = UI_BTYPE_BUT; + but->tip = tip; + } + return but; } diff --git a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc index e345f0af169..bf2346922e7 100644 --- a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc @@ -24,8 +24,6 @@ #include "WM_api.hh" -#include "interface_intern.hh" - #include namespace blender::ui::bonecollections { @@ -243,9 +241,7 @@ class BoneCollectionItem : public AbstractTreeViewItem { else { icon = ICON_BLANK1; } - uiBut *but = uiItemL_ex(sub, "", icon, false, false); - but->type = UI_BTYPE_BUT; - but->tip = tip; + uiBut *but = uiItemL_ex(sub, "", icon, false, false, tip); } /* Visibility eye icon. */ -- 2.30.2 From 03a6e583f7e461a9b13e6598089ff7243697c2c8 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 9 Apr 2024 15:55:23 -0700 Subject: [PATCH 4/4] Text changes suggested by Sybren. --- .../templates/interface_template_bone_collection_tree.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc index bf2346922e7..11bf017e15d 100644 --- a/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_bone_collection_tree.cc @@ -232,11 +232,11 @@ class BoneCollectionItem : public AbstractTreeViewItem { const char *tip = nullptr; if (ANIM_armature_bonecoll_contains_active_bone(&armature_, &bone_collection_)) { icon = ICON_LAYER_ACTIVE; - tip = TIP_("Active"); + tip = TIP_("Contains the active bone"); } else if (has_any_selected_bones_) { icon = ICON_LAYER_USED; - tip = TIP_("Selected"); + tip = TIP_("Contains one or more selected bones"); } else { icon = ICON_BLANK1; -- 2.30.2