From 53e05969aa3863786c9b435befe43e92c59d64ec Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Sat, 21 Sep 2024 21:00:05 -0700 Subject: [PATCH] Add editor setting to enable or disable zooming with ctrl+ Mouse wheel add tool tip for windows and mac Co-authored-by: Stronkkey --- doc/classes/EditorSettings.xml | 6 ++++++ editor/code_editor.cpp | 7 +++++-- editor/code_editor.h | 1 + editor/editor_settings.cpp | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 940fec4688d..c50588be557 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1245,6 +1245,12 @@ The speed of scrolling in lines per second when [member text_editor/behavior/navigation/smooth_scrolling] is [code]true[/code]. Higher values make the script scroll by faster when using the mouse wheel. [b]Note:[/b] You can hold down [kbd]Alt[/kbd] while using the mouse wheel to temporarily scroll 5 times faster. + + If [code]true[/code], allows zooming in the script and text-based shader editor with + [kbd]Windows: Ctrl + Scroll wheel[/kbd]. + [kbd]Mac: CMD + Scroll wheel[/kbd]. + [kbd]Linux: Option + Scroll wheel[/kbd]. + If [code]true[/code], uses [NodePath] instead of [String] when appropriate for code autocompletion or for drag and dropping object properties into the script editor. diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d97293329a5..d1a87290e21 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -882,7 +882,7 @@ void CodeTextEditor::input(const Ref &event) { void CodeTextEditor::_text_editor_gui_input(const Ref &p_event) { Ref mb = p_event; - if (mb.is_valid()) { + if (mb.is_valid() && zoom_shortcut_enabled) { if (mb->is_pressed() && mb->is_command_or_control_pressed()) { if (mb->get_button_index() == MouseButton::WHEEL_UP) { _zoom_in(); @@ -898,7 +898,7 @@ void CodeTextEditor::_text_editor_gui_input(const Ref &p_event) { } Ref magnify_gesture = p_event; - if (magnify_gesture.is_valid()) { + if (magnify_gesture.is_valid() && zoom_shortcut_enabled) { _zoom_to(zoom_factor * powf(magnify_gesture->get_factor(), 0.25f)); accept_event(); return; @@ -1099,6 +1099,9 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_use_custom_word_separators(EDITOR_GET("text_editor/behavior/navigation/use_custom_word_separators")); text_editor->set_custom_word_separators(EDITOR_GET("text_editor/behavior/navigation/custom_word_separators")); + // Behavior: Zoom + zoom_shortcut_enabled = EDITOR_GET("text_editor/behavior/zoom/zoom_scroll_shortcut"); + // Behavior: Indent set_indent_using_spaces(EDITOR_GET("text_editor/behavior/indent/type")); text_editor->set_indent_size(EDITOR_GET("text_editor/behavior/indent/size")); diff --git a/editor/code_editor.h b/editor/code_editor.h index c1c65a2a4a5..cfdccefc38b 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -177,6 +177,7 @@ class CodeTextEditor : public VBoxContainer { bool code_complete_enabled = true; Timer *code_complete_timer = nullptr; int code_complete_timer_line = 0; + bool zoom_shortcut_enabled = true; float zoom_factor = 1.0f; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 963c45b5735..ce8aa65a976 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -696,6 +696,9 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save", true); _initial_set("text_editor/behavior/files/open_dominant_script_on_scene_change", false, true); + // Behavior: Zoom + _initial_set("text_editor/behavior/zoom/zoom_scroll_shortcut", true); + // Script list _initial_set("text_editor/script_list/show_members_overview", true, true); _initial_set("text_editor/script_list/sort_members_outline_alphabetically", false, true);