Mercurial > projects > doodle
view standard_tools.d @ 3:7d57cae10805
Renamed geometry2 to geometry
author | David Bryant <daveb@acres.com.au> |
---|---|
date | Fri, 10 Jul 2009 15:25:48 +0930 |
parents | d6f44347373d |
children | 936feb16eed4 |
line wrap: on
line source
module standard_tools; final class PanTool : Tool { override bool handle_scroll(ICanvas canvas, ScrollEvent event) { const double AMOUNT = 30.0; Vector v; if (event.mask.query(Modifier.SHIFT)) { // left to right v = new Vector(AMOUNT, 0.0); } else { // down to up v = new Vector(0.0, AMOUNT); } if (event.scroll_direction == ScrollDirection.UP) { v = -v; } canvas.rel_pan(v); return true; } bool handle_button_press(ICanvas canvas, ButtonEvent event) { } bool handle_button_release(ICanvas canvas, ButtonEvent event) { } bool handle_motion(ICanvas canvas, MotionEvent event) { } } final class ZoomTool { static invariant double ZOOM = 1.44; override bool handle_scroll(ICanvas canvas, ScrollEvent event) { if (event.mask.query(Modifier.CONTROL)) { // Zoom about the pointer double zoom = 1.44; if (event.scroll_direction == ScrollDirection.DOWN) { zoom = 1.0 / zoom; } canvas.rel_zoom(event.screen_point(), zoom); return true; } else { return false; } } }