From 341873c9d3c1f4742c6bb2ccf9a4435c09930c7e Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Sat, 7 Feb 2009 00:23:53 +0000 Subject: Third attemp at fixing release-critical #2472185. Also fixes regression reported in #2555710. svn-id: r36227 --- gui/ThemeEngine.cpp | 6 +++--- gui/ThemeEngine.h | 2 +- gui/launcher.cpp | 4 +--- gui/widget.cpp | 25 ++++++++++++------------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 78b4545270..f5d6fc6d29 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -742,7 +742,7 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeId) { /********************************************************** * Drawing Queue management *********************************************************/ -void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) { +void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic, bool restore) { if (_widgets[type] == 0) return; @@ -761,7 +761,7 @@ void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) _screenQueue.push_back(q); } } else { - q->drawSelf(!_widgets[type]->_buffer, _widgets[type]->_buffer); + q->drawSelf(!_widgets[type]->_buffer, restore || _widgets[type]->_buffer); delete q; } } @@ -818,7 +818,7 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W else if (state == kStateDisabled) dd = kDDButtonDisabled; - queueDD(dd, r); + queueDD(dd, r, 0, hints & WIDGET_CLEARBG); queueDDText(getTextData(dd), r, str, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV); } diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 49c8966a45..3749b65b53 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -513,7 +513,7 @@ protected: * * This function is called from all the Widget Drawing methods. */ - void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0); + void queueDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool restore = false); void queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg, bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0); void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 4d54a60eb0..2cf6d4c478 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -912,10 +912,8 @@ void LauncherDialog::updateButtons() { ? "Mass Add" : "Add Game"; - if (_addButton->getLabel() != newAddButtonLabel) { + if (_addButton->getLabel() != newAddButtonLabel) _addButton->setLabel(newAddButtonLabel); - _addButton->draw(); - } } void LauncherDialog::reflowLayout() { diff --git a/gui/widget.cpp b/gui/widget.cpp index 412e50f79c..b93f93656c 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -198,17 +198,16 @@ void StaticTextWidget::setValue(int value) { } void StaticTextWidget::setLabel(const Common::String &label) { - _label = label; - - // get parent's size - const uint16 w = _boss->getWidth(); - const uint16 h = _boss->getHeight(); - const int16 x = _boss->getAbsX(); - const int16 y = _boss->getAbsY(); - - // restore the parent's background and redraw it again. - g_gui.theme()->restoreBackground(Common::Rect(x, y, x + w, y + h)); - _boss->draw(); + if (_label != label) { + _label = label; + + // when changing the label, add the CLEARBG flag + // so the widget is completely redrawn, otherwise + // the new text is drawn on top of the old one. + setFlags(WIDGET_CLEARBG); + draw(); + clearFlags(WIDGET_CLEARBG); + } } void StaticTextWidget::setAlign(Graphics::TextAlign align) { @@ -225,7 +224,7 @@ void StaticTextWidget::drawWidget() { #pragma mark - ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd, uint8 hotkey) - : StaticTextWidget(boss, x, y, w, h, label, Graphics::kTextAlignCenter), CommandSender(boss), + : StaticTextWidget(boss, x, y, w, h, label, Graphics::kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; @@ -244,7 +243,7 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { } void ButtonWidget::drawWidget() { - g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, 0); + g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, getFlags()); } #pragma mark - -- cgit v1.2.3