diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-03 21:33:54 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-03 21:48:08 -0500 |
commit | 56994e785ec49f79e65b2e31535119d85c7100a0 (patch) | |
tree | e9e25a36004a69586d3b308810315d19cc0a19f7 /libs/canvas/rectangle.cc | |
parent | 90825340c9c5ec37c422f71e20e5f4ba0cd56151 (diff) |
add new TimeRectangle to ArdourCanvas
Diffstat (limited to 'libs/canvas/rectangle.cc')
-rw-r--r-- | libs/canvas/rectangle.cc | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index 8ee8319591..c6381776e4 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -56,15 +56,21 @@ Rectangle::Rectangle (Item* parent, Rect const & rect) { } -void -Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const +Rect +Rectangle::get_self_for_render () const { /* In general, a Rectangle will have a _position of (0,0) within its parent, and its extent is actually defined by _rect. But in the unusual case that _position is set to something other than (0,0), we should take that into account when rendering. */ - Rect self = item_to_window (_rect.translate (_position)); + + return item_to_window (_rect.translate (_position)); +} + +void +Rectangle::render_self (Rect const & area, Cairo::RefPtr<Cairo::Context> context, Rect self) const +{ boost::optional<Rect> r = self.intersection (area); if (!r) { @@ -105,10 +111,8 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con * the 0.5 pixel additions. */ - self = self.translate (Duple (-0.5, -0.5)); + self = self.translate (Duple (0.5, 0.5)); - std::cerr << "Outline using " << self << " from " << _rect << std::endl; - if (_outline_what == What (LEFT|RIGHT|BOTTOM|TOP)) { context->rectangle (self.x0, self.y0, self.width(), self.height()); @@ -141,6 +145,12 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con } void +Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const +{ + render_self (area, context, get_self_for_render ()); +} + +void Rectangle::compute_bounding_box () const { if (!_rect.empty()) { @@ -238,3 +248,36 @@ Rectangle::set_outline_what (What what) } } + +/*-------------------*/ + +void +TimeRectangle::compute_bounding_box () const +{ + Rectangle::compute_bounding_box (); + assert (_bounding_box); + + Rect r = _bounding_box.get (); + + /* This is a TimeRectangle, so its right edge is drawn 1 pixel beyond + * (larger x-axis coordinates) than a normal Rectangle. + */ + + r.x1 += 1.0; /* this should be using safe_add() */ + + _bounding_box = r; +} + +void +TimeRectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const +{ + Rect self = get_self_for_render (); + + + /* This is a TimeRectangle, so its right edge is drawn 1 pixel beyond + * (larger x-axis coordinates) than a normal Rectangle. + */ + + self.x1 += 1.0; /* this should be using safe_add() */ + render_self (area, context, self); +} |