Mercurial > projects > doodle
annotate doodle/dia/icanvas.d @ 57:9960c4fbd0dd
I is for Interface
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sun, 08 Aug 2010 22:01:54 +0930 |
parents | 576b9fba4677 |
children | c63719604adb |
rev | line source |
---|---|
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
27
diff
changeset
|
1 module doodle.dia.icanvas; |
0 | 2 |
26 | 3 public { |
28
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
27
diff
changeset
|
4 import doodle.tk.geometry; |
1754cb773d41
Part-way through getting to compile with configure/builder.
Graham St Jack <graham.stjack@internode.on.net>
parents:
27
diff
changeset
|
5 import doodle.tk.events; |
26 | 6 import cairo.Context; |
7 } | |
0 | 8 |
27 | 9 private { |
10 import std.typecons; | |
11 } | |
12 | |
13 mixin(defineEnum!("Cursor", | |
14 "DEFAULT", "HAND", "CROSSHAIR")); | |
15 | |
57 | 16 interface IViewport { |
48 | 17 void zoomRelative(in Point pixelDatum, in double factor); |
18 void panRelative(in Vector pixelDisplacement); | |
19 void setCursor(in Cursor cursor); | |
34
c2f11e1d7470
Geometry cleanup and checkpoint.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
20 |
c2f11e1d7470
Geometry cleanup and checkpoint.
David Bryant <bagnose@gmail.com>
parents:
28
diff
changeset
|
21 // FIXME get rid of these and accumulate damage during event handling |
48 | 22 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 |
23 void damagePixel(in Rectangle area); // FIXME as above | |
10 | 24 |
27 | 25 /* |
35 | 26 // FIXME hoping we won't need anything like this |
11 | 27 double zoom() const; |
48 | 28 Point modelToPixel(in Point model) const; |
29 Point pixelToModel(in Point pixel) const; | |
30 Vector modelToPixel(in Vector model) const; | |
31 Vector pixelToModel(in Vector pixel) const; | |
32 Rectangle modelToPixel(in Rectangle model) const; | |
33 Rectangle pixelToModel(in Rectangle model) const; | |
34 double modelToPixel(in double model) const; | |
35 double pixelToModel(in double pixel) const; | |
27 | 36 */ |
0 | 37 } |
38 | |
57 | 39 interface IEventHandler { |
40 bool handleButtonPress(scope IViewport viewport, in ButtonEvent event); | |
41 bool handleButtonRelease(scope IViewport viewport, in ButtonEvent event); | |
42 bool handleMotion(scope IViewport viewport, in MotionEvent event); | |
43 bool handleScroll(scope IViewport viewport, in ScrollEvent event); | |
44 //bool handleEnter(scope IViewport viewport, CrossingEvent event); | |
45 //bool handleLeave(scope IViewport viewport, CrossingEvent event); | |
46 //bool handleFocusIn(scope IViewport viewport, FocusEvent event); | |
47 //bool handleFocusOut(scope IViewport viewport, FocusEvent event); | |
48 bool handleKeyPress(scope IViewport viewport, in KeyEvent event); | |
49 bool handleKeyRelease(scope IViewport viewport, in KeyEvent event); | |
0 | 50 } |
10 | 51 |
57 | 52 interface IGrid { |
48 | 53 void zoomChanged(double zoom); |
35 | 54 |
36 | 55 // TODO inout? |
35 | 56 bool snap(in Point a, out Point b) const; |
57 } | |
58 | |
57 | 59 interface IPage { |
36 | 60 // TODO |
61 } | |
62 | |
10 | 63 abstract class Layer { |
12 | 64 this(in string name) { |
49 | 65 mName = name; |
12 | 66 } |
67 | |
68 string name() const { return mName; } | |
69 | |
11 | 70 Rectangle bounds() const; |
35 | 71 |
57 | 72 void draw(in IViewport viewport, |
48 | 73 in Rectangle pixelDamage, scope Context pixelCr, |
74 in Rectangle modelDamage, scope Context modelCr) const; | |
12 | 75 |
76 private { | |
77 invariant string mName; | |
78 } | |
10 | 79 } |