diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index 78084527c3..f71c4331b3 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -327,6 +327,11 @@ public: void SetPadding(const Margins &padding) { padding_ = padding; } + // Takes effect at the next layout. + void SetCellSize(int columnWidth, int rowHeight) { + settings_.columnWidth = columnWidth; + settings_.rowHeight = rowHeight; + } private: GridLayoutSettings settings_; diff --git a/UI/GameBrowser.cpp b/UI/GameBrowser.cpp index 83d6ae0a84..d752af6314 100644 --- a/UI/GameBrowser.cpp +++ b/UI/GameBrowser.cpp @@ -302,6 +302,15 @@ void GameBrowser::Update() { } } +void GameBrowser::Measure(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert) { + // Under a popup (like the one with the icon size buttons), the screen isn't recreated or updated, + // only laid out, so the grid picks up a new size here. + if (gameGrid_) { + gameGrid_->SetCellSize(150 * g_Config.fGameGridScale, 85 * g_Config.fGameGridScale); + } + LinearLayout::Measure(dc, horiz, vert); +} + void GameBrowser::Draw(UIContext &dc) { using namespace UI; @@ -396,6 +405,7 @@ void GameBrowser::Refresh() { auto mm = GetI18NCategory(I18NCat::MAINMENU); gameList_ = nullptr; + gameGrid_ = nullptr; LinearLayout *topBar = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(0, 12, 8, 0))); Add(topBar); @@ -490,7 +500,9 @@ void GameBrowser::Refresh() { gridSettingsChoice->OnClick.Handle(this, &GameBrowser::GridSettingsClick); if (gridStyle) { - gameList_ = new UI::GridLayoutList(UI::GridLayoutSettings(150 * g_Config.fGameGridScale, 85 * g_Config.fGameGridScale), new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(0, 0, 6, 0))); + // Measure sets the cell size. + gameGrid_ = new UI::GridLayoutList(UI::GridLayoutSettings(), new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(0, 0, 6, 0))); + gameList_ = gameGrid_; } else { UI::LinearLayout *gl = new UI::LinearLayoutList(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); gl->SetSpacing(4.0f); diff --git a/UI/GameBrowser.h b/UI/GameBrowser.h index b610f754d7..0f429ac243 100644 --- a/UI/GameBrowser.h +++ b/UI/GameBrowser.h @@ -46,6 +46,7 @@ public: bool Key(const KeyInput &key) override; bool Touch(const TouchInput &input) override; void SetSearchFilter(const std::string &filter, bool setKeyboardFocus); + void Measure(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert) override; void Draw(UIContext &dc) override; void Update() override; void RequestRefresh() { @@ -86,6 +87,8 @@ private: void OnHomebrewStore(UI::EventParams &e); UI::ViewGroup *gameList_ = nullptr; + // Same as gameList_ in the grid view, else null. + UI::GridLayoutList *gameGrid_ = nullptr; PathBrowser path_; int *viewMode_ = nullptr; BrowseFlags browseFlags_;