Changed 'zoomlevel' to a GUI::Size object to more clearly reflect its intent.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2980 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-08-28 15:29:35 +00:00
parent f6dd1ba27b
commit 04ee72521d
2 changed files with 8 additions and 6 deletions

View File

@ -29,12 +29,13 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h) int x, int y, int w, int h)
: Widget(boss, font, x, y, w, h), : Widget(boss, font, x, y, w, h),
mySurface(NULL), mySurface(NULL),
myZoomLevel(w > 400 ? 2 : 1),
mySurfaceIsValid(false), mySurfaceIsValid(false),
myHaveProperties(false) myHaveProperties(false)
{ {
_flags = WIDGET_ENABLED; _flags = WIDGET_ENABLED;
_bgcolor = _bgcolorhi = kWidColor; _bgcolor = _bgcolorhi = kWidColor;
myAvail = w > 400 ? GUI::Size(640, 512) : GUI::Size(320, 256);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -116,8 +117,7 @@ void RomInfoWidget::parseProperties()
// Scale surface to available image area // Scale surface to available image area
const GUI::Rect& src = mySurface->srcRect(); const GUI::Rect& src = mySurface->srcRect();
uInt32 avail_w = 320 * myZoomLevel, avail_h = 256 * myZoomLevel; float scale = BSPF_min(float(myAvail.w) / src.width(), float(myAvail.h) / src.height());
float scale = BSPF_min(float(avail_w) / src.width(), float(avail_h) / src.height());
mySurface->setDstSize(src.width() * scale, src.height() * scale); mySurface->setDstSize(src.width() * scale, src.height() * scale);
} }
catch(const char* msg) catch(const char* msg)
@ -143,7 +143,7 @@ void RomInfoWidget::drawWidget(bool hilite)
{ {
FBSurface& s = dialog().surface(); FBSurface& s = dialog().surface();
const int yoff = myZoomLevel > 1 ? 260*2 + 10 : 275; const int yoff = myAvail.h + 10;
s.fillRect(_x+2, _y+2, _w-4, _h-4, kWidColor); s.fillRect(_x+2, _y+2, _w-4, _h-4, kWidColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor); s.box(_x, _y, _w, _h, kColor, kShadowColor);
@ -169,6 +169,7 @@ void RomInfoWidget::drawWidget(bool hilite)
uInt32 y = _y + ((yoff - font.getLineHeight()) >> 1); uInt32 y = _y + ((yoff - font.getLineHeight()) >> 1);
s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, _textcolor); s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, _textcolor);
} }
int xpos = _x + 5, ypos = _y + yoff + 10; int xpos = _x + 5, ypos = _y + yoff + 10;
for(unsigned int i = 0; i < myRomInfo.size(); ++i) for(unsigned int i = 0; i < myRomInfo.size(); ++i)
{ {

View File

@ -26,6 +26,7 @@
#include "Widget.hxx" #include "Widget.hxx"
#include "Command.hxx" #include "Command.hxx"
#include "StringList.hxx" #include "StringList.hxx"
#include "Rect.hxx"
#include "bspf.hxx" #include "bspf.hxx"
@ -50,8 +51,8 @@ class RomInfoWidget : public Widget
// Surface pointer holding the PNG image // Surface pointer holding the PNG image
FBSurface* mySurface; FBSurface* mySurface;
// How much to zoom the PNG image // How much space available for the PNG image
int myZoomLevel; GUI::Size myAvail;
// Whether the surface should be redrawn by drawWidget() // Whether the surface should be redrawn by drawWidget()
bool mySurfaceIsValid; bool mySurfaceIsValid;