GUI: Scale grid widget icons with filtering

This commit is contained in:
SupSuper 2022-02-22 17:00:19 +00:00
parent 261f012162
commit 57d0df273e
4 changed files with 5 additions and 8 deletions

View file

@ -543,7 +543,7 @@ void DropdownButtonWidget::drawWidget() {
#pragma mark -
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h) {
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h, bool filtering) {
int nw = w, nh = h;
// Maintain aspect ratio
@ -563,7 +563,7 @@ const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, in
Graphics::ManagedSurface tmp(*gfx);
const Graphics::ManagedSurface *tmp2 = new Graphics::ManagedSurface(tmp.surfacePtr()->scale(w, h, false));
const Graphics::ManagedSurface *tmp2 = new Graphics::ManagedSurface(tmp.surfacePtr()->scale(w, h, filtering));
tmp.free();
return tmp2;

View file

@ -529,7 +529,7 @@ private:
};
ButtonWidget *addClearButton(GuiObject *boss, const Common::String &name, uint32 cmd, int x=0, int y=0, int w=0, int h=0);
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h);
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h, bool filtering = false);
} // End of namespace GUI

View file

@ -582,7 +582,7 @@ void GridWidget::reloadThumbnails() {
if (!_loadedSurfaces.contains(entry->thumbPath)) {
surf = loadSurfaceFromFile(entry->thumbPath);
if (surf) {
const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512));
const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512, true));
_loadedSurfaces[entry->thumbPath] = scSurf;
surf->free();
delete surf;
@ -612,7 +612,7 @@ void GridWidget::loadPlatformIcons() {
Common::String path = Common::String::format("icons/platforms/%s.png", l->code);
Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path);
if (gfx) {
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, _platformIconWidth, _platformIconHeight);
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, _platformIconWidth, _platformIconHeight, true);
_platformIcons[l->id] = scGfx;
gfx->free();
delete gfx;

View file

@ -36,9 +36,6 @@ class ScrollBarWidget;
class GridItemWidget;
class GridWidget;
const Graphics::ManagedSurface *scaleGfx(const Graphics::ManagedSurface *gfx, int w, int h);
Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name, int renderWidth, int renderHeight);
enum {
kPlayButtonCmd = 'PLAY',
kEditButtonCmd = 'EDIT',