Mercurial > projects > doodle
diff doodle/dia/grid_layer.d @ 36:188397ef9a12
Late night tinkering
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 23:36:31 +0930 |
parents | 3f6bb0bb22dc |
children | 452915ecd1f4 |
line wrap: on
line diff
--- a/doodle/dia/grid_layer.d Sun Aug 30 22:14:01 2009 +0930 +++ b/doodle/dia/grid_layer.d Sun Aug 30 23:36:31 2009 +0930 @@ -22,6 +22,7 @@ this(in string name) { super(name); + mZoomValid = false; } // Layer overrides: @@ -36,8 +37,12 @@ in Rectangle model_damage, scope Context model_cr) const { assert(mZoomValid); + double xx = 1.0, yy = 1.0; + model_cr.userToDeviceDistance(xx, yy); + model_cr.save(); { - model_cr.setLineWidth(1.0); + model_cr.setSourceRgba(0.0, 0.0, 0.0, 0.3); + model_cr.setLineWidth(0.5); { // vertical grid lines @@ -47,7 +52,13 @@ for (;;) { line(model_cr, x, y0, x, y1); - model_cr.stroke(); + + // Ensure 1 pixel wide FIXME is this naughty? We are sneaking + // through cairo to mix model and pixel coordinates... + model_cr.save(); { + model_cr.scale(1.0 / xx, 1.0 / yy); + model_cr.stroke(); + } model_cr.restore(); if (x > model_damage.max_corner.x) { break; @@ -65,7 +76,11 @@ for (;;) { line(model_cr, x0, y, x1, y); - model_cr.stroke(); + + model_cr.save(); { + model_cr.scale(1.0 / xx, 1.0 / yy); + model_cr.stroke(); + } model_cr.restore(); if (y > model_damage.max_corner.y) { break; @@ -75,20 +90,20 @@ } } } model_cr.restore(); - - - //double start_x = modf(damage.min_corner.x, zoom); } // Grid overrides: - void zoom_changed(double zoom) { + override void zoom_changed(double zoom) { mZoom = zoom; mZoomValid = true; - mSpacing = 20.0; // mm + + // FIXME compute spacing properly + mSpacing = 10.0 / mZoom; // mm } - bool snap(in Point a, out Point b) const { + // FIXME use inout parameter? + override bool snap(in Point a, out Point b) const { b = a; return false; }