From d15e9c2126f22203e7472c190138c718229847cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=27dreamsComeTrue=27=20Jasi=C5=84ski?= Date: Wed, 19 Feb 2020 20:12:07 +0100 Subject: [PATCH] Allow scroll_to_line when scroll_active is 'false' Fix #36134 (cherry picked from commit 8f11a91917bc85976390477712dc4202ab383fe7) --- scene/gui/rich_text_label.cpp | 3 ++- scene/gui/scroll_bar.cpp | 8 ++++++++ scene/gui/scroll_bar.h | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 5de9ae7ac6a..82fd8df1549 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -870,7 +870,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & void RichTextLabel::_scroll_changed(double) { - if (updating_scroll || !scroll_active) + if (updating_scroll) return; if (scroll_follow && vscroll->get_value() >= (vscroll->get_max() - vscroll->get_page())) @@ -2009,6 +2009,7 @@ void RichTextLabel::set_scroll_active(bool p_active) { return; scroll_active = p_active; + vscroll->set_drag_node_enabled(p_active); update(); } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 45fa2128865..f42260d997b 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -545,6 +545,9 @@ void ScrollBar::_drag_node_exit() { } void ScrollBar::_drag_node_input(const Ref &p_input) { + if (!drag_node_enabled) { + return; + } Ref mb = p_input; @@ -638,6 +641,10 @@ NodePath ScrollBar::get_drag_node() const { return drag_node_path; } +void ScrollBar::set_drag_node_enabled(bool p_enable) { + drag_node_enabled = p_enable; +} + void ScrollBar::set_smooth_scroll_enabled(bool p_enable) { smooth_scroll_enabled = p_enable; } @@ -668,6 +675,7 @@ ScrollBar::ScrollBar(Orientation p_orientation) { drag.active = false; + drag_node_enabled = true; drag_node_speed = Vector2(); drag_node_touching = false; drag_node_touching_deaccel = false; diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index ee5e7140cf7..6a68aa8bea6 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -53,7 +53,6 @@ class ScrollBar : public Range { HighlightStatus highlight; struct Drag { - bool active; float pos_at_click; float value_at_click; @@ -70,6 +69,7 @@ class ScrollBar : public Range { Node *drag_node; NodePath drag_node_path; + bool drag_node_enabled; Vector2 drag_node_speed; Vector2 drag_node_accum; @@ -101,6 +101,7 @@ public: void set_drag_node(const NodePath &p_path); NodePath get_drag_node() const; + void set_drag_node_enabled(bool p_enable); void set_smooth_scroll_enabled(bool p_enable); bool is_smooth_scroll_enabled() const;