Skip to content

Commit 84e278c

Browse files
committed
Tweak script editor zoom presets to be more useful
The presets are now 50%, 75%, 90%, 100%, 110%, 125%, 150%. This also mentions Ctrl + mouse wheel in the tooltip.
1 parent e25f3c0 commit 84e278c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

editor/code_editor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ FindReplaceBar::FindReplaceBar() {
798798

799799
/*** CODE EDITOR ****/
800800

801-
static constexpr float ZOOM_FACTOR_PRESETS[7] = { 0.25f, 0.5f, 0.75f, 1.0f, 1.5f, 2.0f, 3.0f };
801+
static constexpr float ZOOM_FACTOR_PRESETS[8] = { 0.5f, 0.75f, 0.9f, 1.0f, 1.1f, 1.25f, 1.5f, 2.0f };
802802

803803
// This function should be used to handle shortcuts that could otherwise
804804
// be handled too late if they weren't handled here.
@@ -1690,8 +1690,7 @@ void CodeTextEditor::_zoom_to(float p_zoom_factor) {
16901690
}
16911691

16921692
void CodeTextEditor::set_zoom_factor(float p_zoom_factor) {
1693-
int preset_count = sizeof(ZOOM_FACTOR_PRESETS) / sizeof(float);
1694-
zoom_factor = CLAMP(p_zoom_factor, ZOOM_FACTOR_PRESETS[0], ZOOM_FACTOR_PRESETS[preset_count - 1]);
1693+
zoom_factor = CLAMP(p_zoom_factor, 0.25f, 3.0f);
16951694
int neutral_font_size = int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE;
16961695
int new_font_size = Math::round(zoom_factor * neutral_font_size);
16971696

@@ -1815,7 +1814,8 @@ CodeTextEditor::CodeTextEditor() {
18151814
status_bar->add_child(zoom_button);
18161815
zoom_button->set_flat(true);
18171816
zoom_button->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
1818-
zoom_button->set_tooltip_text(TTR("Zoom factor"));
1817+
zoom_button->set_tooltip_text(
1818+
TTR("Zoom factor") + "\n" + vformat(TTR("%sMouse wheel, %s/%s: Finetune\n%s: Reset"), keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL), ED_GET_SHORTCUT("script_editor/zoom_in")->get_as_text(), ED_GET_SHORTCUT("script_editor/zoom_out")->get_as_text(), ED_GET_SHORTCUT("script_editor/reset_zoom")->get_as_text()));
18191819
zoom_button->set_text("100 %");
18201820

18211821
PopupMenu *zoom_menu = zoom_button->get_popup();

0 commit comments

Comments
 (0)