diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2017-01-19 20:54:24 +0100 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2017-01-19 20:54:54 +0100 |
commit | 4fa4b9a1359131d861470376a34750211cf1a1ae (patch) | |
tree | 83d0395d654f9225c258456aa9e68b3ab334f945 /libs/canvas/item.cc | |
parent | 758f183b99dadd173cc5b0f8b9e76f6cc3e02159 (diff) |
remove use of boost::optional to define "undefined" Canvas::Rect, and use Rect::empty instead.
This commit includes Rect::operator bool() which might be a candidate for removal in a future commit, in an attempt
to make the meaning clearer
Diffstat (limited to 'libs/canvas/item.cc')
-rw-r--r-- | libs/canvas/item.cc | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index 706a62b717..06ad24f2e6 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -259,14 +259,14 @@ Item::set_position (Duple p) return; } - boost::optional<ArdourCanvas::Rect> bbox = bounding_box (); - boost::optional<ArdourCanvas::Rect> pre_change_parent_bounding_box; + ArdourCanvas::Rect bbox = bounding_box (); + ArdourCanvas::Rect pre_change_parent_bounding_box; if (bbox) { /* see the comment in Canvas::item_moved() to understand * why we use the parent's bounding box here. */ - pre_change_parent_bounding_box = item_to_parent (bbox.get()); + pre_change_parent_bounding_box = item_to_parent (bbox); } _position = p; @@ -572,7 +572,7 @@ Item::grab_focus () } /** @return Bounding box in this item's coordinates */ -boost::optional<ArdourCanvas::Rect> +ArdourCanvas::Rect Item::bounding_box () const { if (_bounding_box_dirty) { @@ -587,10 +587,10 @@ Item::bounding_box () const Coord Item::height () const { - boost::optional<ArdourCanvas::Rect> bb = bounding_box(); + ArdourCanvas::Rect bb = bounding_box(); if (bb) { - return bb->height (); + return bb.height (); } return 0; } @@ -598,10 +598,10 @@ Item::height () const Coord Item::width () const { - boost::optional<ArdourCanvas::Rect> bb = bounding_box(); + ArdourCanvas::Rect bb = bounding_box(); if (bb) { - return bb->width (); + return bb.width (); } return 0; @@ -611,7 +611,7 @@ void Item::redraw () const { if (visible() && _bounding_box && _canvas) { - _canvas->request_redraw (item_to_window (_bounding_box.get())); + _canvas->request_redraw (item_to_window (_bounding_box)); } } @@ -717,13 +717,13 @@ Item::covers (Duple const & point) const compute_bounding_box (); } - boost::optional<Rect> r = bounding_box(); + Rect r = bounding_box(); if (!r) { return false; } - return r.get().contains (p); + return r.contains (p); } /* nesting/grouping API */ @@ -759,7 +759,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) continue; } - boost::optional<Rect> item_bbox = (*i)->bounding_box (); + Rect item_bbox = (*i)->bounding_box (); if (!item_bbox) { #ifdef CANVAS_DEBUG @@ -770,11 +770,11 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) continue; } - Rect item = (*i)->item_to_window (item_bbox.get(), false); - boost::optional<Rect> d = item.intersection (area); + Rect item = (*i)->item_to_window (item_bbox, false); + Rect d = item.intersection (area); if (d) { - Rect draw = d.get(); + Rect draw = d; if (draw.width() && draw.height()) { #ifdef CANVAS_DEBUG if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { @@ -787,7 +787,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) << ' ' << (*i)->name << " item " - << item_bbox.get() + << item_bbox << " window = " << item << " intersect = " @@ -821,12 +821,12 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) void Item::add_child_bounding_boxes (bool include_hidden) const { - boost::optional<Rect> self; + Rect self; Rect bbox; bool have_one = false; if (_bounding_box) { - bbox = _bounding_box.get(); + bbox = _bounding_box; have_one = true; } @@ -836,13 +836,13 @@ Item::add_child_bounding_boxes (bool include_hidden) const continue; } - boost::optional<Rect> item_bbox = (*i)->bounding_box (); + Rect item_bbox = (*i)->bounding_box (); if (!item_bbox) { continue; } - Rect group_bbox = (*i)->item_to_parent (item_bbox.get ()); + Rect group_bbox = (*i)->item_to_parent (item_bbox); if (have_one) { bbox = bbox.extend (group_bbox); } else { @@ -852,7 +852,7 @@ Item::add_child_bounding_boxes (bool include_hidden) const } if (!have_one) { - _bounding_box = boost::optional<Rect> (); + _bounding_box = Rect (); } else { _bounding_box = bbox; } @@ -1025,11 +1025,11 @@ Item::child_changed () void Item::add_items_at_point (Duple const point, vector<Item const *>& items) const { - boost::optional<Rect> const bbox = bounding_box (); + Rect const bbox = bounding_box (); /* Point is in window coordinate system */ - if (!bbox || !item_to_window (bbox.get()).contains (point)) { + if (!bbox || !item_to_window (bbox).contains (point)) { return; } @@ -1078,7 +1078,7 @@ Item::stop_tooltip_timeout () void Item::dump (ostream& o) const { - boost::optional<ArdourCanvas::Rect> bb = bounding_box(); + ArdourCanvas::Rect bb = bounding_box(); o << _canvas->indent() << whatami() << ' ' << this << " self-Visible ? " << self_visible() << " visible ? " << visible(); o << " @ " << position(); @@ -1090,8 +1090,8 @@ Item::dump (ostream& o) const #endif if (bb) { - o << endl << _canvas->indent() << "\tbbox: " << bb.get(); - o << endl << _canvas->indent() << "\tCANVAS bbox: " << item_to_canvas (bb.get()); + o << endl << _canvas->indent() << "\tbbox: " << bb; + o << endl << _canvas->indent() << "\tCANVAS bbox: " << item_to_canvas (bb); } else { o << " bbox unset"; } @@ -1107,11 +1107,11 @@ Item::dump (ostream& o) const o << " Self-Visible ? " << self_visible(); o << " Visible ? " << visible(); - boost::optional<Rect> bb = bounding_box(); + Rect bb = bounding_box(); if (bb) { - o << endl << _canvas->indent() << " bbox: " << bb.get(); - o << endl << _canvas->indent() << " CANVAS bbox: " << item_to_canvas (bb.get()); + o << endl << _canvas->indent() << " bbox: " << bb; + o << endl << _canvas->indent() << " CANVAS bbox: " << item_to_canvas (bb); } else { o << " bbox unset"; } |