Mercurial > projects > doodle
view standard_tools.d @ 6:a27d2093991c
Checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sat, 11 Jul 2009 20:44:14 +0930 |
parents | 7d57cae10805 |
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; } } }