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