Merge lp:~azzar1/nux/focus-on-enter into lp:nux/2.0
- focus-on-enter
- Merge into 2.0
Proposed by
Andrea Azzarone
Status: | Merged |
---|---|
Approved by: | Jay Taoko |
Approved revision: | 578 |
Merged at revision: | 576 |
Proposed branch: | lp:~azzar1/nux/focus-on-enter |
Merge into: | lp:nux/2.0 |
Diff against target: |
363 lines (+193/-16) 8 files modified
Nux/Area.h (+1/-1) Nux/InputArea.cpp (+17/-6) Nux/InputArea.h (+9/-4) Nux/WindowCompositor.cpp (+10/-2) configure.ac (+1/-1) tests/Makefile.am (+11/-1) tests/Readme.txt (+4/-1) tests/xtest-focus-on-mouse-enter.cpp (+140/-0) |
To merge this branch: | bzr merge lp:~azzar1/nux/focus-on-enter |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Taoko (community) | Approve | ||
Review via email: mp+93564@code.launchpad.net |
Commit message
Description of the change
Adds the support for the "focus on mouse enter" feature.
To post a comment you must log in.
lp:~azzar1/nux/focus-on-enter
updated
- 577. By Andrea Azzarone
-
Change abi version.
- 578. By Andrea Azzarone
-
Fixes.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Nux/Area.h' | |||
2 | --- Nux/Area.h 2012-01-28 05:35:42 +0000 | |||
3 | +++ Nux/Area.h 2012-02-17 20:49:19 +0000 | |||
4 | @@ -515,7 +515,7 @@ | |||
5 | 515 | const char* character); | 515 | const char* character); |
6 | 516 | 516 | ||
7 | 517 | virtual bool AcceptKeyNavFocus(); | 517 | virtual bool AcceptKeyNavFocus(); |
9 | 518 | 518 | ||
10 | 519 | virtual Area* KeyNavIteration(KeyNavDirection direction); | 519 | virtual Area* KeyNavIteration(KeyNavDirection direction); |
11 | 520 | 520 | ||
12 | 521 | bool HasKeyFocus() const; | 521 | bool HasKeyFocus() const; |
13 | 522 | 522 | ||
14 | === modified file 'Nux/InputArea.cpp' | |||
15 | --- Nux/InputArea.cpp 2012-01-04 00:47:59 +0000 | |||
16 | +++ Nux/InputArea.cpp 2012-02-17 20:49:19 +0000 | |||
17 | @@ -44,6 +44,7 @@ | |||
18 | 44 | : Area(NUX_FILE_LINE_PARAM) | 44 | : Area(NUX_FILE_LINE_PARAM) |
19 | 45 | , area_color_(color::Green) | 45 | , area_color_(color::Green) |
20 | 46 | , accept_key_nav_focus_on_mouse_down_(true) | 46 | , accept_key_nav_focus_on_mouse_down_(true) |
21 | 47 | , accept_key_nav_focus_on_mouse_enter_(false) | ||
22 | 47 | { | 48 | { |
23 | 48 | SetGeometry(0, 0, 1, 1); | 49 | SetGeometry(0, 0, 1, 1); |
24 | 49 | 50 | ||
25 | @@ -79,11 +80,6 @@ | |||
26 | 79 | return GetWindowThread()->GetWindowCompositor().GetKeyFocusArea() == this; | 80 | return GetWindowThread()->GetWindowCompositor().GetKeyFocusArea() == this; |
27 | 80 | } | 81 | } |
28 | 81 | 82 | ||
29 | 82 | void InputArea::SetAcceptKeyNavFocusOnMouseDown(bool accept) | ||
30 | 83 | { | ||
31 | 84 | accept_key_nav_focus_on_mouse_down_ = accept; | ||
32 | 85 | } | ||
33 | 86 | |||
34 | 87 | bool InputArea::IsMouseInside() | 83 | bool InputArea::IsMouseInside() |
35 | 88 | { | 84 | { |
36 | 89 | return mouse_in_; | 85 | return mouse_in_; |
37 | @@ -399,9 +395,24 @@ | |||
38 | 399 | return false; | 395 | return false; |
39 | 400 | } | 396 | } |
40 | 401 | 397 | ||
42 | 402 | bool InputArea::AcceptKeyNavFocusOnMouseDown() | 398 | bool InputArea::AcceptKeyNavFocusOnMouseDown() const |
43 | 403 | { | 399 | { |
44 | 404 | return accept_key_nav_focus_on_mouse_down_; | 400 | return accept_key_nav_focus_on_mouse_down_; |
45 | 405 | } | 401 | } |
46 | 402 | |||
47 | 403 | bool InputArea::AcceptKeyNavFocusOnMouseEnter() const | ||
48 | 404 | { | ||
49 | 405 | return accept_key_nav_focus_on_mouse_enter_; | ||
50 | 406 | } | ||
51 | 407 | |||
52 | 408 | void InputArea::SetAcceptKeyNavFocusOnMouseDown(bool accept) | ||
53 | 409 | { | ||
54 | 410 | accept_key_nav_focus_on_mouse_down_ = accept; | ||
55 | 411 | } | ||
56 | 412 | |||
57 | 413 | void InputArea::SetAcceptKeyNavFocusOnMouseEnter(bool accept) | ||
58 | 414 | { | ||
59 | 415 | accept_key_nav_focus_on_mouse_enter_ = accept; | ||
60 | 416 | } | ||
61 | 406 | } | 417 | } |
62 | 407 | 418 | ||
63 | 408 | 419 | ||
64 | === modified file 'Nux/InputArea.h' | |||
65 | --- Nux/InputArea.h 2012-01-04 00:47:59 +0000 | |||
66 | +++ Nux/InputArea.h 2012-02-17 20:49:19 +0000 | |||
67 | @@ -59,7 +59,6 @@ | |||
68 | 59 | virtual void OverlayDrawing(GraphicsEngine &graphics_engine) {} | 59 | virtual void OverlayDrawing(GraphicsEngine &graphics_engine) {} |
69 | 60 | 60 | ||
70 | 61 | bool HasKeyboardFocus(); | 61 | bool HasKeyboardFocus(); |
71 | 62 | void SetAcceptKeyNavFocusOnMouseDown(bool accept); | ||
72 | 63 | 62 | ||
73 | 64 | bool MouseFocusOnOtherArea(); | 63 | bool MouseFocusOnOtherArea(); |
74 | 65 | void CaptureMouseDownAnyWhereElse(bool b); | 64 | void CaptureMouseDownAnyWhereElse(bool b); |
75 | @@ -82,6 +81,9 @@ | |||
76 | 82 | 81 | ||
77 | 83 | void SetKeyboardReceiverIgnoreMouseDownOutside(bool ignore_mouse_down_outside); | 82 | void SetKeyboardReceiverIgnoreMouseDownOutside(bool ignore_mouse_down_outside); |
78 | 84 | 83 | ||
79 | 84 | void SetAcceptKeyNavFocusOnMouseDown(bool accept); | ||
80 | 85 | void SetAcceptKeyNavFocusOnMouseEnter(bool accept); | ||
81 | 86 | |||
82 | 85 | bool KeyboardReceiverIgnoreMouseDownOutside(); | 87 | bool KeyboardReceiverIgnoreMouseDownOutside(); |
83 | 86 | 88 | ||
84 | 87 | virtual bool IsArea() const | 89 | virtual bool IsArea() const |
85 | @@ -147,8 +149,6 @@ | |||
86 | 147 | 149 | ||
87 | 148 | int _dnd_safety_x; | 150 | int _dnd_safety_x; |
88 | 149 | int _dnd_safety_y; | 151 | int _dnd_safety_y; |
89 | 150 | |||
90 | 151 | bool accept_key_nav_focus_on_mouse_down_; | ||
91 | 152 | 152 | ||
92 | 153 | protected: | 153 | protected: |
93 | 154 | bool _capture_mouse_down_any_where_else; | 154 | bool _capture_mouse_down_any_where_else; |
94 | @@ -156,6 +156,10 @@ | |||
95 | 156 | 156 | ||
96 | 157 | bool _keyboard_receiver_ignore_mouse_down_outside; | 157 | bool _keyboard_receiver_ignore_mouse_down_outside; |
97 | 158 | 158 | ||
98 | 159 | bool accept_key_nav_focus_on_mouse_down_; | ||
99 | 160 | bool accept_key_nav_focus_on_mouse_enter_; | ||
100 | 161 | |||
101 | 162 | |||
102 | 159 | #if defined(NUX_OS_LINUX) | 163 | #if defined(NUX_OS_LINUX) |
103 | 160 | // DnD support | 164 | // DnD support |
104 | 161 | // Rather than being implemented with signals, DND support is implemented with protected virtual function. | 165 | // Rather than being implemented with signals, DND support is implemented with protected virtual function. |
105 | @@ -307,7 +311,8 @@ | |||
106 | 307 | protected: | 311 | protected: |
107 | 308 | 312 | ||
108 | 309 | virtual bool AcceptKeyNavFocus(); | 313 | virtual bool AcceptKeyNavFocus(); |
110 | 310 | virtual bool AcceptKeyNavFocusOnMouseDown(); | 314 | virtual bool AcceptKeyNavFocusOnMouseDown() const; |
111 | 315 | virtual bool AcceptKeyNavFocusOnMouseEnter() const; | ||
112 | 311 | 316 | ||
113 | 312 | // == Signals with 1 to 1 mapping to input device == | 317 | // == Signals with 1 to 1 mapping to input device == |
114 | 313 | virtual void EmitMouseDownSignal (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); | 318 | virtual void EmitMouseDownSignal (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); |
115 | 314 | 319 | ||
116 | === modified file 'Nux/WindowCompositor.cpp' | |||
117 | --- Nux/WindowCompositor.cpp 2012-02-04 00:19:46 +0000 | |||
118 | +++ Nux/WindowCompositor.cpp 2012-02-17 20:49:19 +0000 | |||
119 | @@ -430,9 +430,16 @@ | |||
120 | 430 | 430 | ||
121 | 431 | mouse_over_area_->EmitMouseLeaveSignal(x, y, event.GetMouseState(), event.GetKeyState()); | 431 | mouse_over_area_->EmitMouseLeaveSignal(x, y, event.GetMouseState(), event.GetKeyState()); |
122 | 432 | } | 432 | } |
123 | 433 | |||
124 | 434 | // The area we found under the mouse pointer receives a "mouse enter signal". | 433 | // The area we found under the mouse pointer receives a "mouse enter signal". |
125 | 435 | SetMouseOverArea(hit_view); | 434 | SetMouseOverArea(hit_view); |
126 | 435 | |||
127 | 436 | if (mouse_over_area_ != GetKeyFocusArea() && | ||
128 | 437 | mouse_over_area_ && mouse_over_area_->AcceptKeyNavFocusOnMouseEnter()) | ||
129 | 438 | { | ||
130 | 439 | SetKeyFocusArea(mouse_over_area_); | ||
131 | 440 | } | ||
132 | 441 | |||
133 | 442 | |||
134 | 436 | mouse_over_area_->EmitMouseEnterSignal(hit_view_x, hit_view_y, event.GetMouseState(), event.GetKeyState()); | 443 | mouse_over_area_->EmitMouseEnterSignal(hit_view_x, hit_view_y, event.GetMouseState(), event.GetKeyState()); |
135 | 437 | emit_delta = false; | 444 | emit_delta = false; |
136 | 438 | } | 445 | } |
137 | @@ -476,7 +483,8 @@ | |||
138 | 476 | // In the case of a mouse down event, if there is currently a keyboard event receiver and it is different | 483 | // In the case of a mouse down event, if there is currently a keyboard event receiver and it is different |
139 | 477 | // from the area returned by GetAreaUnderMouse, then stop that receiver from receiving anymore keyboard events and switch | 484 | // from the area returned by GetAreaUnderMouse, then stop that receiver from receiving anymore keyboard events and switch |
140 | 478 | // make mouse_over_area_ the new receiver(if it accept keyboard events). | 485 | // make mouse_over_area_ the new receiver(if it accept keyboard events). |
142 | 479 | if (mouse_over_area_ != GetKeyFocusArea() and mouse_over_area_->AcceptKeyNavFocusOnMouseDown()) | 486 | if (mouse_over_area_ != GetKeyFocusArea() && |
143 | 487 | mouse_over_area_ && mouse_over_area_->AcceptKeyNavFocusOnMouseDown()) | ||
144 | 480 | { | 488 | { |
145 | 481 | InputArea* grab_area = GetKeyboardGrabArea(); | 489 | InputArea* grab_area = GetKeyboardGrabArea(); |
146 | 482 | if (grab_area) | 490 | if (grab_area) |
147 | 483 | 491 | ||
148 | === modified file 'configure.ac' | |||
149 | --- configure.ac 2012-02-12 23:28:17 +0000 | |||
150 | +++ configure.ac 2012-02-17 20:49:19 +0000 | |||
151 | @@ -22,7 +22,7 @@ | |||
152 | 22 | # The number format is : year/month/day | 22 | # The number format is : year/month/day |
153 | 23 | # e.g.: december 5th, 2011 is: 20111205 | 23 | # e.g.: december 5th, 2011 is: 20111205 |
154 | 24 | # To make more than one API change in a day, add a number to the date. Like 20111205.xx | 24 | # To make more than one API change in a day, add a number to the date. Like 20111205.xx |
156 | 25 | m4_define([nux_abi_version], [20120212.01]) | 25 | m4_define([nux_abi_version], [20120217.01]) |
157 | 26 | 26 | ||
158 | 27 | m4_define([nux_version], | 27 | m4_define([nux_version], |
159 | 28 | [nux_major_version.nux_minor_version.nux_micro_version]) | 28 | [nux_major_version.nux_minor_version.nux_micro_version]) |
160 | 29 | 29 | ||
161 | === modified file 'tests/Makefile.am' | |||
162 | --- tests/Makefile.am 2012-02-13 15:22:30 +0000 | |||
163 | +++ tests/Makefile.am 2012-02-17 20:49:19 +0000 | |||
164 | @@ -13,6 +13,7 @@ | |||
165 | 13 | xtest-vlayout-key-navigation \ | 13 | xtest-vlayout-key-navigation \ |
166 | 14 | xtest-scrollbar \ | 14 | xtest-scrollbar \ |
167 | 15 | xtest-focus-on-mouse-down \ | 15 | xtest-focus-on-mouse-down \ |
168 | 16 | xtest-focus-on-mouse-enter \ | ||
169 | 16 | xtest-keynav-directions | 17 | xtest-keynav-directions |
170 | 17 | 18 | ||
171 | 18 | # Please keep alphabetical | 19 | # Please keep alphabetical |
172 | @@ -198,6 +199,14 @@ | |||
173 | 198 | xtest_focus_on_mouse_down_LDADD = $(TestLibs) | 199 | xtest_focus_on_mouse_down_LDADD = $(TestLibs) |
174 | 199 | xtest_focus_on_mouse_down_LDFLAGS = -lpthread -lXtst | 200 | xtest_focus_on_mouse_down_LDFLAGS = -lpthread -lXtst |
175 | 200 | 201 | ||
176 | 202 | xtest_focus_on_mouse_enter_SOURCES = xtest-focus-on-mouse-enter.cpp \ | ||
177 | 203 | nux_automated_test_framework.cpp \ | ||
178 | 204 | nux_automated_test_framework.h | ||
179 | 205 | |||
180 | 206 | xtest_focus_on_mouse_enter_CPPFLAGS = $(TestFlags) | ||
181 | 207 | xtest_focus_on_mouse_enter_LDADD = $(TestLibs) | ||
182 | 208 | xtest_focus_on_mouse_enter_LDFLAGS = -lpthread -lXtst | ||
183 | 209 | |||
184 | 201 | xtest_scrollbar_SOURCES = xtest-scrollbar.cpp \ | 210 | xtest_scrollbar_SOURCES = xtest-scrollbar.cpp \ |
185 | 202 | nux_automated_test_framework.cpp \ | 211 | nux_automated_test_framework.cpp \ |
186 | 203 | nux_automated_test_framework.h \ | 212 | nux_automated_test_framework.h \ |
187 | @@ -230,7 +239,7 @@ | |||
188 | 230 | check-headless: gtest-nux-core | 239 | check-headless: gtest-nux-core |
189 | 231 | @gtester --verbose -k -o=test-nux-results.xml ./gtest-nux-core | 240 | @gtester --verbose -k -o=test-nux-results.xml ./gtest-nux-core |
190 | 232 | 241 | ||
192 | 233 | test-apps: test-graphics-display test-empty-window xtest-button xtest-mouse-events xtest-mouse-buttons xtest-hgrid-key-navigation xtest-hlayout-key-navigation xtest-vlayout-key-navigation xtest-scrollbar xtest-focus-on-mouse-down xtest-keynav-directions | 242 | test-apps: test-graphics-display test-empty-window xtest-button xtest-mouse-events xtest-mouse-buttons xtest-hgrid-key-navigation xtest-hlayout-key-navigation xtest-vlayout-key-navigation xtest-scrollbar xtest-focus-on-mouse-down xtest-focus-on-mouse-enter xtest-keynav-directions |
193 | 234 | ./test-graphics-display | 243 | ./test-graphics-display |
194 | 235 | ./test-empty-window | 244 | ./test-empty-window |
195 | 236 | ./xtest-button | 245 | ./xtest-button |
196 | @@ -241,6 +250,7 @@ | |||
197 | 241 | ./xtest-vlayout-key-navigation | 250 | ./xtest-vlayout-key-navigation |
198 | 242 | ./xtest-scrollbar | 251 | ./xtest-scrollbar |
199 | 243 | ./xtest-focus-on-mouse-down | 252 | ./xtest-focus-on-mouse-down |
200 | 253 | ./xtest-focus-on-mouse-enter | ||
201 | 244 | ./xtest-keynav-directions | 254 | ./xtest-keynav-directions |
202 | 245 | 255 | ||
203 | 246 | check-report: | 256 | check-report: |
204 | 247 | 257 | ||
205 | === modified file 'tests/Readme.txt' | |||
206 | --- tests/Readme.txt 2012-01-30 08:43:49 +0000 | |||
207 | +++ tests/Readme.txt 2012-02-17 20:49:19 +0000 | |||
208 | @@ -48,5 +48,8 @@ | |||
209 | 48 | xtest-focus-on-mouse-down | 48 | xtest-focus-on-mouse-down |
210 | 49 | Make sure that AcceptKeyNavFocusOnMouseDown works well. | 49 | Make sure that AcceptKeyNavFocusOnMouseDown works well. |
211 | 50 | 50 | ||
212 | 51 | xtest-focus-on-mouse-enter | ||
213 | 52 | Make sure that AcceptKeyNavFocusOnMouseEnter works well. | ||
214 | 53 | |||
215 | 51 | xtest-keynav-direction | 54 | xtest-keynav-direction |
216 | 52 | Test key navigation. Especially test the direction a key nav is coming from when the view is getting the focus. | ||
217 | 53 | \ No newline at end of file | 55 | \ No newline at end of file |
218 | 56 | Test key navigation. Especially test the direction a key nav is coming from when the view is getting the focus. | ||
219 | 54 | 57 | ||
220 | === added file 'tests/xtest-focus-on-mouse-enter.cpp' | |||
221 | --- tests/xtest-focus-on-mouse-enter.cpp 1970-01-01 00:00:00 +0000 | |||
222 | +++ tests/xtest-focus-on-mouse-enter.cpp 2012-02-17 20:49:19 +0000 | |||
223 | @@ -0,0 +1,140 @@ | |||
224 | 1 | /* | ||
225 | 2 | * Copyright 2012 Inalogic Inc. | ||
226 | 3 | * | ||
227 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
228 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
229 | 6 | * by the Free Software Foundation. | ||
230 | 7 | * | ||
231 | 8 | * This program is distributed in the hope that it will be useful, but | ||
232 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
233 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
234 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
235 | 12 | * | ||
236 | 13 | * You should have received a copy of the GNU General Public License | ||
237 | 14 | * version 3 along with this program. If not, see | ||
238 | 15 | * <http://www.gnu.org/licenses/> | ||
239 | 16 | * | ||
240 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
241 | 18 | * | ||
242 | 19 | */ | ||
243 | 20 | |||
244 | 21 | #include "Nux/Nux.h" | ||
245 | 22 | #include "Nux/WindowThread.h" | ||
246 | 23 | #include "Nux/VLayout.h" | ||
247 | 24 | #include "Nux/ProgramFramework/ProgramTemplate.h" | ||
248 | 25 | #include "Nux/ProgramFramework/TestView.h" | ||
249 | 26 | #include <X11/extensions/XTest.h> | ||
250 | 27 | #include <X11/keysym.h> | ||
251 | 28 | #include "nux_automated_test_framework.h" | ||
252 | 29 | |||
253 | 30 | class FocusOnMouseEnterTest: public ProgramTemplate | ||
254 | 31 | { | ||
255 | 32 | public: | ||
256 | 33 | FocusOnMouseEnterTest(const char* program_name, int window_width, int window_height, int program_life_span); | ||
257 | 34 | ~FocusOnMouseEnterTest(); | ||
258 | 35 | |||
259 | 36 | virtual void UserInterfaceSetup(); | ||
260 | 37 | |||
261 | 38 | TestView* focus_view_; | ||
262 | 39 | TestView* no_focus_view_; | ||
263 | 40 | }; | ||
264 | 41 | |||
265 | 42 | FocusOnMouseEnterTest::FocusOnMouseEnterTest(const char* program_name, | ||
266 | 43 | int window_width, | ||
267 | 44 | int window_height, | ||
268 | 45 | int program_life_span) | ||
269 | 46 | : ProgramTemplate(program_name, window_width, window_height, program_life_span) | ||
270 | 47 | , focus_view_(nullptr) | ||
271 | 48 | , no_focus_view_(nullptr) | ||
272 | 49 | { | ||
273 | 50 | } | ||
274 | 51 | |||
275 | 52 | FocusOnMouseEnterTest::~FocusOnMouseEnterTest() | ||
276 | 53 | {} | ||
277 | 54 | |||
278 | 55 | void FocusOnMouseEnterTest::UserInterfaceSetup() | ||
279 | 56 | { | ||
280 | 57 | nux::VLayout* main_layout = new nux::VLayout(NUX_TRACKER_LOCATION); | ||
281 | 58 | main_layout->SetSpaceBetweenChildren(10); | ||
282 | 59 | main_layout->SetPadding(10, 10); | ||
283 | 60 | |||
284 | 61 | no_focus_view_ = new TestView(NUX_TRACKER_LOCATION); | ||
285 | 62 | no_focus_view_->can_focus_ = true; | ||
286 | 63 | no_focus_view_->SetAcceptKeyNavFocusOnMouseEnter(false); | ||
287 | 64 | main_layout->AddView(no_focus_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
288 | 65 | |||
289 | 66 | focus_view_ = new TestView(NUX_TRACKER_LOCATION); | ||
290 | 67 | focus_view_->can_focus_ = true; | ||
291 | 68 | focus_view_->SetAcceptKeyNavFocusOnMouseEnter(true); | ||
292 | 69 | main_layout->AddView(focus_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | ||
293 | 70 | |||
294 | 71 | static_cast<nux::WindowThread*>(window_thread_)->SetLayout(main_layout); | ||
295 | 72 | |||
296 | 73 | nux::ColorLayer background(nux::Color(0xFF4D4D4D)); | ||
297 | 74 | static_cast<nux::WindowThread*>(window_thread_)->SetWindowBackgroundPaintLayer(&background); | ||
298 | 75 | } | ||
299 | 76 | |||
300 | 77 | FocusOnMouseEnterTest* focus_on_mouse_enter_test = nullptr; | ||
301 | 78 | |||
302 | 79 | void TestingThread(nux::NThread* thread, void* user_data) | ||
303 | 80 | { | ||
304 | 81 | while (focus_on_mouse_enter_test->ReadyToGo() == false) | ||
305 | 82 | { | ||
306 | 83 | nuxDebugMsg("Waiting to start"); | ||
307 | 84 | nux::SleepForMilliseconds(300); | ||
308 | 85 | } | ||
309 | 86 | |||
310 | 87 | nux::SleepForMilliseconds(1000); | ||
311 | 88 | |||
312 | 89 | nux::WindowThread* wnd_thread = static_cast<nux::WindowThread*>(user_data); | ||
313 | 90 | |||
314 | 91 | NuxAutomatedTestFramework test(wnd_thread); | ||
315 | 92 | |||
316 | 93 | test.Startup(); | ||
317 | 94 | |||
318 | 95 | // Set the mouse at coordinates (0, 0) (top-left corner) on the display | ||
319 | 96 | test.PutMouseAt(0, 0); | ||
320 | 97 | |||
321 | 98 | test.TestReportMsg(focus_on_mouse_enter_test->focus_view_, "Focus view created"); | ||
322 | 99 | test.TestReportMsg(focus_on_mouse_enter_test->no_focus_view_, "No focus view created"); | ||
323 | 100 | |||
324 | 101 | // Move mouse to center of no_focus_view_ | ||
325 | 102 | test.ViewSendMouseMotionToCenter(focus_on_mouse_enter_test->no_focus_view_); | ||
326 | 103 | nux::SleepForMilliseconds(500); | ||
327 | 104 | test.TestReportMsg(!focus_on_mouse_enter_test->no_focus_view_->has_focus_, "no_focus_view_ did not take the focus"); | ||
328 | 105 | |||
329 | 106 | // Move mouse to center of focus_view_ | ||
330 | 107 | test.ViewSendMouseMotionToCenter(focus_on_mouse_enter_test->focus_view_); | ||
331 | 108 | nux::SleepForMilliseconds(500); | ||
332 | 109 | test.TestReportMsg(focus_on_mouse_enter_test->focus_view_->has_focus_, "focus_view_ has the focus"); | ||
333 | 110 | |||
334 | 111 | if (test.WhenDoneTerminateProgram()) | ||
335 | 112 | { | ||
336 | 113 | nux::SleepForMilliseconds(1000); | ||
337 | 114 | wnd_thread->ExitMainLoop(); | ||
338 | 115 | } | ||
339 | 116 | nuxDebugMsg("Exit testing thread"); | ||
340 | 117 | } | ||
341 | 118 | |||
342 | 119 | int main(int argc, char** argv) | ||
343 | 120 | { | ||
344 | 121 | int xstatus = XInitThreads(); | ||
345 | 122 | nuxAssertMsg(xstatus > 0, "XInitThreads has failed"); | ||
346 | 123 | |||
347 | 124 | focus_on_mouse_enter_test = new FocusOnMouseEnterTest("Focus On Mouse Enter Test", 300, 300, 15000); | ||
348 | 125 | focus_on_mouse_enter_test->Startup(); | ||
349 | 126 | focus_on_mouse_enter_test->UserInterfaceSetup(); | ||
350 | 127 | |||
351 | 128 | nux::SystemThread* test_thread = nux::CreateSystemThread(focus_on_mouse_enter_test->GetWindowThread(), | ||
352 | 129 | &TestingThread, | ||
353 | 130 | focus_on_mouse_enter_test->GetWindowThread()); | ||
354 | 131 | |||
355 | 132 | test_thread->Start(focus_on_mouse_enter_test); | ||
356 | 133 | |||
357 | 134 | focus_on_mouse_enter_test->Run(); | ||
358 | 135 | |||
359 | 136 | delete test_thread; | ||
360 | 137 | delete focus_on_mouse_enter_test; | ||
361 | 138 | |||
362 | 139 | return 0; | ||
363 | 140 | } |
+1