Add type variations for editor help in tooltips

This commit is contained in:
passivestar
2026-01-09 17:28:05 +04:00
parent 4089843d13
commit d378cbca65
4 changed files with 40 additions and 5 deletions

View File

@@ -4588,11 +4588,11 @@ void EditorHelpBit::update_content_height() {
content->set_custom_minimum_size(Size2(content->get_custom_minimum_size().x, CLAMP(content_height, content_min_height, content_max_height)));
}
EditorHelpBit::EditorHelpBit(const String &p_symbol, const String &p_prologue, bool p_use_class_prefix, bool p_allow_selection) {
EditorHelpBit::EditorHelpBit(const String &p_symbol, const String &p_prologue, bool p_use_class_prefix, bool p_allow_selection, bool p_in_tooltip) {
add_theme_constant_override("separation", 0);
title = memnew(RichTextLabel);
title->set_theme_type_variation("EditorHelpBitTitle");
title->set_theme_type_variation(p_in_tooltip ? "EditorHelpBitTooltipTitle" : "EditorHelpBitTitle");
title->set_custom_minimum_size(Size2(640 * EDSCALE, 0)); // GH-93031. Set the minimum width even if `fit_content` is true.
title->set_fit_content(true);
title->set_selection_enabled(p_allow_selection);
@@ -4606,7 +4606,7 @@ EditorHelpBit::EditorHelpBit(const String &p_symbol, const String &p_prologue, b
content_max_height = 360 * EDSCALE;
content = memnew(RichTextLabel);
content->set_theme_type_variation("EditorHelpBitContent");
content->set_theme_type_variation(p_in_tooltip ? "EditorHelpBitTooltipContent" : "EditorHelpBitContent");
content->set_custom_minimum_size(Size2(640 * EDSCALE, content_min_height));
content->set_v_size_flags(Control::SIZE_EXPAND_FILL);
content->set_selection_enabled(p_allow_selection);
@@ -4707,7 +4707,7 @@ Control *EditorHelpBitTooltip::make_tooltip(Control *p_target, const String &p_s
return _make_invisible_control();
}
EditorHelpBit *help_bit = memnew(EditorHelpBit(p_symbol, p_prologue, p_use_class_prefix, false));
EditorHelpBit *help_bit = memnew(EditorHelpBit(p_symbol, p_prologue, p_use_class_prefix, false, true));
EditorHelpBitTooltip *tooltip = memnew(EditorHelpBitTooltip(p_target));
help_bit->connect("request_hide", callable_mp(static_cast<Node *>(tooltip), &Node::queue_free));

View File

@@ -354,7 +354,7 @@ public:
void set_content_height_limits(float p_min, float p_max);
void update_content_height();
EditorHelpBit(const String &p_symbol = String(), const String &p_prologue = String(), bool p_use_class_prefix = false, bool p_allow_selection = true);
EditorHelpBit(const String &p_symbol = String(), const String &p_prologue = String(), bool p_use_class_prefix = false, bool p_allow_selection = true, bool p_in_tooltip = false);
};
// Standard tooltips do not allow you to hover over them.

View File

@@ -2349,6 +2349,12 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &p_theme, Edito
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitContent", style);
}
// EditorHelpBit tooltip type variations.
{
p_theme->set_type_variation("EditorHelpBitTooltipTitle", "EditorHelpBitTitle");
p_theme->set_type_variation("EditorHelpBitTooltipContent", "EditorHelpBitContent");
}
// Asset Library.
p_theme->set_stylebox("bg", "AssetLib", p_config.base_empty_style);
p_theme->set_stylebox(SceneStringName(panel), "AssetLib", p_config.content_panel_style);

View File

@@ -2535,6 +2535,35 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitContent", editor_help_content_style);
}
// EditorHelpBitTooltipTitle.
{
Ref<StyleBoxFlat> style = p_theme->get_stylebox(CoreStringName(normal), "EditorHelpBitTitle")->duplicate();
style->set_bg_color(style->get_bg_color().lerp(p_config.mono_color_inv, 0.25));
if (!p_config.dark_theme) {
style->set_border_width_all(Math::round(2 * EDSCALE));
style->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.15));
}
style->set_corner_radius_all(0);
p_theme->set_type_variation("EditorHelpBitTooltipTitle", "EditorHelpBitTitle");
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitTooltipTitle", style);
}
// EditorHelpBitTooltipContent.
{
Ref<StyleBoxFlat> style = p_theme->get_stylebox(CoreStringName(normal), "EditorHelpBitContent")->duplicate();
style->set_bg_color(style->get_bg_color().lerp(p_config.mono_color_inv, 0.25));
if (!p_config.dark_theme) {
style->set_border_width_all(Math::round(2 * EDSCALE));
style->set_border_width(SIDE_TOP, 0);
style->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.15));
}
style->set_corner_radius_all(0);
p_theme->set_type_variation("EditorHelpBitTooltipContent", "EditorHelpBitContent");
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitTooltipContent", style);
}
// Asset Library.
p_theme->set_stylebox("bg", "AssetLib", EditorThemeManager::make_empty_stylebox(p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
p_theme->set_stylebox(SceneStringName(panel), "AssetLib", p_config.foreground_panel);