Skip to content

Commit

Permalink
Add option to remove underline in Editor Docs
Browse files Browse the repository at this point in the history
Adds "text_editor/help/show_meta_underline" Editor Setting, enabled by default.
When disabled, all meta words will still change cursor shape on hover.
  • Loading branch information
Mickeon committed Aug 25, 2022
1 parent d0a2a4c commit eea25b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ void EditorHelp::_update_doc() {
method_line.clear();
section_line.clear();

class_desc->set_meta_underline(EditorSettings::get_singleton()->get_setting("text_editor/help/show_meta_underline"));

_update_theme();
String link_color_text = title_color.to_html(false);

Expand Down Expand Up @@ -1985,6 +1987,14 @@ void EditorHelp::_toggle_scripts_pressed() {
update_toggle_scripts_button();
}

void EditorHelp::_meta_hover_started(Variant p_meta) {
// TODO: Very cool meta tooltips.
class_desc->set_default_cursor_shape(CURSOR_POINTING_HAND);
}
void EditorHelp::_meta_hover_ended(Variant p_meta) {
class_desc->set_default_cursor_shape(CURSOR_ARROW);
}

void EditorHelp::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY:
Expand Down Expand Up @@ -2105,6 +2115,11 @@ EditorHelp::EditorHelp() {
class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select));
class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input));
class_desc->connect("resized", callable_mp(this, &EditorHelp::_class_desc_resized).bind(false));

// Change cursor shape, even if meta_underline is disabled.
class_desc->connect("meta_hover_started", callable_mp(this, &EditorHelp::_meta_hover_started)); //.unbind(1));
class_desc->connect("meta_hover_ended", callable_mp(this, &EditorHelp::_meta_hover_ended)); //.unbind(1));

_class_desc_resized(false);

// Added second so it opens at the bottom so it won't offset the entire widget.
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ class EditorHelp : public VBoxContainer {

String _fix_constant(const String &p_constant) const;
void _toggle_scripts_pressed();
void _meta_hover_started(Variant p_meta);
void _meta_hover_ended(Variant p_meta);

static Thread thread;

Expand Down
1 change: 1 addition & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_source_font_size", 14, "8,48,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_title_font_size", 23, "8,48,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/help/class_reference_examples", 0, "GDScript,C#,GDScript and C#")
_initial_set("text_editor/help/show_meta_underline", true);

/* Editors */

Expand Down

0 comments on commit eea25b7

Please sign in to comment.