# HG changeset patch # User David Bryant # Date 1287387602 -37800 # Node ID a274d16ab6ceda188ff4ea11851a806c12fe6f6d # Parent ad672ab258c5fe97b4e4ca92c86880092018655d struct initialisers diff -r ad672ab258c5 -r a274d16ab6ce doodle/dia/layer_stack.d --- a/doodle/dia/layer_stack.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/dia/layer_stack.d Mon Oct 18 18:10:02 2010 +1030 @@ -11,7 +11,7 @@ Rectangle bounds() const { // Take the union of all layer bounds - Rectangle bounds = Rectangle.DEFAULT; + Rectangle bounds; foreach (layer; _layers) { bounds = bounds | layer.bounds; } return bounds; } diff -r ad672ab258c5 -r a274d16ab6ce doodle/dia/page_layer.d --- a/doodle/dia/page_layer.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/dia/page_layer.d Mon Oct 18 18:10:02 2010 +1030 @@ -10,8 +10,8 @@ class PageLayer : Layer, IPage { this(in string name = "Page") { super(name); - _pageGeometry = Rectangle(Point.DEFAULT, Vector(210.0, 297.0)); - //_pageGeometry = Rectangle(Point.DEFAULT, Vector(100.0, 100.0)); + _pageGeometry = Rectangle(Point(), Vector(210.0, 297.0)); + //_pageGeometry = Rectangle(Point(), Vector(100.0, 100.0)); } // Layer overrides: diff -r ad672ab258c5 -r a274d16ab6ce doodle/fig/diagram_layer.d --- a/doodle/fig/diagram_layer.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/fig/diagram_layer.d Mon Oct 18 18:10:02 2010 +1030 @@ -25,7 +25,7 @@ Rectangle bounds = Rectangle.DEFAULT; foreach (element; _elements) { bounds = bounds | element.bounds; } */ - return Rectangle.DEFAULT; + return Rectangle(); } override void draw(in Rectangle screenDamage, scope Renderer screenRenderer, diff -r ad672ab258c5 -r a274d16ab6ce doodle/gtk/cairo_canvas.d --- a/doodle/gtk/cairo_canvas.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/gtk/cairo_canvas.d Mon Oct 18 18:10:02 2010 +1030 @@ -39,8 +39,6 @@ this(in Layer[] layers, IEventHandler eventHandler, IGrid grid, in double pixelsPerMillimetre) { super(3, 3, 0); - _damageScreen = Rectangle.DEFAULT; - _eventHandler = eventHandler; _grid = grid; _pixelsPerMillimetre = pixelsPerMillimetre; @@ -410,7 +408,7 @@ int x, y, w, h; _damageScreen.getQuantised(x, y, w, h); _drawingArea.queueDrawArea(x, cast(int)_screenModel.viewBoundsScreen.h - (y + h), w, h); - _damageScreen = Rectangle.DEFAULT; + _damageScreen = Rectangle(); } } diff -r ad672ab258c5 -r a274d16ab6ce doodle/tk/geometry.d --- a/doodle/tk/geometry.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/tk/geometry.d Mon Oct 18 18:10:02 2010 +1030 @@ -24,8 +24,6 @@ // struct Point { - static immutable Point DEFAULT = Point(0.0, 0.0); - this(in double x, in double y) { _x = x; _y = y; @@ -51,7 +49,7 @@ double y() const { return _y; } private { - double _x, _y; + double _x = 0.0, _y = 0.0; } } @@ -68,8 +66,6 @@ // struct Vector { - static Vector DEFAULT = Vector(0.0, 0.0); - this(in double x, in double y) { _x = x; _y = y; @@ -109,7 +105,7 @@ double y() const { return _y; } private { - double _x, _y; + double _x = 0.0, _y = 0.0; } } @@ -135,12 +131,6 @@ // struct Rectangle { - static Rectangle DEFAULT; - - static this() { - DEFAULT = Rectangle(Point.DEFAULT, Vector.DEFAULT); - } - /* static Rectangle from_arbitrary_corners(in Point corner1, in Point corner) { } @@ -177,14 +167,14 @@ // Intersection Rectangle opAnd(in Rectangle r) const { if (invalid() || r.invalid()) { - return DEFAULT; + return Rectangle(); } else { Point max = minExtents(corner1(), r.corner1()); Point min = maxExtents(corner0(), r.corner0()); if (max.x < min.x || max.y < min.y) { - return DEFAULT; + return Rectangle(); } else { return Rectangle(min, max); diff -r ad672ab258c5 -r a274d16ab6ce doodle/tk/test/test1.d --- a/doodle/tk/test/test1.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/tk/test/test1.d Mon Oct 18 18:10:02 2010 +1030 @@ -6,7 +6,7 @@ void test1() { writefln("*** Test1 ***"); - Point p1 = Point.DEFAULT; + Point p1; Point p2 = p1; // copy construction assert(p1 == p2); // equality assert(!(p1 != p2)); // inequality @@ -14,10 +14,10 @@ assert(p1 == p2); Point p3 = Point(3.0, 5.0); // standard constructor - assert(p3 - p3 == Vector.DEFAULT); // subtraction (point minus point) + assert(p3 - p3 == Vector()); // subtraction (point minus point) Vector v3 = Vector(3.0, 5.0); - assert(p3 - v3 == Point.DEFAULT); // subtraction (point minus vector) + assert(p3 - v3 == Point()); // subtraction (point minus vector) Point p4 = Point(1.0, 10.0); Point p5 = Point(10.0, 1.0); @@ -30,7 +30,7 @@ void test2() { writefln("*** Test2 ***"); - Vector v1 = Vector.DEFAULT; + Vector v1; Vector v2 = v1; // copy construction assert(v1 == v2); // equality assert(!(v1 != v2)); // inequality @@ -38,7 +38,7 @@ Vector v3 = Vector(3.0, 4.0); // standard construction assert(v3 + v3 == Vector(6.0, 8.0)); // addition - assert(v3 - v3 == Vector.DEFAULT); // subtraction + assert(v3 - v3 == Vector()); // subtraction assert(-v3 == Vector(-3.0, -4.0)); // negation assert(v3.length == 5.0); // length assert(2.0 * v3 == Vector(6.0, 8.0)); // scalar multiplication