Mercurial > projects > doodle
comparison doodle/dia/tool_layer.d @ 36:188397ef9a12
Late night tinkering
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 23:36:31 +0930 |
parents | 1754cb773d41 |
children | 1b4c9ba58673 |
comparison
equal
deleted
inserted
replaced
35:3f6bb0bb22dc | 36:188397ef9a12 |
---|---|
1 module doodle.dia.tool_layer; | 1 module doodle.dia.tool_layer; |
2 | |
3 public { | |
4 import doodle.dia.tool; | |
5 } | |
2 | 6 |
3 private { | 7 private { |
4 import std.stdio; | 8 import std.stdio; |
5 import doodle.cairo.routines; | 9 import doodle.cairo.routines; |
6 } | |
7 | |
8 public { | |
9 import doodle.dia.tool; | |
10 } | 10 } |
11 | 11 |
12 class ToolLayer : Layer, EventHandler { | 12 class ToolLayer : Layer, EventHandler { |
13 this(in Tool[] tools, in string name) { | 13 this(in Tool[] tools, in string name) { |
14 super(name); | 14 super(name); |
15 mTools = tools.dup; | 15 mTools = tools.dup; |
16 } | 16 } |
17 | |
18 // Layer overrides: | |
19 | |
20 override Rectangle bounds() const { | |
21 return Rectangle(); | |
22 } | |
23 | |
24 override void draw(const Viewport viewport, | |
25 in Rectangle pixel_damage, scope Context pixel_cr, | |
26 in Rectangle model_damage, scope Context model_cr) const { | |
27 // FIXME this isn't how we will really draw the tools... | |
28 foreach (const Tool tool; mTools) { | |
29 tool.draw(viewport, pixel_damage, pixel_cr, model_damage, model_cr); | |
30 } | |
31 } | |
32 | |
33 // EventHandler overrides: | |
17 | 34 |
18 override bool handle_button_press(scope Viewport viewport, in ButtonEvent event) { | 35 override bool handle_button_press(scope Viewport viewport, in ButtonEvent event) { |
19 // writefln("%s", event); | 36 // writefln("%s", event); |
20 | 37 |
21 if (mGrabbedTool is null) { | 38 if (mGrabbedTool is null) { |
92 } | 109 } |
93 | 110 |
94 return true; | 111 return true; |
95 } | 112 } |
96 | 113 |
97 override Rectangle bounds() const { | |
98 return Rectangle(); | |
99 } | |
100 | |
101 override void draw(const Viewport viewport, | |
102 in Rectangle pixel_damage, scope Context pixel_cr, | |
103 in Rectangle model_damage, scope Context model_cr) const { | |
104 // FIXME this isn't how we will really draw the tools... | |
105 foreach (const Tool tool; mTools) { | |
106 tool.draw(viewport, pixel_damage, pixel_cr, model_damage, model_cr); | |
107 } | |
108 } | |
109 | |
110 /* | 114 /* |
111 override void push(Tool tool) { | 115 override void push(Tool tool) { |
112 } | 116 } |
113 | 117 |
114 override void pop() { | 118 override void pop() { |