diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-21 15:03:50 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-21 15:35:20 -0400 |
commit | eb23bd81024068b780e7446c86dbc5711fa48965 (patch) | |
tree | 1b623f3a2ae89fae944c8bedf2b975951f47f1bf /libs | |
parent | b02a7445bfa11d1c1ea1f6762b7e845b780ab4ea (diff) |
add Group::clear(), do not clear _canvas member of Item when unparented (only the parent is changed)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/canvas/canvas/group.h | 1 | ||||
-rw-r--r-- | libs/canvas/group.cc | 33 |
2 files changed, 33 insertions, 1 deletions
diff --git a/libs/canvas/canvas/group.h b/libs/canvas/canvas/group.h index 8dee5f2672..9a72d50873 100644 --- a/libs/canvas/canvas/group.h +++ b/libs/canvas/canvas/group.h @@ -40,6 +40,7 @@ public: void add (Item *); void remove (Item *); + void clear (bool with_delete = false); std::list<Item*> const & items () const { return _items; } diff --git a/libs/canvas/group.cc b/libs/canvas/group.cc index 907282f9cd..fe783ad8b5 100644 --- a/libs/canvas/group.cc +++ b/libs/canvas/group.cc @@ -170,6 +170,8 @@ Group::compute_bounding_box () const void Group::add (Item* i) { + /* XXX should really notify canvas about this */ + _items.push_back (i); invalidate_lut (); _bounding_box_dirty = true; @@ -180,11 +182,40 @@ Group::add (Item* i) void Group::remove (Item* i) { + + if (i->parent() != this) { + return; + } + + begin_change (); + + i->unparent (); _items.remove (i); invalidate_lut (); _bounding_box_dirty = true; - DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: group remove\n"); + end_change (); +} + +void +Group::clear (bool with_delete) +{ + begin_change (); + + for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) { + if (with_delete) { + delete *i; + } else { + (*i)->unparent (); + } + } + + _items.clear (); + + invalidate_lut (); + _bounding_box_dirty = true; + + end_change (); } void |