summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-07-07 16:04:41 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-07-07 16:04:41 +0200
commit5205ff69ca1cf971cadbf4c418fb99179f2bf6e8 (patch)
treed0ba3a00035ff452e63edc67d18ab65a734fae23
parenta2604ff7123174fd95c22a4c7f3e2972bb4fb514 (diff)
parentd007be2d14387c6bb3ab206db23db276eb9b677d (diff)
downloadredot-engine-5205ff69ca1cf971cadbf4c418fb99179f2bf6e8.tar.gz
Merge pull request #79090 from mb4c/wrap-tooltip
Add tooltip description wrapping in scene tree and plugin settings
-rw-r--r--editor/editor_plugin_settings.cpp11
-rw-r--r--editor/gui/scene_tree_editor.cpp9
2 files changed, 18 insertions, 2 deletions
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 1e582992d1..7f57619ac8 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -101,9 +101,18 @@ void EditorPluginSettings::update_plugins() {
String description = cf->get_value("plugin", "description");
String scr = cf->get_value("plugin", "script");
+ const PackedInt32Array boundaries = TS->string_get_word_breaks(description, "", 80);
+ String wrapped_description;
+
+ for (int j = 0; j < boundaries.size(); j += 2) {
+ const int start = boundaries[j];
+ const int end = boundaries[j + 1];
+ wrapped_description += "\n" + description.substr(start, end - start + 1).rstrip("\n");
+ }
+
TreeItem *item = plugin_list->create_item(root);
item->set_text(0, name);
- item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + scr + "\n" + TTR("Description:") + " " + description);
+ item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + scr + "\n" + TTR("Description:") + " " + wrapped_description);
item->set_metadata(0, path);
item->set_text(1, version);
item->set_metadata(1, scr);
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp
index 7b0b816630..d8c6ff54cc 100644
--- a/editor/gui/scene_tree_editor.cpp
+++ b/editor/gui/scene_tree_editor.cpp
@@ -374,7 +374,14 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
tooltip += String("\n" + TTR("Type:") + " " + (custom_type != StringName() ? String(custom_type) : p_node->get_class()));
if (!p_node->get_editor_description().is_empty()) {
- tooltip += "\n\n" + p_node->get_editor_description();
+ const PackedInt32Array boundaries = TS->string_get_word_breaks(p_node->get_editor_description(), "", 80);
+ tooltip += "\n";
+
+ for (int i = 0; i < boundaries.size(); i += 2) {
+ const int start = boundaries[i];
+ const int end = boundaries[i + 1];
+ tooltip += "\n" + p_node->get_editor_description().substr(start, end - start + 1).rstrip("\n");
+ }
}
item->set_tooltip_text(0, tooltip);