Skip to content

Commit

Permalink
Merge pull request godotengine#81284 from YeldhamDev/this_one_was_in_…
Browse files Browse the repository at this point in the history
…the_backlog_for_a_while

Show doc tooltips when hovering properties in the theme editor
  • Loading branch information
akien-mga committed Oct 6, 2023
2 parents 2f919f0 + 34e6b86 commit 7b999ee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 0 additions & 1 deletion editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "core/config/project_settings.h"
#include "core/templates/hash_set.h"
#include "editor/doc_tools.h"
#include "editor/editor_help.h"
#include "editor/editor_inspector.h"
#include "editor/editor_node.h"
Expand Down
3 changes: 1 addition & 2 deletions editor/connections_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ class ConnectDialog : public ConfirmationDialog {

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

// Custom Tree needed to use a RichTextLabel as tooltip control
// when display signal documentation.
// Custom `Tree` needed to use `EditorHelpTooltip` to display signal documentation.
class ConnectionsDockTree : public Tree {
virtual Control *make_custom_tooltip(const String &p_text) const;
};
Expand Down
12 changes: 9 additions & 3 deletions editor/plugins/theme_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "theme_editor_plugin.h"

#include "core/os/keyboard.h"
#include "editor/editor_help.h"
#include "editor/editor_node.h"
#include "editor/editor_resource_picker.h"
#include "editor/editor_scale.h"
Expand Down Expand Up @@ -2259,6 +2260,10 @@ ThemeTypeDialog::ThemeTypeDialog() {

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

Control *ThemeItemLabel::make_custom_tooltip(const String &p_text) const {
return memnew(EditorHelpTooltip(p_text));
}

VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) {
VBoxContainer *items_tab = memnew(VBoxContainer);
items_tab->set_custom_minimum_size(Size2(0, 160) * EDSCALE);
Expand Down Expand Up @@ -2413,11 +2418,13 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_
item_name_container->set_stretch_ratio(2.0);
item_control->add_child(item_name_container);

Label *item_name = memnew(Label);
Label *item_name = memnew(ThemeItemLabel);
item_name->set_h_size_flags(SIZE_EXPAND_FILL);
item_name->set_clip_text(true);
item_name->set_text(p_item_name);
item_name->set_tooltip_text(p_item_name);
// `|` separators used in `EditorHelpTooltip` for formatting.
item_name->set_tooltip_text("theme_item|" + edited_type + "|" + p_item_name + "|");
item_name->set_mouse_filter(Control::MOUSE_FILTER_STOP);
item_name_container->add_child(item_name);

if (p_editable) {
Expand Down Expand Up @@ -2477,7 +2484,6 @@ void ThemeTypeEditor::_add_focusable(Control *p_control) {

void ThemeTypeEditor::_update_type_items() {
bool show_default = show_default_items_button->is_pressed();
List<StringName> names;

focusables.clear();

Expand Down
5 changes: 5 additions & 0 deletions editor/plugins/theme_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ class ThemeTypeDialog : public ConfirmationDialog {
ThemeTypeDialog();
};

// Custom `Label` needed to use `EditorHelpTooltip` to display theme item documentation.
class ThemeItemLabel : public Label {
virtual Control *make_custom_tooltip(const String &p_text) const;
};

class ThemeTypeEditor : public MarginContainer {
GDCLASS(ThemeTypeEditor, MarginContainer);

Expand Down

0 comments on commit 7b999ee

Please sign in to comment.