13
0

add Group::clear(), do not clear _canvas member of Item when unparented (only the parent is changed)

This commit is contained in:
Paul Davis 2013-04-21 15:03:50 -04:00
parent b02a7445bf
commit eb23bd8102
2 changed files with 33 additions and 1 deletions

View File

@ -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;
}

View File

@ -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