aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/control.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2011-12-25 16:14:07 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:50 +0100
commitfb70fe4e1a04b6041a50da7e2e76200fb18de0f9 (patch)
tree04da9da4fa8594f610bfb0f09bf5f5e900231c13 /src/menu/control.cpp
parentc129094a1604f96b4a3a0ca58226e38a2a1b7cdb (diff)
downloadusdx-fb70fe4e1a04b6041a50da7e2e76200fb18de0f9.tar.gz
usdx-fb70fe4e1a04b6041a50da7e2e76200fb18de0f9.tar.xz
usdx-fb70fe4e1a04b6041a50da7e2e76200fb18de0f9.zip
menu/control: controls are now owned by other controls
controls could now be owned by other controls, that are responsible for destruction of their slaves
Diffstat (limited to 'src/menu/control.cpp')
-rw-r--r--src/menu/control.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/menu/control.cpp b/src/menu/control.cpp
index 68b5c328..f9ea2a89 100644
--- a/src/menu/control.cpp
+++ b/src/menu/control.cpp
@@ -29,26 +29,43 @@
namespace usdx
{
- Control::Control(Control *parent)
- : parent(parent)
+ Control::Control(Control *owner)
+ : owner(owner)
{
+ owner->add(this);
}
Control::~Control()
{
- if (parent) {
- delete parent;
- parent = NULL;
+ for (std::list<Control*>::iterator it =
+ slaves.begin(); it != slaves.end(); it++) {
+ delete *it;
}
+
+ slaves.clear();
+ }
+
+ void Control::set_owner(Control *owner)
+ {
+ if (this->owner != owner) {
+ this->owner->remove(this);
+ this->owner = owner;
+ this->owner->add(this);
+ }
+ }
+
+ Control* Control::get_owner(void) const
+ {
+ return owner;
}
- void Control::set_parent(Control *parent)
+ void Control::add(Control *new_slave)
{
- this->parent = parent;
+ slaves.push_back(new_slave);
}
- Control* Control::get_parent(void) const
+ void Control::remove(Control *slave)
{
- return parent;
+ slaves.remove(slave);
}
};