aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/drawable_control.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/menu/drawable_control.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp
index 6967d5fc..222ef3d5 100644
--- a/src/menu/drawable_control.cpp
+++ b/src/menu/drawable_control.cpp
@@ -35,15 +35,33 @@ namespace usdx
DrawableControl::DrawableControl(Container* parent)
: Control(parent), parent(parent)
{
- if (parent) {
- parent->add(this);
- }
+ ContainerHelper(this).add(parent);
+ }
+
+ DrawableControl::DrawableControl(Container* parent,
+ const ContainerHelper& helper)
+ : Control(parent), parent(parent)
+ {
+ helper.add(parent);
}
DrawableControl::~DrawableControl()
{
if (parent) {
parent->remove(this);
+ parent = NULL;
+ }
+ }
+
+ DrawableControl::ContainerHelper::ContainerHelper(DrawableControl* self) :
+ self(self)
+ {
+ }
+
+ void DrawableControl::ContainerHelper::add(Container* c) const
+ {
+ if (c) {
+ c->add(self);
}
}
};