diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-03-11 16:27:37 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-03-11 16:27:37 +0100 |
commit | 6697c42e7393ce469e8c58c9407930439208fb2a (patch) | |
tree | 780add2ae9fc7ce03dd9744aff9c3bd34ed5bf85 | |
parent | c93c8f584c02f2f35c0d050ab05eb05520b67586 (diff) |
fix clipped drawing of non-filled rectangles
To avoid artifacts we need clip with a rectangle that is line_width()
larger than our expose area.
Noticed by: corvid <corvid@lavabit.com>
-rw-r--r-- | dw/fltkviewbase.cc | 7 | ||||
-rw-r--r-- | dw/fltkviewbase.hh | 18 |
2 files changed, 14 insertions, 11 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index 97a78edb..437c109a 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -386,8 +386,11 @@ void FltkViewBase::drawRectangle (core::style::Color *color, int x2 = translateCanvasXToViewX (x + width); int y2 = translateCanvasYToViewY (y + height); - clipPoint (&x1, &y1); - clipPoint (&x2, &y2); + // We only support rectangles with line width 1px, so we clip with + // a rectangle 1px wider and higher than what we actually expose. + // This is only really necessary for non-filled rectangles. + clipPoint (&x1, &y1, 1); + clipPoint (&x2, &y2, 1); ::fltk::Rectangle rect (x1, y1, x2 - x1, y2 - y1); if (filled) diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh index fb3f2fe1..ba4cc6d2 100644 --- a/dw/fltkviewbase.hh +++ b/dw/fltkviewbase.hh @@ -26,16 +26,16 @@ private: void draw (const core::Rectangle *rect, DrawType type); void drawChildWidgets (); - inline void clipPoint (int *x, int *y) { + inline void clipPoint (int *x, int *y, int border) { if (exposeArea) { - if (*x < exposeArea->x ()) - *x = exposeArea->x (); - if (*x > exposeArea->r ()) - *x = exposeArea->r (); - if (*y < exposeArea->y ()) - *y = exposeArea->y (); - if (*y > exposeArea->b ()) - *y = exposeArea->b (); + if (*x < exposeArea->x () - border) + *x = exposeArea->x () - border; + if (*x > exposeArea->r () + border) + *x = exposeArea->r () + border; + if (*y < exposeArea->y () - border) + *y = exposeArea->y () - border; + if (*y > exposeArea->b () + border) + *y = exposeArea->b () + border; } } |