22
|
1 module dia.icanvas;
|
0
|
2
|
26
|
3 public {
|
|
4 import tk.geometry;
|
|
5 import tk.events;
|
|
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);
|
26
|
20 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
|
|
21 void damage_pixel(in Rectangle area); // FIXME as above
|
10
|
22
|
27
|
23 /*
|
17
|
24 // FIXME not sure about these:
|
11
|
25 double zoom() const;
|
26
|
26 Point model_to_pixel(in Point model) const;
|
|
27 Point pixel_to_model(in Point pixel) const;
|
|
28 Vector model_to_pixel(in Vector model) const;
|
|
29 Vector pixel_to_model(in Vector pixel) const;
|
|
30 Rectangle model_to_pixel(in Rectangle model) const;
|
|
31 Rectangle pixel_to_model(in Rectangle model) const;
|
|
32 double model_to_pixel(in double model) const;
|
|
33 double pixel_to_model(in double pixel) const;
|
27
|
34 */
|
0
|
35 }
|
|
36
|
10
|
37 interface EventHandler {
|
26
|
38 bool handle_button_press(scope Viewport viewport, in ButtonEvent event);
|
|
39 bool handle_button_release(scope Viewport viewport, in ButtonEvent event);
|
|
40 bool handle_motion(scope Viewport viewport, in MotionEvent event);
|
|
41 bool handle_scroll(scope Viewport viewport, in ScrollEvent event);
|
|
42 //bool handle_enter(scope Viewport viewport, CrossingEvent event);
|
|
43 //bool handle_leave(scope Viewport viewport, CrossingEvent event);
|
|
44 //bool handle_focus_in(scope Viewport viewport, FocusEvent event);
|
|
45 //bool handle_focus_out(scope Viewport viewport, FocusEvent event);
|
|
46 bool handle_key_press(scope Viewport viewport, in KeyEvent event);
|
|
47 bool handle_key_release(scope Viewport viewport, in KeyEvent event);
|
0
|
48 }
|
10
|
49
|
|
50 abstract class Layer {
|
12
|
51 this(in string name) {
|
|
52 mName = name;
|
|
53 }
|
|
54
|
|
55 string name() const { return mName; }
|
|
56
|
11
|
57 Rectangle bounds() const;
|
|
58 //void zoom_changed
|
26
|
59 void draw(in Viewport viewport,
|
19
|
60 in Rectangle pixel_damage, scope Context pixel_cr,
|
|
61 in Rectangle model_damage, scope Context model_cr) const;
|
12
|
62
|
|
63 private {
|
|
64 invariant string mName;
|
|
65 }
|
10
|
66 }
|