diff options
Diffstat (limited to 'src/tests/testLayers.cc')
-rw-r--r-- | src/tests/testLayers.cc | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/src/tests/testLayers.cc b/src/tests/testLayers.cc new file mode 100644 index 0000000..59a5d01 --- /dev/null +++ b/src/tests/testLayers.cc | |||
@@ -0,0 +1,222 @@ | |||
1 | #include "App.hh" | ||
2 | #include "FbWindow.hh" | ||
3 | #include "Color.hh" | ||
4 | #include "EventManager.hh" | ||
5 | #include <iostream> | ||
6 | #include "XLayer.hh" | ||
7 | #include "XLayerItem.hh" | ||
8 | #include "MultLayers.hh" | ||
9 | |||
10 | using namespace FbTk; | ||
11 | using namespace std; | ||
12 | int main() { | ||
13 | FbTk::App app; | ||
14 | int mask = ButtonPressMask; | ||
15 | FbWindow win_red(0, 0, 0, 60, 60, mask, true); | ||
16 | FbWindow win_redB(0, 0, 0, 60, 60, mask, true); | ||
17 | FbWindow win_blue(0, 30, 0, 60, 60, mask, true); | ||
18 | FbWindow win_green(0, 60, 0, 60, 60, mask, true); | ||
19 | FbWindow win_red2(0, 0, 0, 60, 60, mask, true); | ||
20 | FbWindow win_blue2(0, 30, 0, 60, 60, mask, true); | ||
21 | FbWindow win_green2(0, 60, 0, 60, 60, mask, true); | ||
22 | FbWindow win_red3(0, 0, 0, 60, 60, mask, true); | ||
23 | FbWindow win_blue3(0, 30, 0, 60, 60, mask, true); | ||
24 | FbWindow win_green3(0, 60, 0, 60, 60, mask, true); | ||
25 | Color red("red", 0); | ||
26 | Color blue("blue", 0); | ||
27 | Color green("green", 0); | ||
28 | Color red2("magenta", 0); | ||
29 | Color blue2("cyan", 0); | ||
30 | Color green2("yellow", 0); | ||
31 | Color red3("pink", 0); | ||
32 | Color blue3("navy", 0); | ||
33 | Color green3("brown", 0); | ||
34 | win_red.setBackgroundColor(red); | ||
35 | win_red.clear(); | ||
36 | win_redB.setBackgroundColor(red); | ||
37 | win_redB.clear(); | ||
38 | win_blue.setBackgroundColor(blue); | ||
39 | win_blue.clear(); | ||
40 | win_green.setBackgroundColor(green); | ||
41 | win_green.clear(); | ||
42 | |||
43 | win_red2.setBackgroundColor(red2); | ||
44 | win_red2.clear(); | ||
45 | win_blue2.setBackgroundColor(blue2); | ||
46 | win_blue2.clear(); | ||
47 | win_green2.setBackgroundColor(green2); | ||
48 | win_green2.clear(); | ||
49 | |||
50 | win_red3.setBackgroundColor(red3); | ||
51 | win_red3.clear(); | ||
52 | win_blue3.setBackgroundColor(blue3); | ||
53 | win_blue3.clear(); | ||
54 | win_green3.setBackgroundColor(green3); | ||
55 | win_green3.clear(); | ||
56 | |||
57 | win_red.show(); | ||
58 | win_red.move(10, 10); | ||
59 | win_redB.show(); | ||
60 | win_redB.move(30, 30); | ||
61 | win_blue.show(); | ||
62 | win_blue.move(40, 40); | ||
63 | win_green.show(); | ||
64 | win_green.move(50, 20); | ||
65 | |||
66 | win_red2.show(); | ||
67 | win_red2.move(15, 15); | ||
68 | win_blue2.show(); | ||
69 | win_blue2.move(45, 45); | ||
70 | win_green2.show(); | ||
71 | win_green2.move(45, 15); | ||
72 | |||
73 | /* | ||
74 | win_red3.show(); | ||
75 | win_red3.move(5, 5); | ||
76 | win_blue3.show(); | ||
77 | win_blue3.move(35, 35); | ||
78 | win_green3.show(); | ||
79 | win_green3.move(45, 5); | ||
80 | */ | ||
81 | |||
82 | EventManager &evm = *EventManager::instance(); | ||
83 | Display *disp = app.display(); | ||
84 | XEvent event; | ||
85 | MultLayers *ml = new MultLayers(3); | ||
86 | XLayerItem *item_red = new XLayerItem(win_red.window()); | ||
87 | item_red->addWindow(win_redB.window()); | ||
88 | XLayerItem *item_green = new XLayerItem(win_green.window()); | ||
89 | XLayerItem *item_blue = new XLayerItem(win_blue.window()); | ||
90 | |||
91 | ml->addToTop(*item_blue, 0); | ||
92 | ml->addToTop(*item_green, 0); | ||
93 | ml->addToTop(*item_red, 0); | ||
94 | |||
95 | XLayerItem *item_red2 = new XLayerItem(win_red2.window()); | ||
96 | XLayerItem *item_green2 = new XLayerItem(win_green2.window()); | ||
97 | XLayerItem *item_blue2 = new XLayerItem(win_blue2.window()); | ||
98 | |||
99 | ml->addToTop(*item_blue2, 1); | ||
100 | ml->addToTop(*item_green2, 1); | ||
101 | ml->addToTop(*item_red2, 1); | ||
102 | |||
103 | XLayerItem *item_red3 = new XLayerItem(win_red3.window()); | ||
104 | XLayerItem *item_green3 = new XLayerItem(win_green3.window()); | ||
105 | XLayerItem *item_blue3 = new XLayerItem(win_blue3.window()); | ||
106 | |||
107 | ml->addToTop(*item_blue3, 2); | ||
108 | ml->addToTop(*item_green3, 2); | ||
109 | ml->addToTop(*item_red3, 2); | ||
110 | |||
111 | //item_blue.setLayer(*layer); | ||
112 | //item_green.setLayer(*layer); | ||
113 | //item_red.setLayer(*layer); | ||
114 | cerr<<"red: "<<hex<<win_red.window()<<endl; | ||
115 | cerr<<"blue: "<<hex<<win_blue.window()<<endl; | ||
116 | cerr<<"green: "<<hex<<win_green.window()<<endl; | ||
117 | cerr<<"Left click on color to raise one step"<<endl; | ||
118 | cerr<<"Right click on color to raise to next level up"<<endl; | ||
119 | cerr<<"Middle click on color to lower to next level down"<<endl; | ||
120 | XFlush(disp); | ||
121 | //layer.restack(); | ||
122 | while (1) { | ||
123 | while (XNextEvent(disp, &event)) | ||
124 | continue; | ||
125 | if (event.xbutton.button == 1) { | ||
126 | if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) { | ||
127 | item_red->raise(); | ||
128 | cerr<<"Raise red"<<endl; | ||
129 | } else if (event.xany.window == win_blue.window()) { | ||
130 | item_blue->raise(); | ||
131 | cerr<<"Raise blue"<<endl; | ||
132 | } else if (event.xany.window == win_green.window()) { | ||
133 | item_green->raise(); | ||
134 | cerr<<"Raise green"<<endl; | ||
135 | } else if (event.xany.window == win_red2.window()) { | ||
136 | item_red2->raise(); | ||
137 | cerr<<"Raise red2"<<endl; | ||
138 | } else if (event.xany.window == win_blue2.window()) { | ||
139 | item_blue2->raise(); | ||
140 | cerr<<"Raise blue2"<<endl; | ||
141 | } else if (event.xany.window == win_green2.window()) { | ||
142 | item_green2->raise(); | ||
143 | cerr<<"Raise green2"<<endl; | ||
144 | } else if (event.xany.window == win_red3.window()) { | ||
145 | item_red3->raise(); | ||
146 | cerr<<"Raise red3"<<endl; | ||
147 | } else if (event.xany.window == win_blue3.window()) { | ||
148 | item_blue3->raise(); | ||
149 | cerr<<"Raise blue3"<<endl; | ||
150 | } else if (event.xany.window == win_green3.window()) { | ||
151 | item_green3->raise(); | ||
152 | cerr<<"Raise green3"<<endl; | ||
153 | } else { | ||
154 | cerr<<"Unknown window"<<endl; | ||
155 | } | ||
156 | |||
157 | } else if (event.xbutton.button == 3) { | ||
158 | if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) { | ||
159 | ml->raise(*item_red); | ||
160 | } else if (event.xany.window == win_blue.window()) { | ||
161 | ml->raise(*item_blue); | ||
162 | } else if (event.xany.window == win_green.window()) { | ||
163 | ml->raise(*item_green); | ||
164 | } else if (event.xany.window == win_red2.window()) { | ||
165 | ml->raise(*item_red2); | ||
166 | } else if (event.xany.window == win_blue2.window()) { | ||
167 | ml->raise(*item_blue2); | ||
168 | } else if (event.xany.window == win_green2.window()) { | ||
169 | ml->raise(*item_green2); | ||
170 | } else if (event.xany.window == win_red3.window()) { | ||
171 | ml->raise(*item_red3); | ||
172 | } else if (event.xany.window == win_blue3.window()) { | ||
173 | ml->raise(*item_blue3); | ||
174 | } else if (event.xany.window == win_green3.window()) { | ||
175 | ml->raise(*item_green3); | ||
176 | } else { | ||
177 | cerr<<"Unknown window"<<endl; | ||
178 | } | ||
179 | |||
180 | } else if (event.xbutton.button == 2) { | ||
181 | if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) { | ||
182 | ml->lower(*item_red); | ||
183 | } else if (event.xany.window == win_blue.window()) { | ||
184 | ml->lower(*item_blue); | ||
185 | } else if (event.xany.window == win_green.window()) { | ||
186 | ml->lower(*item_green); | ||
187 | } else if (event.xany.window == win_red2.window()) { | ||
188 | ml->lower(*item_red2); | ||
189 | } else if (event.xany.window == win_blue2.window()) { | ||
190 | ml->lower(*item_blue2); | ||
191 | } else if (event.xany.window == win_green2.window()) { | ||
192 | ml->lower(*item_green2); | ||
193 | } else if (event.xany.window == win_red3.window()) { | ||
194 | ml->lower(*item_red3); | ||
195 | } else if (event.xany.window == win_blue3.window()) { | ||
196 | ml->lower(*item_blue3); | ||
197 | } else if (event.xany.window == win_green3.window()) { | ||
198 | ml->lower(*item_green3); | ||
199 | } else { | ||
200 | cerr<<"Unknown window"<<endl; | ||
201 | } | ||
202 | |||
203 | } else { | ||
204 | cerr<<"Button: "<<event.xbutton.button<<endl; | ||
205 | if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) { | ||
206 | item_red->raise(); | ||
207 | cerr<<"Raise red"<<endl; | ||
208 | } else if (event.xany.window == win_blue.window()) { | ||
209 | item_blue->raise(); | ||
210 | cerr<<"Raise blue"<<endl; | ||
211 | } else if (event.xany.window == win_green.window()) { | ||
212 | item_green->raise(); | ||
213 | cerr<<"Raise green"<<endl; | ||
214 | } else { | ||
215 | cerr<<"Unknown window"<<endl; | ||
216 | } | ||
217 | |||
218 | } | ||
219 | |||
220 | } | ||
221 | |||
222 | } | ||