From acecfcaf6906f6640d8418c14a3aa2c8833f76e3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jul 2010 01:11:18 +0000 Subject: [PATCH] Center the surface of a GraphicsWidget in case it is smaller than the widget's size. svn-id: r50639 --- gui/widget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gui/widget.cpp b/gui/widget.cpp index 2d4306d26ab..9297cce344a 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 -