Fix #11: Gallery list best size: Invalidate cache and don't use DoGetBestClientSize

Revert "Cleanup: use DoGetBestClientSize"
This reverts commit 5700005243.

DoGetBestClient size is a nice idea, but it doesn't take scrollbars into account.
This commit is contained in:
Twan van Laarhoven
2020-04-30 20:14:25 +02:00
parent 06471e5231
commit 77e2ff8fd7
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -83,6 +83,7 @@ void GalleryList::update() {
} }
updateScrollbar(); updateScrollbar();
Refresh(false); Refresh(false);
InvalidateBestSize();
} }
size_t GalleryList::findItem(const wxMouseEvent& ev) const { 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 w = item_size.x + 2*MARGIN + 2*BORDER;
const int h = item_size.y + 2*MARGIN + 2*BORDER; const int h = item_size.y + 2*MARGIN + 2*BORDER;
if (direction == wxHORIZONTAL) { if (direction == wxHORIZONTAL) {
return wxSize(w, h * (int)column_count); return wxSize(w, h * (int)column_count) + ws - cs;
} else { } else {
return wxSize(w * (int)column_count, h); return wxSize(w * (int)column_count, h) + ws - cs;
} }
} }
+1 -1
View File
@@ -71,7 +71,7 @@ class GalleryList : public wxPanel {
virtual void onSelect(size_t item, size_t col, bool& changes) {} virtual void onSelect(size_t item, size_t col, bool& changes) {}
/// Return the desired size of control /// Return the desired size of control
virtual wxSize DoGetBestClientSize() const; virtual wxSize DoGetBestSize() const;
/// Information on the subcolumns. These are columns inside items /// Information on the subcolumns. These are columns inside items
struct SubColumn { struct SubColumn {