Merge lp:~jamalta/unity/683261-autohide-quicklist into lp:unity
- 683261-autohide-quicklist
- Merge into trunk
Proposed by
Jamal Fanaian
Status: | Merged |
---|---|
Merged at revision: | 696 |
Proposed branch: | lp:~jamalta/unity/683261-autohide-quicklist |
Merge into: | lp:unity |
Diff against target: |
557 lines (+233/-125) 8 files modified
src/Launcher.cpp (+19/-18) src/Launcher.h (+2/-6) src/LauncherIcon.cpp (+14/-32) src/LauncherIcon.h (+0/-3) src/QuicklistManager.cpp (+109/-0) src/QuicklistManager.h (+52/-0) src/QuicklistView.cpp (+34/-66) src/QuicklistView.h (+3/-0) |
To merge this branch: | bzr merge lp:~jamalta/unity/683261-autohide-quicklist |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+43288@code.launchpad.net |
Commit message
Description of the change
Created QuicklistManager which is now responsible for handling Hiding and Showing a QuicklistView. Launcher uses QuicklistManager to figure out whether a QuicklistView is currently open before autohiding.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Launcher.cpp' | |||
2 | --- src/Launcher.cpp 2010-12-09 13:30:37 +0000 | |||
3 | +++ src/Launcher.cpp 2010-12-09 20:57:22 +0000 | |||
4 | @@ -35,6 +35,7 @@ | |||
5 | 35 | #include "Launcher.h" | 35 | #include "Launcher.h" |
6 | 36 | #include "LauncherIcon.h" | 36 | #include "LauncherIcon.h" |
7 | 37 | #include "LauncherModel.h" | 37 | #include "LauncherModel.h" |
8 | 38 | #include "QuicklistManager.h" | ||
9 | 38 | #include "QuicklistView.h" | 39 | #include "QuicklistView.h" |
10 | 39 | 40 | ||
11 | 40 | #define ANIM_DURATION_SHORT 125 | 41 | #define ANIM_DURATION_SHORT 125 |
12 | @@ -190,6 +191,9 @@ | |||
13 | 190 | OnMouseMove.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove)); | 191 | OnMouseMove.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove)); |
14 | 191 | OnMouseWheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel)); | 192 | OnMouseWheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel)); |
15 | 192 | 193 | ||
16 | 194 | QuicklistManager::Default ()->quicklist_opened.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistOpened)); | ||
17 | 195 | QuicklistManager::Default ()->quicklist_closed.connect (sigc::mem_fun(this, &Launcher::RecvQuicklistClosed)); | ||
18 | 196 | |||
19 | 193 | m_ActiveTooltipIcon = NULL; | 197 | m_ActiveTooltipIcon = NULL; |
20 | 194 | m_ActiveMenuIcon = NULL; | 198 | m_ActiveMenuIcon = NULL; |
21 | 195 | 199 | ||
22 | @@ -843,7 +847,7 @@ | |||
23 | 843 | void | 847 | void |
24 | 844 | Launcher::EnsureHiddenState () | 848 | Launcher::EnsureHiddenState () |
25 | 845 | { | 849 | { |
27 | 846 | if (!_mouse_inside_trigger && !_mouse_inside_launcher && _window_over_launcher) | 850 | if (!_mouse_inside_trigger && !_mouse_inside_launcher && _window_over_launcher && !QuicklistManager::Default ()->Current()) |
28 | 847 | SetHidden (true); | 851 | SetHidden (true); |
29 | 848 | else | 852 | else |
30 | 849 | SetHidden (false); | 853 | SetHidden (false); |
31 | @@ -1615,6 +1619,20 @@ | |||
32 | 1615 | { | 1619 | { |
33 | 1616 | } | 1620 | } |
34 | 1617 | 1621 | ||
35 | 1622 | void Launcher::RecvQuicklistOpened (QuicklistView *quicklist) | ||
36 | 1623 | { | ||
37 | 1624 | EventLogic (); | ||
38 | 1625 | EnsureAnimation (); | ||
39 | 1626 | } | ||
40 | 1627 | |||
41 | 1628 | void Launcher::RecvQuicklistClosed (QuicklistView *quicklist) | ||
42 | 1629 | { | ||
43 | 1630 | SetupAutohideTimer (); | ||
44 | 1631 | |||
45 | 1632 | EventLogic (); | ||
46 | 1633 | EnsureAnimation (); | ||
47 | 1634 | } | ||
48 | 1635 | |||
49 | 1618 | void Launcher::EventLogic () | 1636 | void Launcher::EventLogic () |
50 | 1619 | { | 1637 | { |
51 | 1620 | if (_launcher_action_state == ACTION_DRAG_LAUNCHER) | 1638 | if (_launcher_action_state == ACTION_DRAG_LAUNCHER) |
52 | @@ -1954,20 +1972,3 @@ | |||
53 | 1954 | // glEnd(); | 1972 | // glEnd(); |
54 | 1955 | } | 1973 | } |
55 | 1956 | 1974 | ||
56 | 1957 | void Launcher::SetActiveQuicklist (QuicklistView *quicklist) | ||
57 | 1958 | { | ||
58 | 1959 | // Assert: _active_quicklist should be 0 | ||
59 | 1960 | _active_quicklist = quicklist; | ||
60 | 1961 | } | ||
61 | 1962 | |||
62 | 1963 | QuicklistView *Launcher::GetActiveQuicklist () | ||
63 | 1964 | { | ||
64 | 1965 | return _active_quicklist; | ||
65 | 1966 | } | ||
66 | 1967 | |||
67 | 1968 | void Launcher::CancelActiveQuicklist (QuicklistView *quicklist) | ||
68 | 1969 | { | ||
69 | 1970 | if (_active_quicklist == quicklist) | ||
70 | 1971 | _active_quicklist = 0; | ||
71 | 1972 | } | ||
72 | 1973 | |||
73 | 1974 | 1975 | ||
74 | === modified file 'src/Launcher.h' | |||
75 | --- src/Launcher.h 2010-12-07 16:05:52 +0000 | |||
76 | +++ src/Launcher.h 2010-12-09 20:57:22 +0000 | |||
77 | @@ -73,12 +73,8 @@ | |||
78 | 73 | virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); | 73 | virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
79 | 74 | virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); | 74 | virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); |
80 | 75 | 75 | ||
87 | 76 | //! Called by LauncherIcon to signal that a Quicklist is becoming active. | 76 | virtual void RecvQuicklistOpened (QuicklistView *quicklist); |
88 | 77 | void SetActiveQuicklist (QuicklistView *quicklist); | 77 | virtual void RecvQuicklistClosed (QuicklistView *quicklist); |
83 | 78 | //! Get the active qicklist | ||
84 | 79 | QuicklistView *GetActiveQuicklist (); | ||
85 | 80 | //! Called by LauncherIcon to signal that a Quicklist is becoming unactive. | ||
86 | 81 | void CancelActiveQuicklist (QuicklistView *quicklist); | ||
89 | 82 | 78 | ||
90 | 83 | protected: | 79 | protected: |
91 | 84 | // Introspectable methods | 80 | // Introspectable methods |
92 | 85 | 81 | ||
93 | === modified file 'src/LauncherIcon.cpp' | |||
94 | --- src/LauncherIcon.cpp 2010-12-07 23:19:18 +0000 | |||
95 | +++ src/LauncherIcon.cpp 2010-12-09 20:57:22 +0000 | |||
96 | @@ -31,6 +31,7 @@ | |||
97 | 31 | #include "LauncherIcon.h" | 31 | #include "LauncherIcon.h" |
98 | 32 | #include "Launcher.h" | 32 | #include "Launcher.h" |
99 | 33 | 33 | ||
100 | 34 | #include "QuicklistManager.h" | ||
101 | 34 | #include "QuicklistMenuItem.h" | 35 | #include "QuicklistMenuItem.h" |
102 | 35 | #include "QuicklistMenuItemLabel.h" | 36 | #include "QuicklistMenuItemLabel.h" |
103 | 36 | #include "QuicklistMenuItemSeparator.h" | 37 | #include "QuicklistMenuItemSeparator.h" |
104 | @@ -66,9 +67,9 @@ | |||
105 | 66 | _sort_priority = 0; | 67 | _sort_priority = 0; |
106 | 67 | 68 | ||
107 | 68 | _quicklist = new QuicklistView (); | 69 | _quicklist = new QuicklistView (); |
108 | 69 | _quicklist->sigVisible.connect (sigc::mem_fun (this, &LauncherIcon::RecvShowQuicklist)); | ||
109 | 70 | _quicklist->sigHidden.connect (sigc::mem_fun (this, &LauncherIcon::RecvHideQuicklist)); | ||
110 | 71 | _quicklist_is_initialized = false; | 70 | _quicklist_is_initialized = false; |
111 | 71 | |||
112 | 72 | QuicklistManager::Default ()->RegisterQuicklist (_quicklist); | ||
113 | 72 | 73 | ||
114 | 73 | // Add to introspection | 74 | // Add to introspection |
115 | 74 | AddChild (_quicklist); | 75 | AddChild (_quicklist); |
116 | @@ -292,7 +293,7 @@ | |||
117 | 292 | void | 293 | void |
118 | 293 | LauncherIcon::RecvMouseEnter () | 294 | LauncherIcon::RecvMouseEnter () |
119 | 294 | { | 295 | { |
121 | 295 | if (_launcher->GetActiveQuicklist ()) | 296 | if (QuicklistManager::Default ()->Current ()) |
122 | 296 | { | 297 | { |
123 | 297 | // A quicklist is active | 298 | // A quicklist is active |
124 | 298 | return; | 299 | return; |
125 | @@ -318,24 +319,21 @@ | |||
126 | 318 | { | 319 | { |
127 | 319 | if (button == 3) | 320 | if (button == 3) |
128 | 320 | { | 321 | { |
137 | 321 | if (_launcher->GetActiveQuicklist () == _quicklist) | 322 | if (QuicklistManager::Default ()->Current ()) |
138 | 322 | { | 323 | { |
139 | 323 | // this quicklist is already active | 324 | // We probably should let QuicklistManager deal with this case... |
140 | 324 | return; | 325 | QuicklistManager::Default ()->HideQuicklist (QuicklistManager::Default ()->Current()); |
141 | 325 | } | 326 | |
134 | 326 | |||
135 | 327 | if (_launcher->GetActiveQuicklist ()) | ||
136 | 328 | { | ||
142 | 329 | // Hide the active quicklist. This will prevent it from Ungrabing the pointer in | 327 | // Hide the active quicklist. This will prevent it from Ungrabing the pointer in |
143 | 330 | // QuicklistView::RecvMouseDownOutsideOfQuicklist or void QuicklistView::RecvMouseClick. | 328 | // QuicklistView::RecvMouseDownOutsideOfQuicklist or void QuicklistView::RecvMouseClick. |
144 | 331 | // So the new quicklist that is about to be set as active will keep the grab of the pointer. | 329 | // So the new quicklist that is about to be set as active will keep the grab of the pointer. |
145 | 332 | // Also disable theinput window. | 330 | // Also disable theinput window. |
148 | 333 | _launcher->GetActiveQuicklist ()->EnableInputWindow (false); | 331 | //QuicklistManager::Default ()->Current ()->EnableInputWindow (false); |
149 | 334 | _launcher->GetActiveQuicklist ()->CaptureMouseDownAnyWhereElse (false); | 332 | //QuicklistManager::Default ()->Current ()->CaptureMouseDownAnyWhereElse (false); |
150 | 335 | // This call must be last, because after, _launcher->GetActiveQuicklist () will return Null. | 333 | // This call must be last, because after, _launcher->GetActiveQuicklist () will return Null. |
151 | 336 | // the launcher listen to the sigHidden signal emitted by the BaseWindow when it becomes invisible | 334 | // the launcher listen to the sigHidden signal emitted by the BaseWindow when it becomes invisible |
152 | 337 | // and it set the active window to Null. | 335 | // and it set the active window to Null. |
154 | 338 | _launcher->GetActiveQuicklist ()->ShowWindow (false); | 336 | //QuicklistManager::Default ()->Current ()->ShowWindow (false); |
155 | 339 | } | 337 | } |
156 | 340 | 338 | ||
157 | 341 | _tooltip->ShowWindow (false); | 339 | _tooltip->ShowWindow (false); |
158 | @@ -378,14 +376,8 @@ | |||
159 | 378 | 376 | ||
160 | 379 | int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w; | 377 | int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w; |
161 | 380 | int tip_y = _center.y; | 378 | int tip_y = _center.y; |
167 | 381 | _quicklist->ShowQuicklistWithTipAt (tip_x, tip_y); | 379 | QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y); |
163 | 382 | |||
164 | 383 | _quicklist->EnableInputWindow (true, 1); | ||
165 | 384 | _quicklist->GrabPointer (); | ||
166 | 385 | |||
168 | 386 | nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist); | 380 | nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist); |
169 | 387 | |||
170 | 388 | _quicklist->NeedRedraw (); | ||
171 | 389 | } | 381 | } |
172 | 390 | } | 382 | } |
173 | 391 | 383 | ||
174 | @@ -398,16 +390,6 @@ | |||
175 | 398 | } | 390 | } |
176 | 399 | } | 391 | } |
177 | 400 | 392 | ||
178 | 401 | void LauncherIcon::RecvShowQuicklist (nux::BaseWindow *quicklist) | ||
179 | 402 | { | ||
180 | 403 | _launcher->SetActiveQuicklist (_quicklist); | ||
181 | 404 | } | ||
182 | 405 | |||
183 | 406 | void LauncherIcon::RecvHideQuicklist (nux::BaseWindow *quicklist) | ||
184 | 407 | { | ||
185 | 408 | _launcher->CancelActiveQuicklist (_quicklist); | ||
186 | 409 | } | ||
187 | 410 | |||
188 | 411 | void LauncherIcon::HideTooltip () | 393 | void LauncherIcon::HideTooltip () |
189 | 412 | { | 394 | { |
190 | 413 | _tooltip->ShowWindow (false); | 395 | _tooltip->ShowWindow (false); |
191 | @@ -437,7 +419,7 @@ | |||
192 | 437 | int tip_y = _center.y; | 419 | int tip_y = _center.y; |
193 | 438 | 420 | ||
194 | 439 | if (_quicklist->IsVisible ()) | 421 | if (_quicklist->IsVisible ()) |
196 | 440 | _quicklist->ShowQuicklistWithTipAt (tip_x, tip_y); | 422 | QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y); |
197 | 441 | else if (_tooltip->IsVisible ()) | 423 | else if (_tooltip->IsVisible ()) |
198 | 442 | _tooltip->ShowTooltipWithTipAt (tip_x, tip_y); | 424 | _tooltip->ShowTooltipWithTipAt (tip_x, tip_y); |
199 | 443 | 425 | ||
200 | 444 | 426 | ||
201 | === modified file 'src/LauncherIcon.h' | |||
202 | --- src/LauncherIcon.h 2010-12-07 23:19:18 +0000 | |||
203 | +++ src/LauncherIcon.h 2010-12-09 20:57:22 +0000 | |||
204 | @@ -80,9 +80,6 @@ | |||
205 | 80 | void RecvMouseDown (int button); | 80 | void RecvMouseDown (int button); |
206 | 81 | void RecvMouseUp (int button); | 81 | void RecvMouseUp (int button); |
207 | 82 | 82 | ||
208 | 83 | void RecvShowQuicklist (nux::BaseWindow *quicklist); | ||
209 | 84 | void RecvHideQuicklist (nux::BaseWindow *quicklist); | ||
210 | 85 | |||
211 | 86 | void HideTooltip (); | 83 | void HideTooltip (); |
212 | 87 | 84 | ||
213 | 88 | void SetCenter (nux::Point3 center); | 85 | void SetCenter (nux::Point3 center); |
214 | 89 | 86 | ||
215 | === added file 'src/QuicklistManager.cpp' | |||
216 | --- src/QuicklistManager.cpp 1970-01-01 00:00:00 +0000 | |||
217 | +++ src/QuicklistManager.cpp 2010-12-09 20:57:22 +0000 | |||
218 | @@ -0,0 +1,109 @@ | |||
219 | 1 | /* | ||
220 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
221 | 3 | * | ||
222 | 4 | * This program is free software: you can redistribute it and/or modify | ||
223 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
224 | 6 | * published by the Free Software Foundation. | ||
225 | 7 | * | ||
226 | 8 | * This program is distributed in the hope that it will be useful, | ||
227 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
228 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
229 | 11 | * GNU General Public License for more details. | ||
230 | 12 | * | ||
231 | 13 | * You should have received a copy of the GNU General Public License | ||
232 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
233 | 15 | * | ||
234 | 16 | * Authored by: Jamal Fanaian <j@jamalfanaian.com> | ||
235 | 17 | */ | ||
236 | 18 | |||
237 | 19 | #include "Nux/Nux.h" | ||
238 | 20 | #include "Nux/BaseWindow.h" | ||
239 | 21 | #include "Nux/VLayout.h" | ||
240 | 22 | #include "Nux/WindowCompositor.h" | ||
241 | 23 | #include "QuicklistView.h" | ||
242 | 24 | #include "QuicklistManager.h" | ||
243 | 25 | |||
244 | 26 | QuicklistManager * QuicklistManager::_default = 0; | ||
245 | 27 | |||
246 | 28 | /* static */ | ||
247 | 29 | QuicklistManager *QuicklistManager::Default () | ||
248 | 30 | { | ||
249 | 31 | if (!_default) | ||
250 | 32 | _default = new QuicklistManager (); | ||
251 | 33 | return _default; | ||
252 | 34 | } | ||
253 | 35 | |||
254 | 36 | QuicklistManager::QuicklistManager () | ||
255 | 37 | { | ||
256 | 38 | _current_quicklist = 0; | ||
257 | 39 | } | ||
258 | 40 | |||
259 | 41 | QuicklistManager::~QuicklistManager () | ||
260 | 42 | { | ||
261 | 43 | } | ||
262 | 44 | |||
263 | 45 | QuicklistView *QuicklistManager::Current () | ||
264 | 46 | { | ||
265 | 47 | return _current_quicklist; | ||
266 | 48 | } | ||
267 | 49 | |||
268 | 50 | void QuicklistManager::RegisterQuicklist (QuicklistView *quicklist) | ||
269 | 51 | { | ||
270 | 52 | std::list<QuicklistView*>::iterator it; | ||
271 | 53 | |||
272 | 54 | if (std::find (_quicklist_list.begin(), _quicklist_list.end(), quicklist) != _quicklist_list.end()) { | ||
273 | 55 | // quicklist has already been registered | ||
274 | 56 | g_warning ("Attempted to register a quicklist that was previously registered"); | ||
275 | 57 | return; | ||
276 | 58 | } | ||
277 | 59 | |||
278 | 60 | _quicklist_list.push_back (quicklist); | ||
279 | 61 | |||
280 | 62 | quicklist->sigVisible.connect (sigc::mem_fun (this, &QuicklistManager::RecvShowQuicklist)); | ||
281 | 63 | quicklist->sigHidden.connect (sigc::mem_fun (this, &QuicklistManager::RecvHideQuicklist)); | ||
282 | 64 | } | ||
283 | 65 | |||
284 | 66 | void QuicklistManager::ShowQuicklist (QuicklistView *quicklist, int tip_x, | ||
285 | 67 | int tip_y, bool hide_existing_if_open) | ||
286 | 68 | { | ||
287 | 69 | if (_current_quicklist == quicklist) | ||
288 | 70 | { | ||
289 | 71 | // this quicklist is already active | ||
290 | 72 | // do we want to still redraw in case the position has changed? | ||
291 | 73 | return; | ||
292 | 74 | } | ||
293 | 75 | |||
294 | 76 | if (hide_existing_if_open && _current_quicklist) | ||
295 | 77 | { | ||
296 | 78 | HideQuicklist (_current_quicklist); | ||
297 | 79 | } | ||
298 | 80 | |||
299 | 81 | quicklist->ShowQuicklistWithTipAt (tip_x, tip_y); | ||
300 | 82 | } | ||
301 | 83 | |||
302 | 84 | void QuicklistManager::HideQuicklist (QuicklistView *quicklist) | ||
303 | 85 | { | ||
304 | 86 | quicklist->Hide(); | ||
305 | 87 | } | ||
306 | 88 | |||
307 | 89 | void QuicklistManager::RecvShowQuicklist (nux::BaseWindow *window) | ||
308 | 90 | { | ||
309 | 91 | QuicklistView *quicklist = (QuicklistView*) window; | ||
310 | 92 | |||
311 | 93 | _current_quicklist = quicklist; | ||
312 | 94 | |||
313 | 95 | quicklist_opened.emit (quicklist); | ||
314 | 96 | } | ||
315 | 97 | |||
316 | 98 | void QuicklistManager::RecvHideQuicklist (nux::BaseWindow *window) | ||
317 | 99 | { | ||
318 | 100 | QuicklistView *quicklist = (QuicklistView*) window; | ||
319 | 101 | |||
320 | 102 | if (_current_quicklist == quicklist) | ||
321 | 103 | { | ||
322 | 104 | _current_quicklist = 0; | ||
323 | 105 | } | ||
324 | 106 | |||
325 | 107 | quicklist_closed.emit (quicklist); | ||
326 | 108 | } | ||
327 | 109 | |||
328 | 0 | 110 | ||
329 | === added file 'src/QuicklistManager.h' | |||
330 | --- src/QuicklistManager.h 1970-01-01 00:00:00 +0000 | |||
331 | +++ src/QuicklistManager.h 2010-12-09 20:57:22 +0000 | |||
332 | @@ -0,0 +1,52 @@ | |||
333 | 1 | /* | ||
334 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
335 | 3 | * | ||
336 | 4 | * This program is free software: you can redistribute it and/or modify | ||
337 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
338 | 6 | * published by the Free Software Foundation. | ||
339 | 7 | * | ||
340 | 8 | * This program is distributed in the hope that it will be useful, | ||
341 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
342 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
343 | 11 | * GNU General Public License for more details. | ||
344 | 12 | * | ||
345 | 13 | * You should have received a copy of the GNU General Public License | ||
346 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
347 | 15 | * | ||
348 | 16 | * Authored by: Jamal Fanaian <j@jamalfanaian.com> | ||
349 | 17 | */ | ||
350 | 18 | |||
351 | 19 | #ifndef QUICKLISTMANAGER_H | ||
352 | 20 | #define QUICKLISTMANAGER_H | ||
353 | 21 | |||
354 | 22 | class QuicklistManager : public sigc::trackable | ||
355 | 23 | { | ||
356 | 24 | public: | ||
357 | 25 | static QuicklistManager *Default (); | ||
358 | 26 | |||
359 | 27 | QuicklistManager (); | ||
360 | 28 | |||
361 | 29 | ~QuicklistManager (); | ||
362 | 30 | |||
363 | 31 | QuicklistView *Current (); | ||
364 | 32 | |||
365 | 33 | void RegisterQuicklist (QuicklistView *quicklist); | ||
366 | 34 | void ShowQuicklist (QuicklistView *quicklist, int tip_x, int tip_y, bool hide_existing_if_open = true); | ||
367 | 35 | void HideQuicklist (QuicklistView *quicklist); | ||
368 | 36 | |||
369 | 37 | void RecvShowQuicklist (nux::BaseWindow *window); | ||
370 | 38 | void RecvHideQuicklist (nux::BaseWindow *window); | ||
371 | 39 | |||
372 | 40 | sigc::signal<void, QuicklistView*> quicklist_opened; | ||
373 | 41 | sigc::signal<void, QuicklistView*> quicklist_closed; | ||
374 | 42 | |||
375 | 43 | private: | ||
376 | 44 | static QuicklistManager *_default; | ||
377 | 45 | |||
378 | 46 | std::list<QuicklistView*> _quicklist_list; | ||
379 | 47 | QuicklistView *_current_quicklist; | ||
380 | 48 | |||
381 | 49 | }; | ||
382 | 50 | |||
383 | 51 | #endif | ||
384 | 52 | |||
385 | 0 | 53 | ||
386 | === modified file 'src/QuicklistView.cpp' | |||
387 | --- src/QuicklistView.cpp 2010-12-09 10:55:58 +0000 | |||
388 | +++ src/QuicklistView.cpp 2010-12-09 20:57:22 +0000 | |||
389 | @@ -151,7 +151,7 @@ | |||
390 | 151 | SetBaseX (x); | 151 | SetBaseX (x); |
391 | 152 | SetBaseY (y); | 152 | SetBaseY (y); |
392 | 153 | 153 | ||
394 | 154 | ShowWindow (true); | 154 | Show (); |
395 | 155 | } | 155 | } |
396 | 156 | 156 | ||
397 | 157 | void QuicklistView::ShowWindow (bool b, bool start_modal) | 157 | void QuicklistView::ShowWindow (bool b, bool start_modal) |
398 | @@ -159,6 +159,31 @@ | |||
399 | 159 | BaseWindow::ShowWindow (b, start_modal); | 159 | BaseWindow::ShowWindow (b, start_modal); |
400 | 160 | } | 160 | } |
401 | 161 | 161 | ||
402 | 162 | void QuicklistView::Show () | ||
403 | 163 | { | ||
404 | 164 | if (!IsVisible()) | ||
405 | 165 | { | ||
406 | 166 | // FIXME: ShowWindow shouldn't need to be called first | ||
407 | 167 | ShowWindow (true); | ||
408 | 168 | EnableInputWindow (true, 1); | ||
409 | 169 | GrabPointer (); | ||
410 | 170 | NeedRedraw (); | ||
411 | 171 | } | ||
412 | 172 | } | ||
413 | 173 | |||
414 | 174 | void QuicklistView::Hide () | ||
415 | 175 | { | ||
416 | 176 | if (IsVisible() && !_enable_quicklist_for_testing) | ||
417 | 177 | { | ||
418 | 178 | CancelItemsPrelightStatus (); | ||
419 | 179 | CaptureMouseDownAnyWhereElse (false); | ||
420 | 180 | ForceStopFocus (1, 1); | ||
421 | 181 | UnGrabPointer (); | ||
422 | 182 | EnableInputWindow (false); | ||
423 | 183 | ShowWindow (false); | ||
424 | 184 | } | ||
425 | 185 | } | ||
426 | 186 | |||
427 | 162 | long QuicklistView::ProcessEvent (nux::IEvent& ievent, long TraverseInfo, long ProcessEventInfo) | 187 | long QuicklistView::ProcessEvent (nux::IEvent& ievent, long TraverseInfo, long ProcessEventInfo) |
428 | 163 | { | 188 | { |
429 | 164 | long ret = TraverseInfo; | 189 | long ret = TraverseInfo; |
430 | @@ -198,36 +223,14 @@ | |||
431 | 198 | else | 223 | else |
432 | 199 | { | 224 | { |
433 | 200 | _mouse_down = false; | 225 | _mouse_down = false; |
446 | 201 | if (IsVisible ()) | 226 | Hide (); |
435 | 202 | { | ||
436 | 203 | if (!_enable_quicklist_for_testing) | ||
437 | 204 | { | ||
438 | 205 | CancelItemsPrelightStatus (); | ||
439 | 206 | CaptureMouseDownAnyWhereElse (false); | ||
440 | 207 | ForceStopFocus (1, 1); | ||
441 | 208 | UnGrabPointer (); | ||
442 | 209 | EnableInputWindow (false); | ||
443 | 210 | ShowWindow (false); | ||
444 | 211 | } | ||
445 | 212 | } | ||
447 | 213 | return nux::eMouseEventSolved; | 227 | return nux::eMouseEventSolved; |
448 | 214 | } | 228 | } |
449 | 215 | } | 229 | } |
450 | 216 | else if ((ievent.e_event == nux::NUX_MOUSE_RELEASED) && _mouse_down) | 230 | else if ((ievent.e_event == nux::NUX_MOUSE_RELEASED) && _mouse_down) |
451 | 217 | { | 231 | { |
452 | 218 | _mouse_down = false; | 232 | _mouse_down = false; |
465 | 219 | if (IsVisible ()) | 233 | Hide (); |
454 | 220 | { | ||
455 | 221 | if (!_enable_quicklist_for_testing) | ||
456 | 222 | { | ||
457 | 223 | CancelItemsPrelightStatus (); | ||
458 | 224 | CaptureMouseDownAnyWhereElse (false); | ||
459 | 225 | ForceStopFocus (1, 1); | ||
460 | 226 | UnGrabPointer (); | ||
461 | 227 | EnableInputWindow (false); | ||
462 | 228 | ShowWindow (false); | ||
463 | 229 | } | ||
464 | 230 | } | ||
466 | 231 | return nux::eMouseEventSolved; | 234 | return nux::eMouseEventSolved; |
467 | 232 | } | 235 | } |
468 | 233 | 236 | ||
469 | @@ -418,15 +421,7 @@ | |||
470 | 418 | // Check if the mouse was released over an item and emit the signal | 421 | // Check if the mouse was released over an item and emit the signal |
471 | 419 | CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ()); | 422 | CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ()); |
472 | 420 | 423 | ||
482 | 421 | if (!_enable_quicklist_for_testing) | 424 | Hide (); |
474 | 422 | { | ||
475 | 423 | CancelItemsPrelightStatus (); | ||
476 | 424 | CaptureMouseDownAnyWhereElse (false); | ||
477 | 425 | ForceStopFocus (1, 1); | ||
478 | 426 | UnGrabPointer (); | ||
479 | 427 | EnableInputWindow (false); | ||
480 | 428 | ShowWindow (false); | ||
481 | 429 | } | ||
483 | 430 | } | 425 | } |
484 | 431 | } | 426 | } |
485 | 432 | 427 | ||
486 | @@ -474,17 +469,9 @@ | |||
487 | 474 | { | 469 | { |
488 | 475 | // Check if the mouse was released over an item and emit the signal | 470 | // Check if the mouse was released over an item and emit the signal |
489 | 476 | CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ()); | 471 | CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ()); |
501 | 477 | 472 | ||
502 | 478 | if (!_enable_quicklist_for_testing) | 473 | Hide (); |
503 | 479 | { | 474 | } |
493 | 480 | CancelItemsPrelightStatus (); | ||
494 | 481 | CaptureMouseDownAnyWhereElse (false); | ||
495 | 482 | ForceStopFocus (1, 1); | ||
496 | 483 | UnGrabPointer (); | ||
497 | 484 | EnableInputWindow (false); | ||
498 | 485 | ShowWindow (false); | ||
499 | 486 | } | ||
500 | 487 | } | ||
504 | 488 | } | 475 | } |
505 | 489 | 476 | ||
506 | 490 | void QuicklistView::CancelItemsPrelightStatus () | 477 | void QuicklistView::CancelItemsPrelightStatus () |
507 | @@ -570,15 +557,7 @@ | |||
508 | 570 | { | 557 | { |
509 | 571 | if (IsVisible ()) | 558 | if (IsVisible ()) |
510 | 572 | { | 559 | { |
520 | 573 | if (!_enable_quicklist_for_testing) | 560 | Hide (); |
512 | 574 | { | ||
513 | 575 | CancelItemsPrelightStatus (); | ||
514 | 576 | CaptureMouseDownAnyWhereElse (false); | ||
515 | 577 | ForceStopFocus (1, 1); | ||
516 | 578 | UnGrabPointer (); | ||
517 | 579 | EnableInputWindow (false); | ||
518 | 580 | ShowWindow (false); | ||
519 | 581 | } | ||
521 | 582 | } | 561 | } |
522 | 583 | } | 562 | } |
523 | 584 | 563 | ||
524 | @@ -594,18 +573,7 @@ | |||
525 | 594 | 573 | ||
526 | 595 | void QuicklistView::RecvMouseDownOutsideOfQuicklist (int x, int y, unsigned long button_flags, unsigned long key_flags) | 574 | void QuicklistView::RecvMouseDownOutsideOfQuicklist (int x, int y, unsigned long button_flags, unsigned long key_flags) |
527 | 596 | { | 575 | { |
540 | 597 | if (IsVisible ()) | 576 | Hide (); |
529 | 598 | { | ||
530 | 599 | if (!_enable_quicklist_for_testing) | ||
531 | 600 | { | ||
532 | 601 | CancelItemsPrelightStatus (); | ||
533 | 602 | CaptureMouseDownAnyWhereElse (false); | ||
534 | 603 | ForceStopFocus (1, 1); | ||
535 | 604 | UnGrabPointer (); | ||
536 | 605 | EnableInputWindow (false); | ||
537 | 606 | ShowWindow (false); | ||
538 | 607 | } | ||
539 | 608 | } | ||
541 | 609 | } | 577 | } |
542 | 610 | 578 | ||
543 | 611 | void QuicklistView::RemoveAllMenuItem () | 579 | void QuicklistView::RemoveAllMenuItem () |
544 | 612 | 580 | ||
545 | === modified file 'src/QuicklistView.h' | |||
546 | --- src/QuicklistView.h 2010-12-09 10:55:58 +0000 | |||
547 | +++ src/QuicklistView.h 2010-12-09 20:57:22 +0000 | |||
548 | @@ -80,6 +80,9 @@ | |||
549 | 80 | 80 | ||
550 | 81 | void ShowQuicklistWithTipAt (int anchor_tip_x, int anchor_tip_y); | 81 | void ShowQuicklistWithTipAt (int anchor_tip_x, int anchor_tip_y); |
551 | 82 | virtual void ShowWindow (bool b, bool StartModal = false); | 82 | virtual void ShowWindow (bool b, bool StartModal = false); |
552 | 83 | |||
553 | 84 | void Show (); | ||
554 | 85 | void Hide (); | ||
555 | 83 | 86 | ||
556 | 84 | int GetNumItems (); | 87 | int GetNumItems (); |
557 | 85 | QuicklistMenuItem* GetNthItems (int index); | 88 | QuicklistMenuItem* GetNthItems (int index); |
+2