LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OverlayWindowManager.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2013 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef OVERLAYWINDOWMANAGER_H
23 #define OVERLAYWINDOWMANAGER_H
24 
25 #include "Common.h"
26 
27 #include "Timer.h"
28 #include "sptr.h"
29 #include "Event.h"
30 #include "WindowManagerBase.h"
31 #include "dimensionsmain.h"
32 #include "dimensionstypes.h"
33 #include "pixmaploader.h"
34 #include "pixmapobject.h"
35 
36 #include <vector>
37 #include <string>
38 
39 #include <QGraphicsSceneMouseEvent>
40 #include <QPropertyAnimation>
41 #include <QParallelAnimationGroup>
42 #include <QTapAndHoldGesture>
43 #include <QPointer>
44 
45 QT_BEGIN_NAMESPACE
46 class QGestureEvent;
47 class QGraphicsObject;
48 class QStateMachine;
49 class QState;
50 QT_END_NAMESPACE
51 
52 class DragWindow;
54 class FlickGesture;
55 class LaunchPoint;
56 class SearchPill;
57 
59 {
60  Q_OBJECT
61  Q_ENUMS(LauncherState)
62  Q_ENUMS(DockState)
63  Q_ENUMS(SearchPillState)
64  Q_ENUMS(UniversalSearchState)
65  Q_PROPERTY(DockState dockState READ dockState WRITE setDockState)
69  Q_PROPERTY(bool dockShown READ dockShown WRITE setDockShown)
73 
74 public:
75 
80  };
81 
82  enum DockState {
86  };
87 
91  };
92 
96  };
97 
98  OverlayWindowManager(int maxWidth, int maxHeight);
100 
102 
103  void init();
104 
105  // property 'quickLaunchVisibleArea' read function
106  QRectF quickLaunchVisibleArea() const;
107 
108  // property 'quickLaunchVisiblePosition' read function
109  QPointF quickLaunchVisiblePosition() const;
110 
111  // property 'universalSearchState' access functions
112  UniversalSearchState universalSearchState() const { return m_uSearchState; }
113  void setUniversalSearchState(UniversalSearchState s) { m_uSearchState = s; }
114 
115  // property 'searchPillState' access functions
116  SearchPillState searchPillState() const { return m_searchPillState; }
117  void setSearchPillState(SearchPillState s) { m_searchPillState = s; }
118 
119  // property 'dockState' access functions
120  DockState dockState() const { return m_dockState; }
121  void setDockState(DockState s) { m_dockState = s; }
122 
123  // property 'launcherState' access functions
124  LauncherState launcherState() const { return m_launcherState; }
125  void setLauncherState(LauncherState s) { m_launcherState = s; }
126 
127  // property 'dockShown' access functions
128  bool dockShown() const;
129  void setDockShown(bool shown);
130 
131  // property 'universalSearchShown' access functions
132  bool universalSearchShown() const;
133  void setUniversalSearchShown(bool shown);
134 
135  void addWindow(Window* win);
136 
137  bool launcherVisible() const;
138 
139  // launch feedback for the Universal Search window
140  void applyLaunchFeedback(int centerX, int centerY);
141 
142  int lastPenX() const { return m_lastPenX; }
143  int lastPenY() const { return m_lastPenY; }
144 
145  bool inDrag() const { return m_inDrag; }
146  bool canRedirectDragToQuicklaunch(const QPointF& dragPosition);
147 
148  bool okToResize();
149  void resize(int width, int height);
150 
151  // REMOVE ME: this is a workaround to make the quick launch toggle the new launcher
152  void toggleLauncher() { slotSystemAPIToggleLauncher(); }
153 
154  Quicklauncher * quicklaunchBar() const { return m_dockWin; }
155 
156  virtual bool handleNavigationEvent(QKeyEvent* keyEvent, bool& propogate);
157 
158 protected:
159 
160  bool sceneEvent(QEvent* event);
161  void mousePressEvent(QGraphicsSceneMouseEvent* event);
162  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
163  void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
164  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
165  void keyPressEvent(QKeyEvent* event);
166  void keyReleaseEvent(QKeyEvent* event);
167 
168  bool mouseFlickEvent(FlickGesture* flick);
169 
170 private:
171 
172  bool dockInAnimation() const;
173  void mapCoordToWindow(Window* win, int& x, int& y) const;
174 
175  void setupSearchPill();
176  void setupDock();
177  bool setupLauncher();
178  void setupDragWindow();
179  void setupFeedbackWindow();
180 
181  void setupLauncherAnimations();
182  void setupDockAnimations();
183  void setupSearchPillAnimations();
184  void setupUniversalSearchAnimations();
185 
186  void setupDockStateMachine();
187  void setupLauncherStateMachine();
188  void setupSearchPillStateMachine();
189  void setupUniversalSearchStateMachine();
190 
191  QState* createState(QString name, QState *parent = NULL);
192 
193  bool handlePenDownEvent(Event* event);
194  bool handlePenMoveEvent(Event* event);
195  bool handlePenUpEvent(Event* event);
196  bool handlePenFlickEvent(Event* event);
197  bool handlePenCancelEvent(Event* event);
198  bool handlePressAndHoldEvent(Event* event);
199 
200  bool handlePenMoveEventStateNormal(Event* event);
201  void handlePenMoveEventStateStache(Event* event);
202 
203  bool handlePenUpEventStateNormal(Event* event);
204  bool handlePenUpEventStateStache(Event* event);
205 
206  void handlePenCancelEventStateStache(Event* event);
207 
208  void cancelReorder();
209 
210 //THESE ARE INTERNAL STATE MACHINE TRIGGERS ONLY!!! DO NOT HOOK UP TO EXTERNAL SLOTS
211 Q_SIGNALS:
212 
215 
216  void signalFSMShowLauncher();
217  void signalFSMHideLauncher();
218 
221 
222  void signalFSMShowDock(); // show dock (quicklaunch)
223  void signalFSMHideDock(); // hide dock (quicklaunch)
224 
225  void signalFSMDragStarted();
226  void signalFSMDragEnded();
228 //THESE ARE INTERNAL STATE MACHINE TRIGGERS ONLY!!! DO NOT HOOK UP TO EXTERNAL SIGNALS
229 private Q_SLOTS:
230 
231  void slotFSMUniversalSearchVisible();
232  void slotFSMUniversalSearchHidden();
233  void slotUniversalSearchFocusChange (bool enabled);
235 
236 Q_SIGNALS:
237  void signalPenUpEvent(); // release event
238  void signalPenCancelEvent(); // cancel event
239  void signalLauncherOpened(); // launcher was opened
240  void signalLauncherClosed(); // launcher was closed
241  void signalUniversalSearchOpened(); // (obvious)
243 
244 private Q_SLOTS:
245 
246  //
247  void slotSystemAPIToggleLauncher();
248  void slotSystemAPICloseLauncher();
249  void slotSystemAPIOpenLauncher();
250  void slotSystemAPIRecreateLauncher();
251 
253 
254  void slotLauncherOpenState();
255  void slotLauncherClosedState();
256 
257  void slotPositiveSpaceAboutToChange(const QRect& r, bool fullScreen, bool screenResizing);
258  void slotPositiveSpaceChangeFinished(const QRect& r);
259  void slotPositiveSpaceChanged(const QRect& r);
260  void slotCardWindowMaximized();
261  void slotCardWindowMinimized();
262  void slotEmergencyModeChanged(bool enabled);
263 
264  // These are used by the Dimensions Launcher itself to ask for things to happen. Don't call/trigger from anywhere else.
265  // (use the other, external slot interfaces for general launcher control from outside OWM)
266  void slotLauncherRequestShowDimensionsLauncher(DimensionsTypes::ShowCause::Enum cause = DimensionsTypes::ShowCause::None);
267  void slotLauncherRequestHideDimensionsLauncher(DimensionsTypes::HideCause::Enum cause = DimensionsTypes::HideCause::None);
268 
269  void slotLauncherReady();
270  void slotLauncherNotReady();
271 
272  void slotQuickLaunchReady();
273  void slotQuickLaunchNotReady();
274 
275  void slotShowDock();
276  void slotHideDock();
277 
278  void slotStartShowLauncherSequence();
279  void slotStartHideLauncherSequence();
280 
281  void slotAnimateShowDock();
282  void slotAnimateHideDock();
283 
284  void slotAnimateFadeOutSearchPill();
285  void slotAnimateFadeInSearchPill();
286 
287  void slotAnimateHideUniversalSearch();
288  void slotAnimateShowUniversalSearch();
289 
290  void slotFadeDock(bool fadeOut);
291  void slotLauncherOpened();
292  void slotLauncherClosed();
293 
294  void slotShowUniversalSearch(bool hideLauncher=true);
295  void slotHideUniversalSearch(bool showLauncher, bool speedDial);
296 
297  void launcherAnimationFinished();
298  void dockAnimationFinished();
299  void universalSearchOpacityAnimationFinished();
300 
301  // $$$ DEBUG - remove
302  void dockStateTransition();
303  void launcherStateTransition();
304 
305  void slotDisplayStateChange(int);
306 
307 private:
308 
309  QPropertyAnimation * dimensionsLauncherShowUpAnimation();
310  void dimensionsLauncherShowUpAnimation(QPropertyAnimation * p_anim);
311  QPropertyAnimation * dimensionsLauncherHideDownAnimation();
312  void dimensionsLauncherHideDownAnimation(QPropertyAnimation * p_anim);
313 
314  void fadeOutSearchPillAnimation(QPropertyAnimation * p_anim);
315  void fadeInSearchPillAnimation(QPropertyAnimation * p_anim);
316 
317  void fadeOutUniversalSearchAnimation(QPropertyAnimation * p_anim);
318  void fadeInUniversalSearchAnimation(QPropertyAnimation * p_anim);
319 
320  //call this after a resize of OWM of any kind, so that it can reposition; there is no animation here, just a setPos
321  void dimensionsLauncherAdjustPositionOnResize();
322 
323  void animateShowLauncher();
324  void animateHideLauncher();
325 
326 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
327  bool handleTouchBegin(QTouchEvent *e);
328  bool handleTouchEnd(QTouchEvent *e);
329  bool handleTouchUpdate(QTouchEvent *e);
330 #endif
331 
332 private:
333 
334  enum DragIconState {
335  DragInvalid,
336  DragQuicklaunch,
337  DragLauncher,
338  };
339 
340  enum PenDownState {
341  PenDownInvalid,
342  PenDownInSearch
343  };
344 
345  QRectF m_geom;
346  QSize m_screenSize; //precomputed from m_geom, aligned to px coords
347  Quicklauncher * m_dockWin;
348  bool m_dockShown;
349  QPoint m_dockShownPos;
350  QPoint m_dockHiddenPos;
351 
352  int m_dockOffsetFromBottom;
353  int m_oldDockOffsetFromBottom;
354 
355  Window* m_universalSearchWin;
356  bool m_universalSearchShown;
357  bool m_ignoreKeyDueToSpeedDialEvent;
358  int m_keyDown;
359 
360  SearchPill* m_searchPill;
361  DragWindow* m_dragWin;
362 
363  int m_lastPenX, m_lastPenY;
364  bool m_dockWasShownBeforeDrag;
365 
366  bool m_inDrag;
367 
368  PenDownState m_penDownState;
369 
370  bool m_dockHasMetFinger;
371 
372  LauncherFeedbackWindow* m_feedbackWindow;
373  QSize m_feedbackOffset;
374 
375  QPointer<QStateMachine> m_searchPillStateMachine;
376  QPointer<QStateMachine> m_dockStateMachine;
377  QPointer<QStateMachine> m_launcherStateMachine;
378  QPointer<QStateMachine> m_universalSearchStateMachine;
379 
380  struct SearchPillStateManager {
381  QState * pillHidden;
382  QState * pillVisible;
383  };
384 
385  struct DockStateManager {
386  QState *noDock;
387  QState *dockNormal;
388  QState *dockReorder;
389  };
390 
391  struct LauncherStateManager {
392  QState *noLauncher;
393  QState *launcherRegular;
394  QState *launcherReorder;
395  };
396 
397  struct UniversalSearchStateManager {
398  QState *uSearchHidden;
399  QState *uSearchVisible;
400  };
401 
402  SearchPillStateManager *m_searchPillStates;
403  DockStateManager *m_dockStates;
404  LauncherStateManager *m_launcherStates;
405  UniversalSearchStateManager *m_uSearchStates;
406 
407  SearchPillState m_searchPillState;
408  DockState m_dockState;
409  LauncherState m_launcherState;
410  DragIconState m_dragSource;
411  UniversalSearchState m_uSearchState;
412 
413  // these animatios are used by the State Machines ONLY
414  QPropertyAnimation *m_animateLauncherOpacity;
415  QPointer<QPropertyAnimation> m_qp_animateUniversalSearchOpacity;
416  QPointer<QPropertyAnimation> m_qp_animateSearchPillOpacity;
417 
418  // these are the animations that we control directly (not via the state machine)
419  QPropertyAnimation *m_dockOpacityAnimation;
420  QPropertyAnimation *m_dockPosAnimation;
421  QPropertyAnimation *m_dockBgOpacityAnimation;
422 
423  QPointer<QPropertyAnimation> m_qp_launcherPosAnimation;
424 
425  bool m_pendingLauncherRecreate;
426 
427  friend class WindowServerLuna;
428 
429 };
430 
431 Q_DECLARE_METATYPE(OverlayWindowManager::DockState)
432 Q_DECLARE_METATYPE(OverlayWindowManager::LauncherState)
433 
434 #endif /* OVERLAYWINDOWMANAGER_H */