Mercurial > projects > doodle
diff doodle/dia/standard_tools.d @ 58:c63719604adb
Beginnings of creating a rectangle...
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Mon, 09 Aug 2010 21:43:24 +0930 |
parents | 9960c4fbd0dd |
children | 20d6327c4a75 |
line wrap: on
line diff
--- a/doodle/dia/standard_tools.d Sun Aug 08 22:01:54 2010 +0930 +++ b/doodle/dia/standard_tools.d Mon Aug 09 21:43:24 2010 +0930 @@ -11,8 +11,12 @@ } final class PanTool : Tool { + this() { + super("Pan"); + } + override bool handleButtonPress(scope IViewport viewport, in ButtonEvent event) { - if (event.button_name == ButtonName.MIDDLE) { + if (event.buttonName == ButtonName.MIDDLE) { mLastPosition = event.pixelPoint; return true; } @@ -62,11 +66,15 @@ private { Point mLastPosition; - static invariant double AMOUNT = 60.0; + static immutable double AMOUNT = 60.0; } } final class ZoomTool : Tool { + this() { + super("Zoom"); + } + override bool handleScroll(scope IViewport viewport, in ScrollEvent event) { if (event.mask.isSet(Modifier.CONTROL)) { if (event.scrollDirection == ScrollDirection.DOWN) { @@ -87,13 +95,17 @@ } private { - static invariant double ZOOM = sqrt(2.0); + static immutable double ZOOM = sqrt(2.0); } } final class SelectTool : Tool { + this() { + super("Select"); + } + override bool handleButtonPress(scope IViewport viewport, in ButtonEvent event) { - if (event.button_name == ButtonName.LEFT) { + if (event.buttonName == ButtonName.LEFT) { _active = true; _anchorPoint = _currentPoint = event.pixelPoint; viewport.setCursor(Cursor.HAND); @@ -105,7 +117,7 @@ } override bool handleButtonRelease(scope IViewport viewport, in ButtonEvent event) { - if (event.button_name == ButtonName.LEFT && _active) { + if (event.buttonName == ButtonName.LEFT && _active) { _active = false; viewport.damagePixel(feather(Rectangle(_anchorPoint, _currentPoint), LINE_WIDTH / 2.0)); viewport.setCursor(Cursor.DEFAULT); @@ -152,6 +164,6 @@ bool _active; Point _currentPoint; Point _anchorPoint; // Pixel - static invariant double LINE_WIDTH = 1.0; + static immutable double LINE_WIDTH = 1.0; } }