From 4fa4b9a1359131d861470376a34750211cf1a1ae Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 19 Jan 2017 20:54:24 +0100 Subject: 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 --- libs/canvas/canvas/canvas.h | 8 ++++---- libs/canvas/canvas/item.h | 6 +++--- libs/canvas/canvas/types.h | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'libs/canvas/canvas') diff --git a/libs/canvas/canvas/canvas.h b/libs/canvas/canvas/canvas.h index 7731b8533b..7932705483 100644 --- a/libs/canvas/canvas/canvas.h +++ b/libs/canvas/canvas/canvas.h @@ -95,11 +95,11 @@ public: ArdourCanvas::Color background_color() const { return _bg_color; } /** Called when an item is being destroyed */ - virtual void item_going_away (Item *, boost::optional) {} + virtual void item_going_away (Item *, Rect) {} void item_shown_or_hidden (Item *); void item_visual_property_changed (Item*); - void item_changed (Item *, boost::optional); - void item_moved (Item *, boost::optional); + void item_changed (Item *, Rect); + void item_moved (Item *, Rect); Duple canvas_to_window (Duple const&, bool rounded = true) const; Duple window_to_canvas (Duple const&) const; @@ -224,7 +224,7 @@ public: void pick_current_item (Duple const &, int state); private: - void item_going_away (Item *, boost::optional); + void item_going_away (Item *, Rect); bool send_leave_event (Item const *, double, double) const; Cairo::RefPtr canvas_image; diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index dacb9d559b..517b4401ba 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -136,7 +136,7 @@ public: ScrollGroup* scroll_parent() const { return _scroll_parent; } - boost::optional bounding_box () const; + Rect bounding_box () const; Coord height() const; Coord width() const; @@ -275,10 +275,10 @@ protected: /** true if this item is visible (ie to be drawn), otherwise false */ bool _visible; /** our bounding box before any change that is currently in progress */ - boost::optional _pre_change_bounding_box; + Rect _pre_change_bounding_box; /** our bounding box; may be out of date if _bounding_box_dirty is true */ - mutable boost::optional _bounding_box; + mutable Rect _bounding_box; /** true if _bounding_box might be out of date, false if its definitely not */ mutable bool _bounding_box_dirty; diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h index d0fecf1fda..a3f1b81ea1 100644 --- a/libs/canvas/canvas/types.h +++ b/libs/canvas/canvas/types.h @@ -117,15 +117,15 @@ struct LIBCANVAS_API Rect Coord x1; Coord y1; - boost::optional intersection (Rect const & o) const throw () { + Rect intersection (Rect const & o) const throw () { Rect i (std::max (x0, o.x0), std::max (y0, o.y0), std::min (x1, o.x1), std::min (y1, o.y1)); if (i.x0 > i.x1 || i.y0 > i.y1) { - return boost::optional (); + return Rect(); } - return boost::optional (i); + return i; } Rect extend (Rect const & o) const throw () { @@ -165,6 +165,7 @@ struct LIBCANVAS_API Rect } bool empty() const throw () { return (x0 == x1 && y0 == y1); } + operator bool() const throw () { return !empty(); } Distance width () const throw () { return x1 - x0; -- cgit v1.2.3