aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/drawable_control.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-03-22 22:15:36 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:52 +0100
commitab4f6fc5cab3e65448145fda2995dc75bd866a2a (patch)
tree8503369d1a3a94f0b24774fd1bc7b66cb3c8dbac /src/menu/drawable_control.cpp
parent384f60e9ffe300c511ecd5e6bb7b73bc2e277d53 (diff)
downloadusdx-ab4f6fc5cab3e65448145fda2995dc75bd866a2a.tar.gz
usdx-ab4f6fc5cab3e65448145fda2995dc75bd866a2a.tar.xz
usdx-ab4f6fc5cab3e65448145fda2995dc75bd866a2a.zip
menu: frame should not be added to container item list
if a frame is constructed, it needs a container as parent to get the size of it, but it should not be in the container item list and should be painted first, to be under every component the inner classes are used as helper classes, to be able to call a virtual method in the constructor of drawable_control to decide whether to add the control to the controls list of the container or not
Diffstat (limited to 'src/menu/drawable_control.cpp')
-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);
}
}
};