From 77e2ff8fd7ca351a28abe39a1424aafaf1fe8658 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Thu, 30 Apr 2020 20:14:25 +0200 Subject: [PATCH] Fix #11: Gallery list best size: Invalidate cache and don't use DoGetBestClientSize Revert "Cleanup: use DoGetBestClientSize" This reverts commit 5700005243d903a3135a005527d858313dee8734. DoGetBestClient size is a nice idea, but it doesn't take scrollbars into account. --- src/gui/control/gallery_list.cpp | 8 +++++--- src/gui/control/gallery_list.hpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/control/gallery_list.cpp b/src/gui/control/gallery_list.cpp index c302e68c..093751d7 100644 --- a/src/gui/control/gallery_list.cpp +++ b/src/gui/control/gallery_list.cpp @@ -83,6 +83,7 @@ void GalleryList::update() { } updateScrollbar(); Refresh(false); + InvalidateBestSize(); } size_t GalleryList::findItem(const wxMouseEvent& ev) const { @@ -263,13 +264,14 @@ void GalleryList::onChar(wxKeyEvent& ev) { } } -wxSize GalleryList::DoGetBestClientSize() const { +wxSize GalleryList::DoGetBestSize() const { + wxSize ws = GetSize(), cs = GetClientSize(); const int w = item_size.x + 2*MARGIN + 2*BORDER; const int h = item_size.y + 2*MARGIN + 2*BORDER; if (direction == wxHORIZONTAL) { - return wxSize(w, h * (int)column_count); + return wxSize(w, h * (int)column_count) + ws - cs; } else { - return wxSize(w * (int)column_count, h); + return wxSize(w * (int)column_count, h) + ws - cs; } } diff --git a/src/gui/control/gallery_list.hpp b/src/gui/control/gallery_list.hpp index 1630cf89..33c6bb72 100644 --- a/src/gui/control/gallery_list.hpp +++ b/src/gui/control/gallery_list.hpp @@ -71,7 +71,7 @@ class GalleryList : public wxPanel { virtual void onSelect(size_t item, size_t col, bool& changes) {} /// Return the desired size of control - virtual wxSize DoGetBestClientSize() const; + virtual wxSize DoGetBestSize() const; /// Information on the subcolumns. These are columns inside items struct SubColumn {