diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-06-18 08:23:06 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-06-18 08:23:06 -0400 |
commit | 77f5f4c4bf9074d953a1653658c8f96f38ae258c (patch) | |
tree | 08790670f6435eed917ab3f2629a0373652cbc1e /libs/canvas/rectangle.cc | |
parent | a0c5de281a2ba029a9af53a6ffe3a717280998b3 (diff) |
basically operational switch to canvas drawing coordinates, although text and waves don't work, and redraw areas are too small
Diffstat (limited to 'libs/canvas/rectangle.cc')
-rw-r--r-- | libs/canvas/rectangle.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index bb1198c1bb..7abf13216b 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -50,7 +50,7 @@ Rectangle::Rectangle (Group* parent, Rect const & rect) } void -Rectangle::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const +Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const { /* Cairo goes a little (!) wrong when asked to fill/stroke rectangles that * extend way beyond the surface boundaries. To avoid this issue, @@ -58,17 +58,13 @@ Rectangle::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) * canvas, converting to item-space coordinates, of course. */ - Rect plot = _rect; - Rect visible = _canvas->visible_area(); - Duple visible_end = canvas_to_item (Duple (visible.x1, visible.y1)); + Rect self = item_to_window (_rect); + boost::optional<Rect> draw = self.intersection (area); - plot.x1 = min (plot.x1, visible_end.x); - plot.y1 = min (plot.y1, visible_end.y); - - if (_fill) { + if (_fill && draw) { setup_fill_context (context); - cerr << "Fill rect: " << plot << endl; - context->rectangle (plot.x0, plot.y0, plot.width(), plot.height()); + + context->rectangle (draw->x0, draw->y0, draw->width(), draw->height()); if (!_outline) { context->fill (); @@ -100,30 +96,30 @@ Rectangle::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) */ if (!_fill) { - context->rectangle (plot.x0, plot.y0, plot.width(), plot.height()); + context->rectangle (draw->x0, draw->y0, draw->width(), draw->height()); context->stroke (); } } else { if (_outline_what & LEFT) { - context->move_to (plot.x0, plot.y0); - context->line_to (plot.x0, plot.y1); + context->move_to (draw->x0, draw->y0); + context->line_to (draw->x0, draw->y1); } if (_outline_what & BOTTOM) { - context->move_to (plot.x0, plot.y1); - context->line_to (plot.x1, plot.y1); + context->move_to (draw->x0, draw->y1); + context->line_to (draw->x1, draw->y1); } if (_outline_what & RIGHT) { - context->move_to (plot.x1, plot.y0); - context->line_to (plot.x1, plot.y1); + context->move_to (draw->x1, draw->y0); + context->line_to (draw->x1, draw->y1); } if (_outline_what & TOP) { - context->move_to (plot.x0, plot.y0); - context->line_to (plot.x1, plot.y0); + context->move_to (draw->x0, draw->y0); + context->line_to (draw->x1, draw->y0); } context->stroke (); |