Update scrollbar on resize (and on startup)

This commit is contained in:
Twan van Laarhoven
2020-05-12 02:07:42 +02:00
parent 7cf5531efd
commit bc53730091
+4
View File
@@ -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);
}