Skip to content

Commit

Permalink
libdeng2|Refactor: Use de::Id instead of duint32
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 23, 2013
1 parent e749ed6 commit 31f2a8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 2 additions & 1 deletion doomsday/libdeng2/include/de/widgets/widget.h
Expand Up @@ -23,6 +23,7 @@

#include "../String"
#include "../Event"
#include "../Id"

namespace de {

Expand Down Expand Up @@ -62,7 +63,7 @@ class DENG2_PUBLIC Widget
/**
* Returns the automatically generated, unique identifier of the widget.
*/
duint32 id() const;
Id id() const;

String name() const;
void setName(String const &name);
Expand Down
18 changes: 6 additions & 12 deletions doomsday/libdeng2/src/widgets/widget.cpp
Expand Up @@ -24,12 +24,9 @@

namespace de {

static duint32 widgetIdGen = 0;

struct Widget::Instance
DENG2_PIMPL(Widget::Instance)
{
Widget &self;
duint32 id;
Id id;
String name;
Widget *parent;
Behaviors behavior;
Expand All @@ -41,11 +38,8 @@ struct Widget::Instance
Children children;
NamedChildren index;

Instance(Widget &w, String const &n) : self(w), name(n), parent(0)
{
// A unique ID is generated for each Widget instance.
id = ++widgetIdGen;
}
Instance(Public *i, String const &n) : Base(i), name(n), parent(0)
{}

~Instance()
{
Expand All @@ -63,7 +57,7 @@ struct Widget::Instance
}
};

Widget::Widget(String const &name) : d(new Instance(*this, name))
Widget::Widget(String const &name) : d(new Instance(this, name))
{}

Widget::~Widget()
Expand All @@ -82,7 +76,7 @@ Widget::~Widget()
delete d;
}

duint32 Widget::id() const
Id Widget::id() const
{
return d->id;
}
Expand Down

0 comments on commit 31f2a8c

Please sign in to comment.