From 2900553a43f0075fa5fa47e32efab7ec936f909f Mon Sep 17 00:00:00 2001 From: av-dx Date: Thu, 3 Jun 2021 20:00:49 +0530 Subject: [PATCH] GUI: Reflow Grid when window size changes --- gui/widget.cpp | 26 ++++++++++++++++++++++++++ gui/widget.h | 1 + 2 files changed, 27 insertions(+) diff --git a/gui/widget.cpp b/gui/widget.cpp index 8ed74f8ea99..a2ce2193cae 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -1270,6 +1270,32 @@ void GridWidget::handleMouseWheel(int x, int y, int direction) { markAsDirty(); } +void GridWidget::reflowLayout() { + Widget::reflowLayout(); + int row = 0, col = 0; + int entriesPerRow = MAX((((int)_w-100) / kThumbnailWidth) -1 , 0); + int k = 0; + for (Common::Array::iterator i = _entries.begin(); i != _entries.end(); ++i) { + k = row * entriesPerRow + col; + if (*i) { + (*i)->_thumb->setPos(50 + col * (kThumbnailWidth + 50), _scrollPos + 50 + row * (kThumbnailHeight + 80)); + (*i)->_plat->setPos(kThumbnailWidth + 50 - 32 + col * (kThumbnailWidth + 50), _scrollPos + 50 + row * (kThumbnailHeight + 80)+ kThumbnailHeight-32); + (*i)->_lang->setPos(kThumbnailWidth + 50 - 32 + col * (kThumbnailWidth + 50), _scrollPos + 50 + row * (kThumbnailHeight + 80)); + (*i)->_title->setPos(50 + col * (kThumbnailWidth + 50), _scrollPos + 50 + row * (kThumbnailHeight + 80) + kThumbnailHeight); + + (*i)->setPos(50 + col * (kThumbnailWidth + 50), _scrollPos + 50 + row * (kThumbnailHeight + 80)); + // newEntry = new EntryContainerWidget(this, 50 + col * (kThumbnailWidth + 50), 50 + row * (kThumbnailHeight + 80), kThumbnailWidth, kThumbnailHeight+kLineHeight*2); + + if (++col >= entriesPerRow) { + ++row; + col = 0; + } + ++k; + } + } + markAsDirty(); +} + #pragma mark - OptionsContainerWidget::OptionsContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogLayout, diff --git a/gui/widget.h b/gui/widget.h index e6fad6cfd3c..afe6fc037ab 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -524,6 +524,7 @@ public: int getLoadedNumber(void) {return _loadedSurfaces.size();} void reloadThumbnails(); void handleMouseWheel(int x, int y, int direction) override; + void reflowLayout() override; int selectedEntry;