Mercurial > projects > doodle
view doodle/dia/icanvas.d @ 48:1b4c9ba58673
Stylistic overhaul.
author | daveb |
---|---|
date | Tue, 03 Aug 2010 17:37:21 +0930 |
parents | f2e4e1d29b98 |
children | 576b9fba4677 |
line wrap: on
line source
module doodle.dia.icanvas; public { import doodle.tk.geometry; import doodle.tk.events; import cairo.Context; } private { import std.typecons; } mixin(defineEnum!("Cursor", "DEFAULT", "HAND", "CROSSHAIR")); interface Viewport { void zoomRelative(in Point pixelDatum, in double factor); void panRelative(in Vector pixelDisplacement); void setCursor(in Cursor cursor); // FIXME get rid of these and accumulate damage during event handling void damageModel(in Rectangle area); // FIXME could be an inout parameter of the event handling, or a special scope Damage object that supports growth only void damagePixel(in Rectangle area); // FIXME as above /* // FIXME hoping we won't need anything like this double zoom() const; Point modelToPixel(in Point model) const; Point pixelToModel(in Point pixel) const; Vector modelToPixel(in Vector model) const; Vector pixelToModel(in Vector pixel) const; Rectangle modelToPixel(in Rectangle model) const; Rectangle pixelToModel(in Rectangle model) const; double modelToPixel(in double model) const; double pixelToModel(in double pixel) const; */ } interface EventHandler { bool handleButtonPress(scope Viewport viewport, in ButtonEvent event); bool handleButtonRelease(scope Viewport viewport, in ButtonEvent event); bool handleMotion(scope Viewport viewport, in MotionEvent event); bool handleScroll(scope Viewport viewport, in ScrollEvent event); //bool handleEnter(scope Viewport viewport, CrossingEvent event); //bool handleLeave(scope Viewport viewport, CrossingEvent event); //bool handleFocusIn(scope Viewport viewport, FocusEvent event); //bool handleFocusOut(scope Viewport viewport, FocusEvent event); bool handleKeyPress(scope Viewport viewport, in KeyEvent event); bool handleKeyRelease(scope Viewport viewport, in KeyEvent event); } interface Grid { void zoomChanged(double zoom); // TODO inout? bool snap(in Point a, out Point b) const; } interface Page { // TODO } abstract class Layer { this(in string name) { mName = name.idup; } string name() const { return mName; } Rectangle bounds() const; void draw(in Viewport viewport, in Rectangle pixelDamage, scope Context pixelCr, in Rectangle modelDamage, scope Context modelCr) const; private { invariant string mName; } }