GameBrowser: Resize the grid cells when the icon size changes under the popup

The screen under a popup is only laid out, not recreated, so the grid kept the
cell size it was created with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-06 21:23:18 +01:00
1 parent 9c7125b55c
commit 334115da49
3 files changed
+21 -1

No files matched your search

+5
View File
@@ -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_;
+13 -1
View File
@@ -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);
+3
View File
@@ -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_;