diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-09 16:41:28 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-09 16:41:28 -0500 |
commit | c679d616f6e97c539083782b283cf30033ea4368 (patch) | |
tree | 759429123a7f666c5fd5848d9f2ab36c681c5a50 /libs | |
parent | 736038556fa41607d54a57fd3339d4fd1782bddf (diff) |
correct drawing of rectangle borders.
They need to use fractional coordinates, and the border position needed
generalizing for other border widths. See verbose comment for details
Diffstat (limited to 'libs')
-rw-r--r-- | libs/canvas/canvas.cc | 1 | ||||
-rw-r--r-- | libs/canvas/rectangle.cc | 33 |
2 files changed, 31 insertions, 3 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 941ea8465d..4c4696e0c1 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -787,6 +787,7 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev) /* render canvas */ +#define CANVAS_SINGLE_EXPOSE #ifdef CANVAS_SINGLE_EXPOSE render (Rect (ev->area.x, ev->area.y, ev->area.x + ev->area.width, ev->area.y + ev->area.height), draw_context); #else diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index 364f6c5996..7a4129d30a 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -65,14 +65,14 @@ Rectangle::get_self_for_render () const we should take that into account when rendering. */ - return item_to_window (_rect.translate (_position)); + return item_to_window (_rect.translate (_position), false); } void Rectangle::render_self (Rect const & area, Cairo::RefPtr<Cairo::Context> context, Rect self) const { boost::optional<Rect> r = self.intersection (area); - + if (!r) { return; } @@ -147,7 +147,34 @@ Rectangle::compute_bounding_box () const { if (!_rect.empty()) { Rect r = _rect.fix (); - _bounding_box = r.expand (_outline_width + 0.5); + + /* if the outline is 1 pixel, then the actual + bounding box is 0.5 pixels outside the stated + corners of the rectangle. + + if the outline is 2 pixels, then the actual + bounding box is 1.0 pixels outside the stated + corners of the rectangle (so that the middle + of the 2 pixel wide border passes through + the corners, alternatively described as 1 row + of pixels outside of the corners, and 1 row + inside). + + if the outline is 3 pixels, then the actual + bounding box is 1.5 outside the stated corners + of the rectangle (so that the middle row of + pixels of the border passes through the corners). + + if the outline is 4 pixels, then the actual bounding + box is 2.0 pixels outside the stated corners + of the rectangle, so that the border consists + of 2 pixels outside the corners and 2 pixels inside. + + hence ... the bounding box is width * 0.5 larger + than the rectangle itself. + */ + + _bounding_box = r.expand (_outline_width * 0.5); } _bounding_box_dirty = false; |