summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorBernhard Liebl <Bernhard.Liebl@gmx.org>2017-12-28 15:49:37 +0100
committerBernhard Liebl <Bernhard.Liebl@gmx.org>2017-12-28 15:49:37 +0100
commitd640542f6d891a9385138a580f298054ff8bb216 (patch)
treed2d6462eedfff23a8fa22a75338318664e0ddef5 /scene/gui
parenta663dbfdd8465d45a03e4880c0d907334236b260 (diff)
Remove some lagginess from TextEdit's smooth scrolling
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/text_edit.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 0fba4a6f94..759c9cb815 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3119,6 +3119,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
void TextEdit::_scroll_up(real_t p_delta) {
+ if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta))
+ scrolling = false;
+
if (scrolling) {
target_v_scroll = (target_v_scroll - p_delta);
} else {
@@ -3129,8 +3132,12 @@ void TextEdit::_scroll_up(real_t p_delta) {
if (target_v_scroll <= 0) {
target_v_scroll = 0;
}
- scrolling = true;
- set_physics_process(true);
+ if (Math::abs(target_v_scroll - v_scroll->get_value()) < 1.0) {
+ v_scroll->set_value(target_v_scroll);
+ } else {
+ scrolling = true;
+ set_physics_process(true);
+ }
} else {
v_scroll->set_value(target_v_scroll);
}
@@ -3138,6 +3145,9 @@ void TextEdit::_scroll_up(real_t p_delta) {
void TextEdit::_scroll_down(real_t p_delta) {
+ if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(p_delta))
+ scrolling = false;
+
if (scrolling) {
target_v_scroll = (target_v_scroll + p_delta);
} else {
@@ -3154,8 +3164,13 @@ void TextEdit::_scroll_down(real_t p_delta) {
if (target_v_scroll > max_v_scroll) {
target_v_scroll = max_v_scroll;
}
- scrolling = true;
- set_physics_process(true);
+
+ if (Math::abs(target_v_scroll - v_scroll->get_value()) < 1.0) {
+ v_scroll->set_value(target_v_scroll);
+ } else {
+ scrolling = true;
+ set_physics_process(true);
+ }
} else {
v_scroll->set_value(target_v_scroll);
}