Skip to content

Commit

Permalink
Refactor|libappfw|GuiWidget: Added a slot for deleting later
Browse files Browse the repository at this point in the history
Also added a guiFind() utility method and renamed the clipped()
method for clarity.
  • Loading branch information
skyjake committed Apr 14, 2014
1 parent 802bc33 commit 9946567
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
17 changes: 13 additions & 4 deletions doomsday/libappfw/include/de/framework/guiwidget.h
Expand Up @@ -85,14 +85,16 @@ class BlurWidget;
*/
class LIBAPPFW_PUBLIC GuiWidget : public QObject, public Widget
{
Q_OBJECT

public:
/**
* Properties of the widget's background's apperance.
* GuiWidget::glMakeGeometry() uses this to construct the background
* 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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
18 changes: 14 additions & 4 deletions doomsday/libappfw/src/guiwidget.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -498,7 +498,7 @@ void GuiWidget::set(Background const &bg)
requestGeometry();
}

bool GuiWidget::clipped() const
bool GuiWidget::isClipped() const
{
return behavior().testFlag(ContentClipping);
}
Expand Down Expand Up @@ -647,14 +647,14 @@ void GuiWidget::draw()

d->drawBlurredBackground();

if(clipped())
if(isClipped())
{
GLState::push().setNormalizedScissor(normalizedRect());
}

drawContent();

if(clipped())
if(isClipped())
{
GLState::pop();
}
Expand Down Expand Up @@ -813,6 +813,16 @@ bool GuiWidget::isInitialized() const
return d->inited;
}

GuiWidget *GuiWidget::guiFind(String const &name)
{
return find(name)->maybeAs<GuiWidget>();
}

GuiWidget const *GuiWidget::guiFind(String const &name) const
{
return find(name)->maybeAs<GuiWidget>();
}

void GuiWidget::glMakeGeometry(DefaultVertexBuf::Builder &verts)
{
if(d->background.type != Background::Blurred &&
Expand Down

0 comments on commit 9946567

Please sign in to comment.