diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-11-04 11:56:10 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-11-04 11:56:10 -0500 |
commit | 6473cc7cb431abe71721341c550130e61cf64aa1 (patch) | |
tree | 1f0a2c5783e883d817d4667269abd73d0fdb5afb /libs/canvas/item.cc | |
parent | 08b485db75082a21c3814b0a4517f2b2fc994b77 (diff) |
drop use of bounding box to determine whether an item covers a point; add Item::covers(Duple const&)
Default implementation for Item still uses bounding box, but specializations for Arc (Circle), Polygon, Line and PolyLine have been added
Diffstat (limited to 'libs/canvas/item.cc')
-rw-r--r-- | libs/canvas/item.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index 534ae6d52e..3c3816881a 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -546,6 +546,24 @@ Item::depth () const return d; } +bool +Item::covers (Duple const & point) const +{ + Duple p = canvas_to_item (point); + + if (_bounding_box_dirty) { + compute_bounding_box (); + } + + boost::optional<Rect> r = bounding_box(); + + if (!r) { + return false; + } + + return r.get().contains (p); +} + ostream& ArdourCanvas::operator<< (ostream& o, const Item& i) { |