//--------------------------------------------------------------------------------------- int GmoCompositeShape::add(GmoShape* pShape) { m_components.push_back(pShape); if (m_components.size() == 1) { //copy bounds m_origin = pShape->get_origin(); m_size = pShape->get_size(); } else { //TODO: Note from LenMus: // lmCompositeShape: the selection rectangle should not be the boundling rectangle // but each rectangle of each component shape. This will save the need to define // specific shapes just to override selection rectangle. i.i. metronome marks //compute new selection rectangle by union of individual selection rectangles URect bbox = get_bounds(); bbox.Union(pShape->get_bounds()); m_origin = bbox.get_top_left(); m_size.width = bbox.get_width(); m_size.height = bbox.get_height(); } //return index to added shape return (int)m_components.size() - 1; }
//--------------------------------------------------------------------------------------- void GmoCompositeShape::recompute_bounds() { URect bbox; std::list<GmoShape*>::iterator it; for (it = m_components.begin(); it != m_components.end(); ++it) bbox.Union((*it)->get_bounds()); m_origin = bbox.get_top_left(); m_size.width = bbox.get_width(); m_size.height = bbox.get_height(); }