From bc537300919926d185cb314921dcb3acea01ff0e Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Tue, 12 May 2020 02:07:42 +0200 Subject: [PATCH] Update scrollbar on resize (and on startup) --- src/gui/set/console_panel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/set/console_panel.cpp b/src/gui/set/console_panel.cpp index f8f8c784..a03062b4 100644 --- a/src/gui/set/console_panel.cpp +++ b/src/gui/set/console_panel.cpp @@ -187,6 +187,10 @@ class MessageCtrl : public wxPanel { void update_scrollbar() { int screen_height = GetClientSize().y; int total_height = messages.empty() ? 0 : messages.back()->bottom(); + // update view_start to keep messages in view + int bottom = total_height - GetClientSize().y; + view_start = min(bottom, view_start); + view_start = max(0, view_start); SetScrollbar(wxVERTICAL, view_start, screen_height, total_height); }