From e6c317a9226b71af572d2e2004e307c0e895b77c Mon Sep 17 00:00:00 2001 From: Oleksiy Kurochko Date: Thu, 3 May 2012 19:32:08 +0300 Subject: GUI: Implemented pressed state for buttons --- gui/widget.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 0e2fd248b1..6ae4e5cee5 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -30,6 +30,8 @@ #include "gui/ThemeEval.h" +#include "gui/dialog.h" + namespace GUI { Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip) @@ -77,6 +79,8 @@ void Widget::updateState(int oldFlags, int newFlags) { _state = ThemeEngine::kStateEnabled; if (newFlags & WIDGET_HILITED) _state = ThemeEngine::kStateHighlight; + if (newFlags & WIDGET_PRESSED) + _state = ThemeEngine::kStatePressed; } else { _state = ThemeEngine::kStateDisabled; } @@ -272,27 +276,33 @@ void StaticTextWidget::drawWidget() { ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, const char *tooltip, uint32 cmd, uint8 hotkey) : StaticTextWidget(boss, x, y, w, h, cleanupHotkey(label), Graphics::kTextAlignCenter, tooltip), CommandSender(boss), - _cmd(cmd), _hotkey(hotkey) { + _cmd(cmd), _hotkey(hotkey), _lastTime(0) { if (hotkey == 0) _hotkey = parseHotkey(label); - setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); + setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE); _type = kButtonWidget; } ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, const char *tooltip, uint32 cmd, uint8 hotkey) : StaticTextWidget(boss, name, cleanupHotkey(label), tooltip), CommandSender(boss), - _cmd(cmd) { + _cmd(cmd), _lastTime(0) { if (hotkey == 0) _hotkey = parseHotkey(label); - setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); + setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE); _type = kButtonWidget; } void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { - if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) + if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { sendCommand(_cmd, 0); + startAnimatePressedState(); + } +} + +void ButtonWidget::handleMouseDown(int x, int y, int button, int clickCount) { + setPressedState(); } void ButtonWidget::drawWidget() { @@ -324,6 +334,44 @@ ButtonWidget *addClearButton(GuiObject *boss, const Common::String &name, uint32 return button; } +void ButtonWidget::setHighLighted(bool enable) { + (enable) ? setFlags(WIDGET_HILITED) : clearFlags(WIDGET_HILITED); + draw(); +} + +void ButtonWidget::handleTickle() { + if (_lastTime) { + uint32 curTime = g_system->getMillis(); + if (curTime - _lastTime > kPressedButtonTime) { + stopAnimatePressedState(); + } + } +} + +void ButtonWidget::setPressedState() { + wantTickle(true); + setFlags(WIDGET_PRESSED); + draw(); +} + +void ButtonWidget::stopAnimatePressedState() { + wantTickle(false); + _lastTime = 0; + clearFlags(WIDGET_PRESSED); + draw(); +} + +void ButtonWidget::startAnimatePressedState() { + _lastTime = g_system->getMillis(); +} + +void ButtonWidget::wantTickle(bool tickled) { + if (tickled) + ((GUI::Dialog *)_boss)->setTickleWidget(this); + else + ((GUI::Dialog *)_boss)->unSetTickleWidget(); +} + #pragma mark - PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey) -- cgit v1.2.3 From 97065c95e654f36070b8f12f20b3bff1752b5e0c Mon Sep 17 00:00:00 2001 From: Oleksiy Kurochko Date: Mon, 7 May 2012 09:54:32 +0300 Subject: GUI: Fix bug with button pressed state --- gui/widget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 6ae4e5cee5..fc6510b976 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -281,7 +281,7 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Co if (hotkey == 0) _hotkey = parseHotkey(label); - setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE); + setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; } @@ -290,7 +290,7 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Co _cmd(cmd), _lastTime(0) { if (hotkey == 0) _hotkey = parseHotkey(label); - setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG | WIDGET_WANT_TICKLE); + setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; } -- cgit v1.2.3 From 13f93494578818b5a1272d793f7412b6810f3321 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 12 Jun 2012 04:16:51 +0200 Subject: GUI: Take advantage of Surface::fillRect in GraphicsWidget::setGfx. --- gui/widget.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index fc6510b976..657245c815 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -643,14 +643,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { _gfx.free(); _gfx.create(w, h, overlayFormat); - - OverlayColor *dst = (OverlayColor *)_gfx.pixels; - OverlayColor fillCol = overlayFormat.RGBToColor(r, g, b); - while (h--) { - for (int i = 0; i < w; ++i) { - *dst++ = fillCol; - } - } + _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); } void GraphicsWidget::drawWidget() { -- cgit v1.2.3 From cebbc11dac77d30fac3be4cc0ebdc6bc059636ef Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 13 Jun 2012 04:44:39 +0200 Subject: GUI: Allow Surfaces with abitrary RGB pixel formats to be used in PicButtonWidget and GraphicsWidget. Only 1Bpp aka paletted surfaces are not supported. --- gui/widget.cpp | 79 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 24 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 657245c815..1b68e36ea8 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -376,7 +376,7 @@ void ButtonWidget::wantTickle(bool tickled) { PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey), - _gfx(), _alpha(256), _transparency(false) { + _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; @@ -384,38 +384,54 @@ PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, co PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, name, "", tooltip, cmd, hotkey), - _alpha(256), _transparency(false) { + _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; } PicButtonWidget::~PicButtonWidget() { - _gfx.free(); + _gfx->free(); + delete _gfx; } void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { - _gfx.free(); + _gfx->free(); if (!gfx || !gfx->pixels) return; + if (gfx->format.bytesPerPixel == 1) { + warning("PicButtonWidget::setGfx got paletted surface passed"); + return; + } + + if (gfx->w > _w || gfx->h > _h) { warning("PicButtonWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h); return; } - // TODO: add conversion to OverlayColor - _gfx.copyFrom(*gfx); + _gfx->copyFrom(*gfx); } void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); - if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) { - const int x = _x + (_w - _gfx.w) / 2; - const int y = _y + (_h - _gfx.h) / 2; + if (_gfx->pixels) { + // Check whether the set up surface needs to be converted to the GUI + // color format. + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + if (_gfx->format != requiredFormat) { + Graphics::Surface *converted = _gfx->convertTo(requiredFormat); + _gfx->free(); + delete _gfx; + _gfx = converted; + } + + 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); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency); } } @@ -603,34 +619,39 @@ int SliderWidget::posToValue(int pos) { #pragma mark - GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip) - : Widget(boss, x, y, w, h, tooltip), _gfx(), _alpha(256), _transparency(false) { + : Widget(boss, x, y, w, h, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, const char *tooltip) - : Widget(boss, name, tooltip), _gfx(), _alpha(256), _transparency(false) { + : Widget(boss, name, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::~GraphicsWidget() { - _gfx.free(); + _gfx->free(); + delete _gfx; } void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { - _gfx.free(); + _gfx->free(); if (!gfx || !gfx->pixels) return; + if (gfx->format.bytesPerPixel == 1) { + warning("GraphicsWidget::setGfx got paletted surface passed"); + return; + } + if (gfx->w > _w || gfx->h > _h) { warning("GraphicsWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h); return; } - // TODO: add conversion to OverlayColor - _gfx.copyFrom(*gfx); + _gfx->copyFrom(*gfx); } void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { @@ -639,19 +660,29 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { if (h == -1) h = _h; - Graphics::PixelFormat overlayFormat = g_system->getOverlayFormat(); + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - _gfx.free(); - _gfx.create(w, h, overlayFormat); - _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); + _gfx->free(); + _gfx->create(w, h, requiredFormat); + _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); } void GraphicsWidget::drawWidget() { - if (sizeof(OverlayColor) == _gfx.format.bytesPerPixel && _gfx.pixels) { - const int x = _x + (_w - _gfx.w) / 2; - const int y = _y + (_h - _gfx.h) / 2; + if (_gfx->pixels) { + // Check whether the set up surface needs to be converted to the GUI + // color format. + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + if (_gfx->format != requiredFormat) { + Graphics::Surface *converted = _gfx->convertTo(requiredFormat); + _gfx->free(); + delete _gfx; + _gfx = converted; + } + + 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); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency); } } -- cgit v1.2.3 From c1426f783d91976d221c059c37b606411445d438 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 16:15:46 +0200 Subject: GUI: Use a black rect when no thumbnail is available in the thumbnail load chooser. --- gui/widget.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 1b68e36ea8..3c26f1135b 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -414,6 +414,19 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { _gfx->copyFrom(*gfx); } +void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { + if (w == -1) + w = _w; + if (h == -1) + h = _h; + + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + + _gfx->free(); + _gfx->create(w, h, requiredFormat); + _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); +} + void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); -- cgit v1.2.3 From 0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 9 Jul 2012 01:49:58 +0200 Subject: GUI: Make container widget a bit more container like. Now it is possible to add sub widgets to a ContainerWidget and allow for these to get events too. --- gui/widget.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 3c26f1135b..4babce66fb 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -711,6 +711,26 @@ ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : _type = kContainerWidget; } +ContainerWidget::~ContainerWidget() { + // We also remove the widget from the boss to avoid segfaults, when the + // deleted widget is an active widget in the boss. + for (Widget *w = _firstWidget; w; w = w->next()) { + _boss->removeWidget(w); + } +} + +Widget *ContainerWidget::findWidget(int x, int y) { + return findWidgetInChain(_firstWidget, x, y); +} + +void ContainerWidget::removeWidget(Widget *widget) { + // We also remove the widget from the boss to avoid a reference to a + // widget not in the widget chain anymore. + _boss->removeWidget(widget); + + Widget::removeWidget(widget); +} + void ContainerWidget::drawWidget() { g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, ThemeEngine::kWidgetBackgroundBorder); } -- cgit v1.2.3 From 90eb773c5d862d38f3dc834d51c5a57319c61c3f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 13 Jul 2012 17:17:58 +0200 Subject: GUI: Implement saving in the grid based save/load chooser. --- gui/widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 4babce66fb..9046bcc9c1 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -296,8 +296,8 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Co void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { - sendCommand(_cmd, 0); startAnimatePressedState(); + sendCommand(_cmd, 0); } } -- cgit v1.2.3 From a1e56adad8eb8ed4c8de5850fb2c81af9adb9585 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 28 Aug 2012 02:25:14 +0200 Subject: GUI: Use in-place Surface conversion in widget code. --- gui/widget.cpp | 64 +++++++++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 9046bcc9c1..c5ca628576 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -376,7 +376,7 @@ void ButtonWidget::wantTickle(bool tickled) { PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey), - _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; @@ -384,18 +384,17 @@ PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, co PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, name, "", tooltip, cmd, hotkey), - _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; } PicButtonWidget::~PicButtonWidget() { - _gfx->free(); - delete _gfx; + _gfx.free(); } void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { - _gfx->free(); + _gfx.free(); if (!gfx || !gfx->pixels) return; @@ -411,7 +410,7 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { return; } - _gfx->copyFrom(*gfx); + _gfx.copyFrom(*gfx); } void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { @@ -422,29 +421,26 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - _gfx->free(); - _gfx->create(w, h, requiredFormat); - _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); + _gfx.free(); + _gfx.create(w, h, requiredFormat); + _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); } void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); - if (_gfx->pixels) { + if (_gfx.pixels) { // Check whether the set up surface needs to be converted to the GUI // color format. const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (_gfx->format != requiredFormat) { - Graphics::Surface *converted = _gfx->convertTo(requiredFormat); - _gfx->free(); - delete _gfx; - _gfx = converted; + if (_gfx.format != requiredFormat) { + _gfx.convertToInPlace(requiredFormat); } - const int x = _x + (_w - _gfx->w) / 2; - const int y = _y + (_h - _gfx->h) / 2; + 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); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency); } } @@ -632,24 +628,23 @@ int SliderWidget::posToValue(int pos) { #pragma mark - GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip) - : Widget(boss, x, y, w, h, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + : Widget(boss, x, y, w, h, tooltip), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, const char *tooltip) - : Widget(boss, name, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + : Widget(boss, name, tooltip), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::~GraphicsWidget() { - _gfx->free(); - delete _gfx; + _gfx.free(); } void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { - _gfx->free(); + _gfx.free(); if (!gfx || !gfx->pixels) return; @@ -664,7 +659,7 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { return; } - _gfx->copyFrom(*gfx); + _gfx.copyFrom(*gfx); } void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { @@ -675,27 +670,24 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - _gfx->free(); - _gfx->create(w, h, requiredFormat); - _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); + _gfx.free(); + _gfx.create(w, h, requiredFormat); + _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); } void GraphicsWidget::drawWidget() { - if (_gfx->pixels) { + if (_gfx.pixels) { // Check whether the set up surface needs to be converted to the GUI // color format. const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (_gfx->format != requiredFormat) { - Graphics::Surface *converted = _gfx->convertTo(requiredFormat); - _gfx->free(); - delete _gfx; - _gfx = converted; + if (_gfx.format != requiredFormat) { + _gfx.convertToInPlace(requiredFormat); } - const int x = _x + (_w - _gfx->w) / 2; - const int y = _y + (_h - _gfx->h) / 2; + 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); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency); } } -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- gui/widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/widget.cpp') diff --git a/gui/widget.cpp b/gui/widget.cpp index 9046bcc9c1..270cdc56de 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -366,7 +366,7 @@ void ButtonWidget::startAnimatePressedState() { } void ButtonWidget::wantTickle(bool tickled) { - if (tickled) + if (tickled) ((GUI::Dialog *)_boss)->setTickleWidget(this); else ((GUI::Dialog *)_boss)->unSetTickleWidget(); -- cgit v1.2.3