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
|
10
|
9 interface Viewport {
|
26
|
10 void zoom_relative(in Point pixel_datum, in double factor);
|
|
11 void pan_relative(in Vector pixel_displacement);
|
|
12 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
|
|
13 void damage_pixel(in Rectangle area); // FIXME as above
|
10
|
14
|
17
|
15 // FIXME not sure about these:
|
11
|
16 double zoom() const;
|
26
|
17 Point model_to_pixel(in Point model) const;
|
|
18 Point pixel_to_model(in Point pixel) const;
|
|
19 Vector model_to_pixel(in Vector model) const;
|
|
20 Vector pixel_to_model(in Vector pixel) const;
|
|
21 Rectangle model_to_pixel(in Rectangle model) const;
|
|
22 Rectangle pixel_to_model(in Rectangle model) const;
|
|
23 double model_to_pixel(in double model) const;
|
|
24 double pixel_to_model(in double pixel) const;
|
0
|
25 }
|
|
26
|
10
|
27 interface EventHandler {
|
26
|
28 bool handle_button_press(scope Viewport viewport, in ButtonEvent event);
|
|
29 bool handle_button_release(scope Viewport viewport, in ButtonEvent event);
|
|
30 bool handle_motion(scope Viewport viewport, in MotionEvent event);
|
|
31 bool handle_scroll(scope Viewport viewport, in ScrollEvent event);
|
|
32 //bool handle_enter(scope Viewport viewport, CrossingEvent event);
|
|
33 //bool handle_leave(scope Viewport viewport, CrossingEvent event);
|
|
34 //bool handle_focus_in(scope Viewport viewport, FocusEvent event);
|
|
35 //bool handle_focus_out(scope Viewport viewport, FocusEvent event);
|
|
36 bool handle_key_press(scope Viewport viewport, in KeyEvent event);
|
|
37 bool handle_key_release(scope Viewport viewport, in KeyEvent event);
|
0
|
38 }
|
10
|
39
|
|
40 abstract class Layer {
|
12
|
41 this(in string name) {
|
|
42 mName = name;
|
|
43 }
|
|
44
|
|
45 string name() const { return mName; }
|
|
46
|
11
|
47 Rectangle bounds() const;
|
|
48 //void zoom_changed
|
26
|
49 void draw(in Viewport viewport,
|
19
|
50 in Rectangle pixel_damage, scope Context pixel_cr,
|
|
51 in Rectangle model_damage, scope Context model_cr) const;
|
12
|
52
|
|
53 private {
|
|
54 invariant string mName;
|
|
55 }
|
10
|
56 }
|