diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-08-21 22:19:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-21 22:19:18 +0200 |
commit | 328452e028480d85ea06de56eb46b36bc35f3424 (patch) | |
tree | 02e69656ad828e033b840ac75d1cceb139104e92 | |
parent | 7cbcc913b4651d7743dd3e0eadcb7ca3c05861a2 (diff) | |
parent | d6599fde0ae8e6d224c3449629917ecd5076480c (diff) |
Merge pull request #10508 from Paulb23/increase_smooth_scroll_speed
Increased smooth scroll speed and added user setting
-rw-r--r-- | editor/code_editor.cpp | 1 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 14 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 4 |
4 files changed, 19 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index c33340ce69..a809f4b15e 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1088,6 +1088,7 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter")); text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret")); text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling")); + text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed")); } void CodeTextEditor::set_error(const String &p_error) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 46135e80ae..5c8e166730 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -616,6 +616,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10"); set("text_editor/open_scripts/smooth_scrolling", true); + set("text_editor/open_scripts/v_scroll_speed", 80); set("text_editor/open_scripts/show_members_overview", true); set("text_editor/files/trim_trailing_whitespace_on_save", false); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f99cbbad89..fa51099411 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -429,7 +429,7 @@ void TextEdit::_notification(int p_what) { if (scrolling && v_scroll->get_value() != target_v_scroll) { double target_y = target_v_scroll - v_scroll->get_value(); double dist = sqrt(target_y * target_y); - double vel = ((target_y / dist) * 50) * get_fixed_process_delta_time(); + double vel = ((target_y / dist) * v_scroll_speed) * get_fixed_process_delta_time(); if (vel >= dist) { v_scroll->set_value(target_v_scroll); @@ -4264,6 +4264,14 @@ bool TextEdit::is_smooth_scroll_enabled() const { return smooth_scroll_enabled; } +void TextEdit::set_v_scroll_speed(float p_speed) { + v_scroll_speed = p_speed; +} + +float TextEdit::get_v_scroll_speed() const { + return v_scroll_speed; +} + void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) { completion_prefixes.clear(); @@ -4766,6 +4774,8 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled); ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled); + ClassDB::bind_method(D_METHOD("set_v_scroll_speed", "speed"), &TextEdit::set_v_scroll_speed); + ClassDB::bind_method(D_METHOD("get_v_scroll_speed"), &TextEdit::get_v_scroll_speed); ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color); ClassDB::bind_method(D_METHOD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false)); @@ -4777,6 +4787,7 @@ void TextEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed"); ADD_GROUP("Caret", "caret_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode"); @@ -4916,6 +4927,7 @@ TextEdit::TextEdit() { smooth_scroll_enabled = false; scrolling = false; target_v_scroll = 0; + v_scroll_speed = 80; raised_from_completion = false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c4e0700531..d942f521cd 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -259,6 +259,7 @@ class TextEdit : public Control { bool smooth_scroll_enabled; bool scrolling; float target_v_scroll; + float v_scroll_speed; bool raised_from_completion; @@ -494,6 +495,9 @@ public: void set_smooth_scroll_enabled(bool p_enable); bool is_smooth_scroll_enabled() const; + void set_v_scroll_speed(float p_speed); + float get_v_scroll_speed() const; + uint32_t get_version() const; uint32_t get_saved_version() const; void tag_saved_version(); |