canvas items must be able to use fractional positions when rendering.
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Feb 2015 21:40:10 +0000 (16:40 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 9 Feb 2015 21:40:10 +0000 (16:40 -0500)
This is required to be able to draw precise single pixel lines, as described
in the Cairo FAQ

libs/canvas/canvas/item.h
libs/canvas/item.cc

index 308b2437c3961f21a4a0480256b2b3ea351c93a8..60fadabfbda00837d5dec4c42f3c3705a9f8a24c 100644 (file)
@@ -154,7 +154,7 @@ public:
 
         Duple item_to_window (Duple const&, bool rounded = true) const;
         Duple window_to_item (Duple const&) const;
-        Rect item_to_window (Rect const&) const;
+        Rect item_to_window (Rect const&, bool rounded = true) const;
         Rect window_to_item (Rect const&) const;
         
        void raise_to_top ();
index 9a851891d950a9f0605e260704a1972e34c93eff..ab8764a97a9677ad5ac138d4d85c27e054b83bb3 100644 (file)
@@ -231,14 +231,16 @@ Item::window_to_item (ArdourCanvas::Duple const & d) const
 }
 
 ArdourCanvas::Rect
-Item::item_to_window (ArdourCanvas::Rect const & r) const
+Item::item_to_window (ArdourCanvas::Rect const & r, bool rounded) const
 {
        Rect ret = item_to_canvas (r).translate (-scroll_offset());
 
-       ret.x0 = round (ret.x0);
-       ret.x1 = round (ret.x1);
-       ret.y0 = round (ret.y0);
-       ret.y1 = round (ret.y1);
+       if (rounded) {
+               ret.x0 = round (ret.x0);
+               ret.x1 = round (ret.x1);
+               ret.y0 = round (ret.y0);
+               ret.y1 = round (ret.y1);
+       }
 
        return ret;
 }
@@ -766,7 +768,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
                        continue;
                }
                
-               Rect item = (*i)->item_to_window (item_bbox.get());
+               Rect item = (*i)->item_to_window (item_bbox.get(), false);
                boost::optional<Rect> d = item.intersection (area);
                
                if (d) {