changeset 68:64bd864db30d

Bah
author daveb
date Fri, 13 Aug 2010 15:53:48 +0930
parents 31d10176415d
children d540f7e4af9e
files doodle/gtk/canvas.d
diffstat 1 files changed, 55 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/doodle/gtk/canvas.d	Fri Aug 13 15:28:04 2010 +0930
+++ b/doodle/gtk/canvas.d	Fri Aug 13 15:53:48 2010 +0930
@@ -50,7 +50,7 @@
 //   zoom about a point (hold control and move scroll wheel)
 //   resize the widget
 
-final class Canvas : Table, IViewport {
+final class Canvas : Table, private IViewport {
     this(in Layer[] layers, IEventHandler eventHandler, IGrid grid, in double ppi) {
         super(3, 3, 0);
 
@@ -153,65 +153,68 @@
                0, 0);
     }
 
-    // IViewport overrides:
+    protected {         // XXX the compiler complains about unimplemented methods if this is private
 
-    void zoomRelative(in Point pixelDatum, in double factor) {
-        // Work out pixel distance from current centre to datum,
-        // Do the zoom, then work out the new centre that keeps the
-        // pixel distance the same
+        // IViewport overrides:
 
-        Point oldModelDatum = pixelToModel(pixelDatum);
-        Vector pixelDistance = modelToPixel(oldModelDatum - _viewCentre);
-        _zoom = clampZoom(factor * _zoom);
-        _viewCentre = oldModelDatum - pixelToModel(pixelDistance);
-
-        consolidateBounds;
-
-        updateAdjustments;
-        updateRulers;
-        _grid.zoomChanged(_zoom);
-        queueDraw;
-    }
-
-    void panRelative(in Vector pixelDisplacement) {
-        _viewCentre = _viewCentre + pixelToModel(pixelDisplacement);
+        void zoomRelative(in Point pixelDatum, in double factor) {
+            // Work out pixel distance from current centre to datum,
+            // Do the zoom, then work out the new centre that keeps the
+            // pixel distance the same
 
-        consolidateBounds;
-
-        updateAdjustments;
-        updateRulers;
-        queueDraw;
-    }
-
-    void setCursor(in Cursor cursor) {
-        CursorType cursorType;
+            Point oldModelDatum = pixelToModel(pixelDatum);
+            Vector pixelDistance = modelToPixel(oldModelDatum - _viewCentre);
+            _zoom = clampZoom(factor * _zoom);
+            _viewCentre = oldModelDatum - pixelToModel(pixelDistance);
 
-        switch (cursor) {
-        case Cursor.DEFAULT:
-            cursorType = CursorType.ARROW;
-            break;
-        case Cursor.HAND:
-            cursorType = CursorType.HAND1;
-            break;
-        case Cursor.CROSSHAIR:
-            cursorType = CursorType.CROSSHAIR;
-            break;
-        case Cursor.PENCIL:
-            cursorType = CursorType.PENCIL;
-            break;
-        default:
-            assert(0);
+            consolidateBounds;
+
+            updateAdjustments;
+            updateRulers;
+            _grid.zoomChanged(_zoom);
+            queueDraw;
         }
 
-        _drawingArea.setCursor(new gdk.Cursor.Cursor(cursorType));
-    }
+        void panRelative(in Vector pixelDisplacement) {
+            _viewCentre = _viewCentre + pixelToModel(pixelDisplacement);
+
+            consolidateBounds;
+
+            updateAdjustments;
+            updateRulers;
+            queueDraw;
+        }
+
+        void setCursor(in Cursor cursor) {
+            CursorType cursorType;
 
-    void damageModel(in Rectangle area) {
-        _damage = _damage | modelToPixel(area);
-    }
+            switch (cursor) {
+            case Cursor.DEFAULT:
+                cursorType = CursorType.ARROW;
+                break;
+            case Cursor.HAND:
+                cursorType = CursorType.HAND1;
+                break;
+            case Cursor.CROSSHAIR:
+                cursorType = CursorType.CROSSHAIR;
+                break;
+            case Cursor.PENCIL:
+                cursorType = CursorType.PENCIL;
+                break;
+            default:
+                assert(0);
+            }
 
-    void damagePixel(in Rectangle area) {
-        _damage = _damage | area;
+            _drawingArea.setCursor(new gdk.Cursor.Cursor(cursorType));
+        }
+
+        void damageModel(in Rectangle area) {
+            _damage = _damage | modelToPixel(area);
+        }
+
+        void damagePixel(in Rectangle area) {
+            _damage = _damage | area;
+        }
     }
 
     private {