Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / workspace / workspace_cycler.h
blob6811d8d4bac02962beac827c77e623cd89d7d478
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"
15 namespace ash {
16 namespace internal {
18 class WorkspaceManager;
20 // Class to enable quick workspace switching (cycling) via 3 finger vertical
21 // scroll.
22 // During cycling, the workspaces are arranged in a card stack as shown below:
23 // ____________________________________________
24 // | ________________________ |
25 // | | | |
26 // | _|________________________|_ |
27 // | | | |
28 // | _|____________________________|_ |
29 // | | | |
30 // | | | |
31 // | | workspace to activate | |
32 // | | | |
33 // | | | |
34 // | _|________________________________|_ |
35 // | | | |
36 // | _|____________________________________|_ |
37 // | | | |
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 {
44 public:
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.
54 void AbortCycling();
56 private:
57 // The cycler state.
58 enum State {
59 NOT_CYCLING,
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.
67 STARTING_CYCLING,
69 // The user is moving workspaces around in the card stack.
70 CYCLING,
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
74 // of the animation.
75 STOPPING_CYCLING,
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.
99 State state_;
101 // The amount of scrolling which has occurred.
102 float scroll_x_;
103 float scroll_y_;
105 DISALLOW_COPY_AND_ASSIGN(WorkspaceCycler);
108 } // namespace internal
109 } // namespace ash
111 #endif // ASH_WM_WORKSPACE_WORKSPACE_CYCLER_H_