diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-22 11:41:05 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-22 11:41:05 -0400 |
commit | 6a5d805b383cd71bb1d0984964439c5ec08e9270 (patch) | |
tree | d551b417d1dbc026376207a94b4933a0b824797b /libs/canvas/item.cc | |
parent | f0933bf00551ce998ca441aa5611d27702f6e590 (diff) |
more canvas refactoring.
Remove Canvas::Layout, use Canvas::Container for the same purpose, move child-rendering into Item::render_children() so that it
could theoretically be used by any derived type.
Diffstat (limited to 'libs/canvas/item.cc')
-rw-r--r-- | libs/canvas/item.cc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index e58411f17f..2d4f03a41f 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -674,6 +674,96 @@ Item::covers (Duple const & point) const /* nesting/grouping API */ void +Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const +{ + if (_items.empty()) { + return; + } + + ensure_lut (); + std::vector<Item*> items = _lut->get (area); + +#ifdef CANVAS_DEBUG + if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + cerr << string_compose ("%1%7 %2 @ %7 render %5 @ %6 %3 items out of %4\n", + _canvas->render_indent(), (name.empty() ? string ("[unnamed]") : name), items.size(), _items.size(), area, _position, this, + whatami()); + } +#endif + + ++render_depth; + + for (std::vector<Item*>::const_iterator i = items.begin(); i != items.end(); ++i) { + + if (!(*i)->visible ()) { +#ifdef CANVAS_DEBUG + if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] invisible - skipped\n"; + } +#endif + continue; + } + + boost::optional<Rect> item_bbox = (*i)->bounding_box (); + + if (!item_bbox) { +#ifdef CANVAS_DEBUG + if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] empty - skipped\n"; + } +#endif + continue; + } + + Rect item = (*i)->item_to_window (item_bbox.get()); + boost::optional<Rect> d = item.intersection (area); + + if (d) { + Rect draw = d.get(); + if (draw.width() && draw.height()) { +#ifdef CANVAS_DEBUG + if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (dynamic_cast<Container*>(*i) == 0) { + cerr << _canvas->render_indent() << "render " + << ' ' + << (*i) + << ' ' + << (*i)->whatami() + << ' ' + << (*i)->name + << " item " + << item_bbox.get() + << " window = " + << item + << " intersect = " + << draw + << " @ " + << _position + << endl; + } + } +#endif + + (*i)->render (area, context); + ++render_count; + } + + } else { + +#ifdef CANVAS_DEBUG + if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + cerr << string_compose ("%1skip render of %2 %3, no intersection between %4 and %5\n", _canvas->render_indent(), (*i)->whatami(), + (*i)->name, item, area); + } +#endif + + } + } + + --render_depth; +} + +void Item::add_child_bounding_boxes() const { boost::optional<Rect> self; |