GUI: Add slider for Grid Launcher icon size

This commit is contained in:
Thierry Crozat 2022-06-04 01:06:34 +01:00
parent 7edae880f8
commit 5ea034391b
15 changed files with 87 additions and 59 deletions

View file

@ -350,6 +350,7 @@ void registerDefaults() {
ConfMan.registerDefault("gui_browser_native", true); ConfMan.registerDefault("gui_browser_native", true);
ConfMan.registerDefault("gui_return_to_launcher_at_exit", false); ConfMan.registerDefault("gui_return_to_launcher_at_exit", false);
ConfMan.registerDefault("gui_launcher_chooser", "list"); ConfMan.registerDefault("gui_launcher_chooser", "list");
ConfMan.registerDefault("grid_items_per_row", 4);
// Specify threshold for scanning directories in the launcher // Specify threshold for scanning directories in the launcher
// If number of game entries in scummvm.ini exceeds the specified // If number of game entries in scummvm.ini exceeds the specified
// number, then skip scanning. -1 = scan always // number, then skip scanning. -1 = scan always

View file

@ -36,7 +36,7 @@
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.9.4" #define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.9.5"
class OSystem; class OSystem;

View file

@ -930,6 +930,8 @@ protected:
void build() override; void build() override;
private: private:
GridWidget *_grid; GridWidget *_grid;
SliderWidget *_gridItemSizeSlider;
StaticTextWidget *_gridItemSizeLabel;
}; };
#endif // !DISABLE_LAUNCHERDISPLAY_GRID #endif // !DISABLE_LAUNCHERDISPLAY_GRID
@ -1303,7 +1305,7 @@ void LauncherSimple::updateButtons() {
#ifndef DISABLE_LAUNCHERDISPLAY_GRID #ifndef DISABLE_LAUNCHERDISPLAY_GRID
LauncherGrid::LauncherGrid(const Common::String &title, LauncherChooser *chooser) LauncherGrid::LauncherGrid(const Common::String &title, LauncherChooser *chooser)
: LauncherDialog(title, chooser), : LauncherDialog(title, chooser),
_grid(nullptr) { _grid(nullptr), _gridItemSizeSlider(nullptr), _gridItemSizeLabel(nullptr) {
build(); build();
} }
@ -1468,6 +1470,13 @@ void LauncherGrid::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
} }
break; break;
} }
case kItemSizeCmd:
_gridItemSizeLabel->setValue(_gridItemSizeSlider->getValue());
_gridItemSizeLabel->markAsDirty();
ConfMan.setInt("grid_items_per_row", _gridItemSizeSlider->getValue());
ConfMan.flushToDisk();
reflowLayout();
break;
default: default:
LauncherDialog::handleCommand(sender, cmd, data); LauncherDialog::handleCommand(sender, cmd, data);
} }
@ -1584,6 +1593,14 @@ int LauncherGrid::getSelected() { return _grid->getSelected(); }
void LauncherGrid::build() { void LauncherGrid::build() {
LauncherDialog::build(); LauncherDialog::build();
new StaticTextWidget(this, "LauncherGrid.GridItemsPerRowDesc", _("Icons per row:"));
_gridItemSizeSlider = new SliderWidget(this, "LauncherGrid.GridItemsPerRow", Common::U32String(), kItemSizeCmd);
_gridItemSizeSlider->setMinValue(1);
_gridItemSizeSlider->setMaxValue(12);
_gridItemSizeSlider->setValue(ConfMan.getInt("grid_items_per_row"));
_gridItemSizeLabel = new StaticTextWidget(this, "LauncherGrid.GridItemsPerRowLabel", Common::U32String(" "), Common::U32String(), ThemeEngine::kFontStyleBold, Common::UNK_LANG, false);
_gridItemSizeLabel->setValue(ConfMan.getInt("grid_items_per_row"));
// Add list with game titles // Add list with game titles
_grid = new GridWidget(this, "LauncherGrid.IconArea"); _grid = new GridWidget(this, "LauncherGrid.IconArea");
// Populate the list // Populate the list

View file

@ -69,22 +69,10 @@
<def var = 'Radiobutton.Spacing' value = '15' scalable = 'yes'/> <def var = 'Radiobutton.Spacing' value = '15' scalable = 'yes'/>
<def var = 'GridSupported' value = '1'/> <def var = 'GridSupported' value = '1'/>
<def var = 'GridItemThumbnail.Width' value = '192' scalable = 'no' resolution = 'x>640' />
<def var = 'GridItemThumbnail.Height' value = '192' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.FlagIcon.Width' value = '50' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.FlagIcon.Height' value = '25' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.PlatformIcon.Width' value = '32' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.PlatformIcon.Height' value = '32' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.XSpacing' value = '40' scalable = 'no' resolution = 'x>640' /> <def var = 'Grid.XSpacing' value = '40' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.YSpacing' value = '30' scalable = 'no' resolution = 'x>640' /> <def var = 'Grid.YSpacing' value = '30' scalable = 'no' resolution = 'x>640' />
<def var = 'Grid.ShowTitles' value = '1' scalable = 'no' resolution = 'x>640' /> <def var = 'Grid.ShowTitles' value = '1' scalable = 'no' resolution = 'x>640' />
<def var = 'GridItemThumbnail.Width' value = '96' scalable = 'no' resolution = 'x<641' />
<def var = 'GridItemThumbnail.Height' value = '96' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.FlagIcon.Width' value = '25' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.FlagIcon.Height' value = '12' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.PlatformIcon.Width' value = '16' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.PlatformIcon.Height' value = '16' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.XSpacing' value = '20' scalable = 'no' resolution = 'x<641' /> <def var = 'Grid.XSpacing' value = '20' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.YSpacing' value = '15' scalable = 'no' resolution = 'x<641' /> <def var = 'Grid.YSpacing' value = '15' scalable = 'no' resolution = 'x<641' />
<def var = 'Grid.ShowTitles' value = '1' scalable = 'no' resolution = 'x<641' /> <def var = 'Grid.ShowTitles' value = '1' scalable = 'no' resolution = 'x<641' />
@ -321,6 +309,16 @@
height = 'Globals.Button.Height' height = 'Globals.Button.Height'
width = 'Globals.Button.Height' width = 'Globals.Button.Height'
/> />
<widget name = 'GridItemsPerRowDesc'
type = 'OptionsLabel'
/>
<widget name = 'GridItemsPerRow'
type = 'Slider'
rtl = 'no'
/>
<widget name = 'GridItemsPerRowLabel'
type = 'SmallLabel'
/>
<space /> <space />
</layout> </layout>
</layout> </layout>

View file

@ -62,12 +62,6 @@
<def var = 'Radiobutton.Spacing' value = '5' scalable = 'yes'/> <def var = 'Radiobutton.Spacing' value = '5' scalable = 'yes'/>
<def var = 'GridSupported' value = '0'/> <def var = 'GridSupported' value = '0'/>
<def var = 'GridItemThumbnail.Width' value = '128' scalable = 'no'/>
<def var = 'GridItemThumbnail.Height' value = '128' scalable = 'no'/>
<def var = 'Grid.FlagIcon.Width' value = '30' scalable = 'no'/>
<def var = 'Grid.FlagIcon.Height' value = '15' scalable = 'no'/>
<def var = 'Grid.PlatformIcon.Width' value = '24' scalable = 'no'/>
<def var = 'Grid.PlatformIcon.Height' value = '24' scalable = 'no'/>
<def var = 'Grid.XSpacing' value = '20' scalable = 'no'/> <def var = 'Grid.XSpacing' value = '20' scalable = 'no'/>
<def var = 'Grid.YSpacing' value = '10' scalable = 'no'/> <def var = 'Grid.YSpacing' value = '10' scalable = 'no'/>
<def var = 'Grid.ShowTitles' value = '0' scalable = 'no'/> <def var = 'Grid.ShowTitles' value = '0' scalable = 'no'/>
@ -253,6 +247,15 @@
height = 'Globals.Button.Height' height = 'Globals.Button.Height'
width = 'Globals.Button.Height' width = 'Globals.Button.Height'
/> />
<widget name = 'GridItemsPerRowDesc'
type = 'OptionsLabel'
/>
<widget name = 'GridItemsPerRow'
type = 'Slider'
/>
<widget name = 'GridItemsPerRowLabel'
type = 'SmallLabel'
/>
</layout> </layout>
<widget name = 'GameList'/> <widget name = 'GameList'/>
<widget name = 'IconArea'/> <widget name = 'IconArea'/>

Binary file not shown.

View file

@ -1,3 +1,3 @@
[SCUMMVM_STX0.9.4:ResidualVM Modern Theme Remastered:No Author] [SCUMMVM_STX0.9.5:ResidualVM Modern Theme Remastered:No Author]
%using ../common %using ../common
%using ../common-svg %using ../common-svg

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.9.4:ScummVM Classic Theme:No Author] [SCUMMVM_STX0.9.5:ScummVM Classic Theme:No Author]

Binary file not shown.

View file

@ -1,2 +1,2 @@
[SCUMMVM_STX0.9.4:ScummVM Modern Theme:No Author] [SCUMMVM_STX0.9.5:ScummVM Modern Theme:No Author]
%using ../common %using ../common

Binary file not shown.

View file

@ -1,3 +1,3 @@
[SCUMMVM_STX0.9.4:ScummVM Modern Theme Remastered:No Author] [SCUMMVM_STX0.9.5:ScummVM Modern Theme Remastered:No Author]
%using ../common %using ../common
%using ../common-svg %using ../common-svg

View file

@ -334,22 +334,20 @@ Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name, int re
GridWidget::GridWidget(GuiObject *boss, const Common::String &name) GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
: ContainerWidget(boss, name), CommandSender(boss) { : ContainerWidget(boss, name), CommandSender(boss) {
_thumbnailHeight = int(g_gui.xmlEval()->getVar("Globals.GridItemThumbnail.Height") * g_gui.getScaleFactor() + .5f);
_thumbnailWidth = int(g_gui.xmlEval()->getVar("Globals.GridItemThumbnail.Width") * g_gui.getScaleFactor() + .5f);
_flagIconHeight = int(g_gui.xmlEval()->getVar("Globals.Grid.FlagIcon.Height") * g_gui.getScaleFactor() + .5f);
_flagIconWidth = int(g_gui.xmlEval()->getVar("Globals.Grid.FlagIcon.Width") * g_gui.getScaleFactor() + .5f);
_platformIconHeight = int(g_gui.xmlEval()->getVar("Globals.Grid.PlatformIcon.Height") * g_gui.getScaleFactor() + .5f);
_platformIconWidth = int(g_gui.xmlEval()->getVar("Globals.Grid.PlatformIcon.Width") * g_gui.getScaleFactor() + .5f);
_minGridXSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.XSpacing") * g_gui.getScaleFactor() + .5f);
_minGridYSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.YSpacing") * g_gui.getScaleFactor() + .5f);
_isTitlesVisible = g_gui.xmlEval()->getVar("Globals.Grid.ShowTitles");
_scrollBarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
_scrollWindowPaddingX = _minGridXSpacing; _thumbnailHeight = 0;
_scrollWindowPaddingY = _minGridYSpacing; _thumbnailWidth = 0;
_flagIconHeight = 0;
_flagIconWidth = 0;
_platformIconHeight = 0;
_platformIconWidth = 0;
_minGridXSpacing = 0;
_minGridYSpacing = 0;
_isTitlesVisible = 0;
_scrollBarWidth = 0;
loadPlatformIcons(); _scrollWindowPaddingX = 0;
loadFlagIcons(); _scrollWindowPaddingY = 0;
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, _y, _scrollBarWidth, _y + _h); _scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, _y, _scrollBarWidth, _y + _h);
_scrollBar->setTarget(this); _scrollBar->setTarget(this);
@ -368,8 +366,8 @@ GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
_gridXSpacing = 0; _gridXSpacing = 0;
_gridHeaderHeight = kLineHeight; _gridHeaderHeight = kLineHeight;
_gridHeaderWidth = 0; _gridHeaderWidth = 0;
_gridItemHeight = _thumbnailHeight + (2 * kLineHeight * _isTitlesVisible); _gridItemHeight = 0;
_gridItemWidth = _thumbnailWidth; _gridItemWidth = 0;
_trayHeight = kLineHeight * 3; _trayHeight = kLineHeight * 3;
_selectedEntry = nullptr; _selectedEntry = nullptr;
@ -623,7 +621,7 @@ void GridWidget::reloadThumbnails() {
} }
if (surf) { if (surf) {
const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512, true)); const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, _thumbnailHeight, true));
_loadedSurfaces[entry->thumbPath] = scSurf; _loadedSurfaces[entry->thumbPath] = scSurf;
if (surf != scSurf) { if (surf != scSurf) {
surf->free(); surf->free();
@ -860,35 +858,45 @@ void GridWidget::reflowLayout() {
_scrollWindowHeight = _h; _scrollWindowHeight = _h;
_scrollWindowWidth = _w; _scrollWindowWidth = _w;
_itemsPerRow = ConfMan.getInt("grid_items_per_row");
_minGridXSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.XSpacing") * g_gui.getScaleFactor() + .5f);
_minGridYSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.YSpacing") * g_gui.getScaleFactor() + .5f);
_isTitlesVisible = g_gui.xmlEval()->getVar("Globals.Grid.ShowTitles");
_scrollBarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
_scrollWindowPaddingX = _minGridXSpacing;
_scrollWindowPaddingY = _minGridYSpacing;
_gridYSpacing = _minGridYSpacing;
// Recompute thumbnail size
int oldThumbnailHeight = _thumbnailHeight; int oldThumbnailHeight = _thumbnailHeight;
int oldThumbnailWidth = _thumbnailWidth; int oldThumbnailWidth = _thumbnailWidth;
_thumbnailHeight = int(g_gui.xmlEval()->getVar("Globals.GridItemThumbnail.Height") * g_gui.getScaleFactor() + .5f);
_thumbnailWidth = int(g_gui.xmlEval()->getVar("Globals.GridItemThumbnail.Width") * g_gui.getScaleFactor() + .5f); int availableWidth = _scrollWindowWidth - (2 * _scrollWindowPaddingX) - _scrollBarWidth;
_flagIconHeight = int(g_gui.xmlEval()->getVar("Globals.Grid.FlagIcon.Height") * g_gui.getScaleFactor() + .5f); _thumbnailWidth = availableWidth / _itemsPerRow - _minGridXSpacing;
_flagIconWidth = int(g_gui.xmlEval()->getVar("Globals.Grid.FlagIcon.Width") * g_gui.getScaleFactor() + .5f); const int minimumthumbnailWidth = int(36 * g_gui.getScaleFactor() + .5f);
_platformIconHeight = int(g_gui.xmlEval()->getVar("Globals.Grid.PlatformIcon.Height") * g_gui.getScaleFactor() + .5f); if (_thumbnailWidth < minimumthumbnailWidth) {
_platformIconWidth = int(g_gui.xmlEval()->getVar("Globals.Grid.PlatformIcon.Width") * g_gui.getScaleFactor() + .5f); _thumbnailWidth = minimumthumbnailWidth;
_itemsPerRow = MAX((availableWidth / (_thumbnailWidth + _minGridXSpacing)), 1);
}
_thumbnailHeight = _thumbnailWidth;
_flagIconWidth = _thumbnailWidth / 4;
_flagIconHeight = _flagIconWidth / 2;
_platformIconHeight = _platformIconWidth = _thumbnailWidth / 6;
if ((oldThumbnailHeight != _thumbnailHeight) || (oldThumbnailWidth != _thumbnailWidth)) { if ((oldThumbnailHeight != _thumbnailHeight) || (oldThumbnailWidth != _thumbnailWidth)) {
unloadSurfaces(_loadedSurfaces); unloadSurfaces(_loadedSurfaces);
reloadThumbnails(); reloadThumbnails();
loadFlagIcons(); loadFlagIcons();
loadPlatformIcons(); loadPlatformIcons();
} }
_minGridXSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.XSpacing") * g_gui.getScaleFactor() + .5f);
_minGridYSpacing = int(g_gui.xmlEval()->getVar("Globals.Grid.YSpacing") * g_gui.getScaleFactor() + .5f);
_scrollWindowPaddingX = _minGridXSpacing;
_scrollWindowPaddingY = _minGridYSpacing;
_gridYSpacing = _minGridYSpacing;
_isTitlesVisible = g_gui.xmlEval()->getVar("Globals.Grid.ShowTitles");
_scrollBarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
_trayHeight = kLineHeight * 3; _trayHeight = kLineHeight * 3;
_gridItemHeight = _thumbnailHeight + (2 * kLineHeight * _isTitlesVisible); _gridItemHeight = _thumbnailHeight + (2 * kLineHeight * _isTitlesVisible);
_gridItemWidth = _thumbnailWidth; _gridItemWidth = _thumbnailWidth;
_itemsPerRow = MAX(((_scrollWindowWidth - (2 * _scrollWindowPaddingX) - _scrollBarWidth) / (_gridItemWidth + _minGridXSpacing)), 1);
_gridXSpacing = MAX(((_scrollWindowWidth - _scrollBarWidth - (2 * _scrollWindowPaddingX)) - (_itemsPerRow * _gridItemWidth)) / (_itemsPerRow + 1), _minGridXSpacing); _gridXSpacing = MAX(((_scrollWindowWidth - _scrollBarWidth - (2 * _scrollWindowPaddingX)) - (_itemsPerRow * _gridItemWidth)) / (_itemsPerRow + 1), _minGridXSpacing);
calcEntrySizes(); calcEntrySizes();

View file

@ -42,7 +42,8 @@ enum {
kLoadButtonCmd = 'LOAD', kLoadButtonCmd = 'LOAD',
kOpenTrayCmd = 'OPTR', kOpenTrayCmd = 'OPTR',
kItemClicked = 'LBX1', kItemClicked = 'LBX1',
kItemDoubleClickedCmd = 'LBX2' kItemDoubleClickedCmd = 'LBX2',
kItemSizeCmd = 'SIZE'
}; };
/* GridItemInfo */ /* GridItemInfo */