Mercurial > projects > doodle
annotate doodle/dia/icanvas.d @ 36:188397ef9a12
Late night tinkering
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 23:36:31 +0930 |
parents | 3f6bb0bb22dc |
children | f2e4e1d29b98 |
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 | |
10 | 16 interface Viewport { |
26 | 17 void zoom_relative(in Point pixel_datum, in double factor); |
18 void pan_relative(in Vector pixel_displacement); | |
27 | 19 void set_cursor(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 |
26 | 22 void damage_model(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 damage_pixel(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; |
26 | 28 Point model_to_pixel(in Point model) const; |
29 Point pixel_to_model(in Point pixel) const; | |
30 Vector model_to_pixel(in Vector model) const; | |
31 Vector pixel_to_model(in Vector pixel) const; | |
32 Rectangle model_to_pixel(in Rectangle model) const; | |
33 Rectangle pixel_to_model(in Rectangle model) const; | |
34 double model_to_pixel(in double model) const; | |
35 double pixel_to_model(in double pixel) const; | |
27 | 36 */ |
0 | 37 } |
38 | |
10 | 39 interface EventHandler { |
26 | 40 bool handle_button_press(scope Viewport viewport, in ButtonEvent event); |
41 bool handle_button_release(scope Viewport viewport, in ButtonEvent event); | |
42 bool handle_motion(scope Viewport viewport, in MotionEvent event); | |
43 bool handle_scroll(scope Viewport viewport, in ScrollEvent event); | |
44 //bool handle_enter(scope Viewport viewport, CrossingEvent event); | |
45 //bool handle_leave(scope Viewport viewport, CrossingEvent event); | |
46 //bool handle_focus_in(scope Viewport viewport, FocusEvent event); | |
47 //bool handle_focus_out(scope Viewport viewport, FocusEvent event); | |
48 bool handle_key_press(scope Viewport viewport, in KeyEvent event); | |
49 bool handle_key_release(scope Viewport viewport, in KeyEvent event); | |
0 | 50 } |
10 | 51 |
35 | 52 interface Grid { |
53 void zoom_changed(double zoom); | |
54 | |
36 | 55 // TODO inout? |
35 | 56 bool snap(in Point a, out Point b) const; |
57 } | |
58 | |
36 | 59 interface Page { |
60 // TODO | |
61 } | |
62 | |
10 | 63 abstract class Layer { |
12 | 64 this(in string name) { |
65 mName = name; | |
66 } | |
67 | |
68 string name() const { return mName; } | |
69 | |
11 | 70 Rectangle bounds() const; |
35 | 71 |
26 | 72 void draw(in Viewport viewport, |
19 | 73 in Rectangle pixel_damage, scope Context pixel_cr, |
74 in Rectangle model_damage, scope Context model_cr) const; | |
12 | 75 |
76 private { | |
77 invariant string mName; | |
78 } | |
10 | 79 } |