1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_CYCLER_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_CYCLER_H_
8 #include "ash/ash_export.h"
9 #include "ash/wm/workspace/workspace_cycler_animator.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/base/events/event_handler.h"
18 class WorkspaceManager
;
20 // Class to enable quick workspace switching (cycling) via 3 finger vertical
22 // During cycling, the workspaces are arranged in a card stack as shown below:
23 // ____________________________________________
24 // | ________________________ |
26 // | _|________________________|_ |
28 // | _|____________________________|_ |
31 // | | workspace to activate | |
34 // | _|________________________________|_ |
36 // | _|____________________________________|_ |
38 // |_|________________________________________|_|
39 // The user selects a workspace to activate by moving the workspace they want
40 // to activate to the most prominent position in the card stack.
42 class ASH_EXPORT WorkspaceCycler
: public ui::EventHandler
,
43 public WorkspaceCyclerAnimator::Delegate
{
45 explicit WorkspaceCycler(WorkspaceManager
* workspace_manager
);
46 virtual ~WorkspaceCycler();
48 // Abort any animations that the cycler is doing. The active workspace is set
49 // to the active workspace before cycling was initiated.
50 // Cycling should be aborted:
51 // - Before a workspace is added or destroyed.
52 // - Before a workspace is activated.
53 // - When the workspace bounds or the shelf bounds change.
61 // The cycler is waiting for the user to scroll far enough vertically to
62 // trigger cycling workspaces.
63 NOT_CYCLING_TRACKING_SCROLL
,
65 // The workspaces are animating into a card stack configuration. The cycler
66 // is in this state for the duration of the animation.
69 // The user is moving workspaces around in the card stack.
72 // The workspace that the user selected to be active is being animated to
73 // take up the entire screen. The cycler is in this state for the duration
78 // Set the cycler state to |new_state|.
79 // The state is not changed if transitioning from the current state to
80 // |new_state| is not valid.
81 void SetState(State new_state
);
83 // Returns true if transitioning from |state_| to |next_state| is valid.
84 bool IsValidNextState(State next_state
) const;
86 // ui::EventHandler overrides:
87 virtual void OnEvent(ui::Event
* event
) OVERRIDE
;
88 virtual void OnScrollEvent(ui::ScrollEvent
* event
) OVERRIDE
;
90 // WorkspaceCyclerAnimator::Delegate overrides:
91 virtual void StartWorkspaceCyclerAnimationFinished() OVERRIDE
;
92 virtual void StopWorkspaceCyclerAnimationFinished() OVERRIDE
;
94 WorkspaceManager
* workspace_manager_
;
96 scoped_ptr
<WorkspaceCyclerAnimator
> animator_
;
98 // The cycler's state.
101 // The amount of scrolling which has occurred.
105 DISALLOW_COPY_AND_ASSIGN(WorkspaceCycler
);
108 } // namespace internal
111 #endif // ASH_WM_WORKSPACE_WORKSPACE_CYCLER_H_