Skip to content

Commit

Permalink
Editor: Display deprecated/experimental messages in tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
dalexeev committed Apr 18, 2024
1 parent 3b18061 commit a714cb9
Show file tree
Hide file tree
Showing 17 changed files with 803 additions and 364 deletions.
17 changes: 12 additions & 5 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/popup_menu.h"
#include "scene/gui/spin_box.h"
Expand Down Expand Up @@ -872,7 +873,13 @@ ConnectDialog::~ConnectDialog() {

Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
// If it's not a doc tooltip, fallback to the default one.
return p_text.contains("::") ? nullptr : memnew(EditorHelpTooltip(p_text));
if (p_text.contains("::")) {
return nullptr;
}

EditorHelpBit *help_bit = memnew(EditorHelpBit(p_text));
EditorHelpBitTooltip::show_tooltip(help_bit, const_cast<ConnectionsDockTree *>(this));
return memnew(Control); // Make the standard tooltip invisible.
}

struct _ConnectionsDockMethodInfoSort {
Expand Down Expand Up @@ -1458,8 +1465,8 @@ void ConnectionsDock::update_tree() {

section_item = tree->create_item(root);
section_item->set_text(0, class_name);
// `|` separators used in `EditorHelpTooltip` for formatting.
section_item->set_tooltip_text(0, "class|" + doc_class_name + "||");
// `|` separators used in `EditorHelpBit`.
section_item->set_tooltip_text(0, "class|" + doc_class_name + "|");
section_item->set_icon(0, class_icon);
section_item->set_selectable(0, false);
section_item->set_editable(0, false);
Expand Down Expand Up @@ -1490,8 +1497,8 @@ void ConnectionsDock::update_tree() {
sinfo["args"] = argnames;
signal_item->set_metadata(0, sinfo);
signal_item->set_icon(0, get_editor_theme_icon(SNAME("Signal")));
// `|` separators used in `EditorHelpTooltip` for formatting.
signal_item->set_tooltip_text(0, "signal|" + doc_class_name + "|" + String(signal_name) + "|" + signame.trim_prefix(mi.name));
// `|` separators used in `EditorHelpBit`.
signal_item->set_tooltip_text(0, "signal|" + doc_class_name + "|" + String(signal_name));

// List existing connections.
List<Object::Connection> existing_connections;
Expand Down
2 changes: 1 addition & 1 deletion editor/connections_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ConnectDialog : public ConfirmationDialog {

//////////////////////////////////////////

// Custom `Tree` needed to use `EditorHelpTooltip` to display signal documentation.
// Custom `Tree` needed to use `EditorHelpBit` to display signal documentation.
class ConnectionsDockTree : public Tree {
virtual Control *make_custom_tooltip(const String &p_text) const;
};
Expand Down
16 changes: 3 additions & 13 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ void CreateDialog::_update_search() {
select_type(_top_result(candidates, search_text));
} else {
favorite->set_disabled(true);
help_bit->set_text(vformat(TTR("No results for \"%s\"."), search_text));
help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5));
help_bit->set_custom_text(String(), String(), vformat(TTR("No results for \"%s\"."), search_text.replace("[", "[lb]")));
get_ok_button()->set_disabled(true);
search_options->deselect_all();
}
Expand Down Expand Up @@ -502,17 +501,7 @@ void CreateDialog::select_type(const String &p_type, bool p_center_on_item) {
to_select->select(0);
search_options->scroll_to_item(to_select, p_center_on_item);

String text = help_bit->get_class_description(p_type);
if (!text.is_empty()) {
// Display both class name and description, since the help bit may be displayed
// far away from the location (especially if the dialog was resized to be taller).
help_bit->set_text(vformat("[b]%s[/b]: %s", p_type, text));
help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1));
} else {
// Use nested `vformat()` as translators shouldn't interfere with BBCode tags.
help_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", p_type)));
help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5));
}
help_bit->parse_symbol("class|" + p_type + "|");

favorite->set_disabled(false);
favorite->set_pressed(favorite_list.has(p_type));
Expand Down Expand Up @@ -837,6 +826,7 @@ CreateDialog::CreateDialog() {
vbc->add_margin_child(TTR("Matches:"), search_options, true);

help_bit = memnew(EditorHelpBit);
help_bit->set_content_height_limits(64 * EDSCALE, 64 * EDSCALE);
help_bit->connect("request_hide", callable_mp(this, &CreateDialog::_hide_requested));
vbc->add_margin_child(TTR("Description:"), help_bit);

Expand Down
22 changes: 8 additions & 14 deletions editor/editor_build_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ void EditorBuildProfileManager::_action_confirm() {
}
}

