13
0

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
This commit is contained in:
Paul Davis 2015-02-09 16:41:28 -05:00
parent 736038556f
commit c679d616f6
2 changed files with 31 additions and 3 deletions

View File

@ -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

View File

@ -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;