UI: Enum Tooltip Item Order

Tooltips for enum items currently show the enum name on one line, then
enum description, then the current value's name, then the value's
description on the next line. This PR changes that to display the
(short) names together then the (longer) descriptions together. This
also adds a small amount of padding under the title.

Pull Request: https://projects.blender.org/blender/blender/pulls/137571
This commit is contained in:
Harley Acheson
2025-05-01 00:50:34 +02:00
committed by Harley Acheson
parent 2ab59859c9
commit 89ad52b22a

View File

@@ -608,7 +608,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_tool(bContext *C,
{},
UI_TIP_STYLE_NORMAL,
(is_error) ? UI_TIP_LC_ALERT : UI_TIP_LC_MAIN,
true);
false);
MEM_freeN(expr_result);
}
}
@@ -899,6 +899,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
* Otherwise fallback to the regular label. */
if (!but_tip_label.empty()) {
UI_tooltip_text_field_add(*data, but_tip_label, {}, UI_TIP_STYLE_HEADER, UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(*data, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL);
}
/* Regular (non-custom) label. Only show when the button doesn't already show the label. Check
* prefix instead of comparing because the button may include the shortcut. Buttons with dynamic
@@ -907,14 +908,25 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
else if (!but_label.empty() && !blender::StringRef(but->drawstr).startswith(but_label) &&
!but->tip_func)
{
UI_tooltip_text_field_add(*data, but_label, {}, UI_TIP_STYLE_HEADER, UI_TIP_LC_NORMAL);
if (!enum_label.empty()) {
UI_tooltip_text_field_add(*data,
fmt::format("{}: ", but_label),
enum_label,
UI_TIP_STYLE_HEADER,
UI_TIP_LC_NORMAL);
}
else {
UI_tooltip_text_field_add(*data, but_label, {}, UI_TIP_STYLE_HEADER, UI_TIP_LC_NORMAL);
}
UI_tooltip_text_field_add(*data, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL);
}
/* Tip */
if (!but_tip.empty()) {
if (!enum_label.empty()) {
if (!enum_label.empty() && enum_label == but_label) {
UI_tooltip_text_field_add(
*data, fmt::format("{}: ", but_tip), enum_label, UI_TIP_STYLE_HEADER, UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(*data, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL);
}
else {
const bool add_period = ui_tooltip_period_needed(but_tip);
@@ -923,6 +935,9 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
{},
UI_TIP_STYLE_HEADER,
UI_TIP_LC_NORMAL);
if (but_label.empty()) {
UI_tooltip_text_field_add(*data, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL);
}
}
/* special case enum rna buttons */
@@ -958,7 +973,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
true);
!data->fields.is_empty());
}
/* Property context-toggle shortcut. */
@@ -1202,6 +1217,11 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
IMB_freeImBuf(image_data.ibuf);
}
/* If the last field is a spacer, remove it. */
while (!data->fields.is_empty() && data->fields.last().format.style == UI_TIP_STYLE_SPACER) {
data->fields.pop_last();
}
return data->fields.is_empty() ? nullptr : std::move(data);
}