From 56a74fb5dd8d42b96c00e3a8602221fabe5eadfe Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 6 Apr 2022 19:58:41 -0400 Subject: improve scrolling behavior again, refactor scrolling is almost exactly how i want it, but when an existing message's height allocation is changed it still causes the scroll position to change, but its not that bad and is better than what i had before anyways so it is good enough for now. ideally if you are scrolled in the middle it will stay put completely --- src/components/chatlist.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/components/chatlist.hpp') diff --git a/src/components/chatlist.hpp b/src/components/chatlist.hpp index 783474a..f77bbd6 100644 --- a/src/components/chatlist.hpp +++ b/src/components/chatlist.hpp @@ -26,8 +26,11 @@ public: void ActuallyRemoveMessage(Snowflake id); // perhaps not the best method name private: - void OnUpperAdjustmentChanged(); + void SetupMenu(); void ScrollToBottom(); + void OnVAdjustmentValueChanged(); + void OnVAdjustmentUpperChanged(); + void OnListSizeAllocate(Gtk::Allocation &allocation); void RemoveMessageAndHeader(Gtk::Widget *widget); bool m_use_pinned_menu = false; @@ -48,14 +51,14 @@ private: int m_num_rows = 0; std::map m_id_to_widget; + bool m_ignore_next_upper = false; + double m_old_upper = -1.0; bool m_should_scroll_to_bottom = true; Gtk::ListBox m_list; bool m_separate_all = false; Glib::Timer m_history_timer; - bool m_needs_upper_adjustment = false; - double m_old_upper = -1.0; public: // these are all forwarded by the parent @@ -93,7 +96,6 @@ private: template inline void ChatList::SetMessages(Iter begin, Iter end) { - m_needs_upper_adjustment = false; Clear(); m_num_rows = 0; m_num_messages = 0; @@ -107,7 +109,6 @@ inline void ChatList::SetMessages(Iter begin, Iter end) { template inline void ChatList::PrependMessages(Iter begin, Iter end) { - m_needs_upper_adjustment = true; for (Iter it = begin; it != end; it++) ProcessNewMessage(*it, true); } -- cgit v1.2.3