void EditorBuildProfileManager::_hide_requested() {
_cancel_pressed(); // From AcceptDialog.
}

void EditorBuildProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) {
TreeItem *class_item = class_list->create_item(p_parent);
class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
Expand Down Expand Up @@ -646,21 +650,10 @@ void EditorBuildProfileManager::_class_list_item_selected() {

Variant md = item->get_metadata(0);
if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) {
String text = description_bit->get_class_description(md);
if (!text.is_empty()) {
// Display both class name and description, since the help bit may be displayed
// far away from the location (especially if the dialog was resized to be taller).
description_bit->set_text(vformat("[b]%s[/b]: %s", md, text));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1));
} else {
// Use nested `vformat()` as translators shouldn't interfere with BBCode tags.
description_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", md)));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5));
}
description_bit->parse_symbol("class|" + md.operator String() + "|");
} else if (md.get_type() == Variant::INT) {
String build_option_description = EditorBuildProfile::get_build_option_description(EditorBuildProfile::BuildOption((int)md));
description_bit->set_text(vformat("[b]%s[/b]: %s", TTR(item->get_text(0)), TTRGET(build_option_description)));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1));
description_bit->set_custom_text(TTR(item->get_text(0)), String(), TTRGET(build_option_description));
}
}

Expand Down Expand Up @@ -864,7 +857,8 @@ EditorBuildProfileManager::EditorBuildProfileManager() {
main_vbc->add_margin_child(TTR("Configure Engine Compilation Profile:"), class_list, true);

description_bit = memnew(EditorHelpBit);
description_bit->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
description_bit->set_content_height_limits(80 * EDSCALE, 80 * EDSCALE);
description_bit->connect("request_hide", callable_mp(this, &EditorBuildProfileManager::_hide_requested));
main_vbc->add_margin_child(TTR("Description:"), description_bit, false);

confirm_dialog = memnew(ConfirmationDialog);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_build_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class EditorBuildProfileManager : public AcceptDialog {

void _profile_action(int p_action);
void _action_confirm();
void _hide_requested();

void _update_edited_profile();
void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
Expand Down
23 changes: 8 additions & 15 deletions editor/editor_feature_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ void EditorFeatureProfileManager::_profile_selected(int p_what) {
_update_selected_profile();
}

void EditorFeatureProfileManager::_hide_requested() {
_cancel_pressed(); // From AcceptDialog.
}

void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) {
TreeItem *class_item = class_list->create_item(p_parent);
class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
Expand Down Expand Up @@ -555,22 +559,10 @@ void EditorFeatureProfileManager::_class_list_item_selected() {

Variant md = item->get_metadata(0);
if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) {
String text = description_bit->get_class_description(md);
if (!text.is_empty()) {
// Display both class name and description, since the help bit may be displayed
// far away from the location (especially if the dialog was resized to be taller).
description_bit->set_text(vformat("[b]%s[/b]: %s", md, text));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1));
} else {
// Use nested `vformat()` as translators shouldn't interfere with BBCode tags.
description_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", md)));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5));
}
description_bit->parse_symbol("class|" + md.operator String() + "|");
} else if (md.get_type() == Variant::INT) {
String feature_description = EditorFeatureProfile::get_feature_description(EditorFeatureProfile::Feature((int)md));
description_bit->set_text(vformat("[b]%s[/b]: %s", TTR(item->get_text(0)), TTRGET(feature_description)));
description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1));

description_bit->set_custom_text(TTR(item->get_text(0)), String(), TTRGET(feature_description));
return;
} else {
return;
Expand Down Expand Up @@ -991,8 +983,9 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);

description_bit = memnew(EditorHelpBit);
description_bit->set_content_height_limits(80 * EDSCALE, 80 * EDSCALE);
description_bit->connect("request_hide", callable_mp(this, &EditorFeatureProfileManager::_hide_requested));
property_list_vbc->add_margin_child(TTR("Description:"), description_bit, false);
description_bit->set_custom_minimum_size(Size2(0, 80) * EDSCALE);

property_list = memnew(Tree);
property_list_vbc->add_margin_child(TTR("Extra Options:"), property_list, true);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_feature_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class EditorFeatureProfileManager : public AcceptDialog {

void _profile_action(int p_action);
void _profile_selected(int p_what);
void _hide_requested();

String current_profile;
void _update_profile_list(const String &p_select_profile = String());
Expand Down
Loading

0 comments on commit a714cb9

Please sign in to comment.