diff options
author | Paulb23 <p_batty@hotmail.co.uk> | 2017-08-21 19:13:24 +0100 |
---|---|---|
committer | Paulb23 <p_batty@hotmail.co.uk> | 2017-08-21 19:20:11 +0100 |
commit | d6599fde0ae8e6d224c3449629917ecd5076480c (patch) | |
tree | 7a06fe64ce0ce76fe83f0e772fb2ae965f63d3d8 /scene | |
parent | 1be30f35a68a9fb2c156ded45c8689cc44f26f29 (diff) |
Increased smooth scroll speed and added user setting
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 14 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 4 |
2 files changed, 17 insertions, 1 deletions
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(); |