diff options
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index dd8aa523c4..40b58d2c62 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -108,6 +108,7 @@ void FindReplaceBar::_notification(int p_what) { hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close"))); hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close"))); hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size()); + _update_toggle_replace_button(replace_text->is_visible_in_tree()); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -539,6 +540,14 @@ void FindReplaceBar::_hide_bar(bool p_force_focus) { hide(); } +void FindReplaceBar::_update_toggle_replace_button(bool p_replace_visible) { + String tooltip = p_replace_visible ? TTR("Hide Replace") : TTR("Show Replace"); + String shortcut = ED_GET_SHORTCUT(p_replace_visible ? "script_text_editor/find" : "script_text_editor/replace")->get_as_text(); + toggle_replace_button->set_tooltip_text(vformat("%s (%s)", tooltip, shortcut)); + StringName rtl_compliant_arrow = is_layout_rtl() ? SNAME("GuiTreeArrowLeft") : SNAME("GuiTreeArrowRight"); + toggle_replace_button->set_icon(get_editor_theme_icon(p_replace_visible ? SNAME("GuiTreeArrowDown") : rtl_compliant_arrow)); +} + void FindReplaceBar::_show_search(bool p_with_replace, bool p_show_only) { show(); if (p_show_only) { @@ -582,6 +591,7 @@ void FindReplaceBar::popup_search(bool p_show_only) { hbc_button_replace->hide(); hbc_option_replace->hide(); selection_only->set_pressed(false); + _update_toggle_replace_button(false); _show_search(false, p_show_only); } @@ -591,6 +601,7 @@ void FindReplaceBar::popup_replace() { replace_text->show(); hbc_button_replace->show(); hbc_option_replace->show(); + _update_toggle_replace_button(true); } selection_only->set_pressed(text_editor->has_selection(0) && text_editor->get_selection_from_line(0) < text_editor->get_selection_to_line(0)); @@ -644,6 +655,11 @@ void FindReplaceBar::_replace_text_submitted(const String &p_text) { } } +void FindReplaceBar::_toggle_replace_pressed() { + bool replace_visible = replace_text->is_visible_in_tree(); + replace_visible ? popup_search(true) : popup_replace(); +} + String FindReplaceBar::get_search_text() const { return search_text->get_text(); } @@ -702,6 +718,12 @@ void FindReplaceBar::_bind_methods() { } FindReplaceBar::FindReplaceBar() { + toggle_replace_button = memnew(Button); + add_child(toggle_replace_button); + toggle_replace_button->set_flat(true); + toggle_replace_button->set_focus_mode(FOCUS_NONE); + toggle_replace_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_toggle_replace_pressed)); + vbc_lineedit = memnew(VBoxContainer); add_child(vbc_lineedit); vbc_lineedit->set_alignment(BoxContainer::ALIGNMENT_CENTER); @@ -798,7 +820,7 @@ FindReplaceBar::FindReplaceBar() { /*** CODE EDITOR ****/ -static constexpr float ZOOM_FACTOR_PRESETS[7] = { 0.25f, 0.5f, 0.75f, 1.0f, 1.5f, 2.0f, 3.0f }; +static constexpr float ZOOM_FACTOR_PRESETS[8] = { 0.5f, 0.75f, 0.9f, 1.0f, 1.1f, 1.25f, 1.5f, 2.0f }; // This function should be used to handle shortcuts that could otherwise // be handled too late if they weren't handled here. @@ -1068,6 +1090,9 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_draw_spaces(EDITOR_GET("text_editor/appearance/whitespace/draw_spaces")); text_editor->add_theme_constant_override("line_spacing", EDITOR_GET("text_editor/appearance/whitespace/line_spacing")); + // Behavior: General + text_editor->set_empty_selection_clipboard_enabled(EDITOR_GET("text_editor/behavior/general/empty_selection_clipboard")); + // Behavior: Navigation text_editor->set_scroll_past_end_of_file_enabled(EDITOR_GET("text_editor/behavior/navigation/scroll_past_end_of_file")); text_editor->set_smooth_scroll_enabled(EDITOR_GET("text_editor/behavior/navigation/smooth_scrolling")); @@ -1694,8 +1719,7 @@ void CodeTextEditor::_zoom_to(float p_zoom_factor) { } void CodeTextEditor::set_zoom_factor(float p_zoom_factor) { - int preset_count = sizeof(ZOOM_FACTOR_PRESETS) / sizeof(float); - zoom_factor = CLAMP(p_zoom_factor, ZOOM_FACTOR_PRESETS[0], ZOOM_FACTOR_PRESETS[preset_count - 1]); + zoom_factor = CLAMP(p_zoom_factor, 0.25f, 3.0f); int neutral_font_size = int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE; int new_font_size = Math::round(zoom_factor * neutral_font_size); @@ -1821,7 +1845,8 @@ CodeTextEditor::CodeTextEditor() { status_bar->add_child(zoom_button); zoom_button->set_flat(true); zoom_button->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); - zoom_button->set_tooltip_text(TTR("Zoom factor")); + zoom_button->set_tooltip_text( + 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())); zoom_button->set_text("100 %"); PopupMenu *zoom_menu = zoom_button->get_popup(); |