diff options
author | Johannes Schickel | 2010-07-04 01:11:18 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-07-04 01:11:18 +0000 |
commit | acecfcaf6906f6640d8418c14a3aa2c8833f76e3 (patch) | |
tree | 91c0c3533996327c683df89e623af72a8a3a8663 /gui | |
parent | 10e7581fe1a281f69875a6d76c9c1bf5aafa939c (diff) | |
download | scummvm-rg350-acecfcaf6906f6640d8418c14a3aa2c8833f76e3.tar.gz scummvm-rg350-acecfcaf6906f6640d8418c14a3aa2c8833f76e3.tar.bz2 scummvm-rg350-acecfcaf6906f6640d8418c14a3aa2c8833f76e3.zip |
Center the surface of a GraphicsWidget in case it is smaller than the widget's size.
svn-id: r50639
Diffstat (limited to 'gui')
-rw-r--r-- | gui/widget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp index 2d4306d26a..9297cce344 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -596,7 +596,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { _gfx.free(); _gfx.create(w, h, sizeof(OverlayColor)); - OverlayColor *dst = (OverlayColor*)_gfx.pixels; + OverlayColor *dst = (OverlayColor *)_gfx.pixels; Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat(); OverlayColor fillCol = overlayFormat.RGBToColor(r, g, b); while (h--) { @@ -607,8 +607,12 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { } void GraphicsWidget::drawWidget() { - if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) - g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, _state, _alpha, _transparency); + if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) { + const int x = _x + (_w - _gfx.w) / 2; + const int y = _y + (_h - _gfx.h) / 2; + + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency); + } } #pragma mark - |