From 9946567ed920c7c1b8c136e20d53b2ab8de21c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Mon, 14 Apr 2014 15:16:49 +0300 Subject: [PATCH] Refactor|libappfw|GuiWidget: Added a slot for deleting later Also added a guiFind() utility method and renamed the clipped() method for clarity. --- .../libappfw/include/de/framework/guiwidget.h | 17 +++++++++++++---- doomsday/libappfw/src/guiwidget.cpp | 18 ++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/doomsday/libappfw/include/de/framework/guiwidget.h b/doomsday/libappfw/include/de/framework/guiwidget.h index 2d784fea7a..aefe964523 100644 --- a/doomsday/libappfw/include/de/framework/guiwidget.h +++ b/doomsday/libappfw/include/de/framework/guiwidget.h @@ -85,6 +85,8 @@ class BlurWidget; */ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget { + Q_OBJECT + public: /** * Properties of the widget's background's apperance. @@ -92,7 +94,7 @@ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget * geometry of the widget. * * @todo Refactor: it should be possible to apply any combination of these - * in a single widget; use a dynamic array of effects. + * in a single widget; use a dynamic array of effects. Base it on ProceduralImage. */ struct Background { enum Type { @@ -203,8 +205,6 @@ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget */ Rectanglef normalizedContentRect() const; - void guiDeleteLater(); - void setFont(DotPath const &id); void setTextColor(DotPath const &id); void set(Background const &bg); @@ -219,7 +219,7 @@ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget * to its boundaries. The Widget::ContentClipping behavior flag is used for * storing this information. */ - bool clipped() const; + bool isClipped() const; Background const &background() const; @@ -334,6 +334,15 @@ class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget bool isInitialized() const; + GuiWidget *guiFind(String const &name); + GuiWidget const *guiFind(String const &name) const; + +public slots: + /** + * Puts the widget in garbage to be deleted at the next recycling. + */ + void guiDeleteLater(); + public: /** * Normalize a rectangle within a container rectangle. diff --git a/doomsday/libappfw/src/guiwidget.cpp b/doomsday/libappfw/src/guiwidget.cpp index 7857ff6287..988e29aabf 100644 --- a/doomsday/libappfw/src/guiwidget.cpp +++ b/doomsday/libappfw/src/guiwidget.cpp @@ -164,7 +164,7 @@ DENG2_PIMPL(GuiWidget) } if(!wasClipped) return false; - if(self.clipped()) + if(self.isClipped()) { int const CULL_SAFETY_WIDTH = 100; // avoid pop-in when scrolling @@ -498,7 +498,7 @@ void GuiWidget::set(Background const &bg) requestGeometry(); } -bool GuiWidget::clipped() const +bool GuiWidget::isClipped() const { return behavior().testFlag(ContentClipping); } @@ -647,14 +647,14 @@ void GuiWidget::draw() d->drawBlurredBackground(); - if(clipped()) + if(isClipped()) { GLState::push().setNormalizedScissor(normalizedRect()); } drawContent(); - if(clipped()) + if(isClipped()) { GLState::pop(); } @@ -813,6 +813,16 @@ bool GuiWidget::isInitialized() const return d->inited; } +GuiWidget *GuiWidget::guiFind(String const &name) +{ + return find(name)->maybeAs(); +} + +GuiWidget const *GuiWidget::guiFind(String const &name) const +{ + return find(name)->maybeAs(); +} + void GuiWidget::glMakeGeometry(DefaultVertexBuf::Builder &verts) { if(d->background.type != Background::Blurred &&