OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 5 #ifndef ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
6 #define ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 6 #define ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
7 | 7 |
8 #include "athena/wm/bezel_controller.h" | 8 #include "athena/wm/bezel_controller.h" |
9 #include "athena/wm/public/window_manager_observer.h" | |
10 #include "athena/wm/window_overview_mode.h" | |
11 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | |
13 | |
14 namespace gfx { | |
15 class Transform; | |
16 } | |
17 | 10 |
18 namespace athena { | 11 namespace athena { |
19 class WindowListProvider; | |
20 class WindowManager; | |
21 class WindowOverviewModeDelegate; | |
22 | 12 |
23 // Responsible for entering split view mode, exiting from split view mode, and | 13 // Responsible for entering split view mode, exiting from split view mode, and |
24 // laying out the windows in split view mode. | 14 // laying out the windows in split view mode. |
25 class SplitViewController : public BezelController::ScrollDelegate, | 15 class SplitViewController : public BezelController::ScrollDelegate { |
26 public WindowManagerObserver { | |
27 public: | 16 public: |
28 SplitViewController(aura::Window* container, | 17 SplitViewController(); |
29 WindowListProvider* window_list_provider, | |
30 WindowManager* window_manager); | |
31 | |
32 virtual ~SplitViewController(); | 18 virtual ~SplitViewController(); |
33 | 19 |
34 bool IsSplitViewModeActive() const; | |
35 | |
36 private: | 20 private: |
37 enum State { | |
38 // Split View mode is not active. |left_window_| and |right_window| are | |
39 // NULL. | |
40 INACTIVE, | |
41 // Two windows |left_window_| and |right_window| are shown side by side and | |
42 // there is a horizontal scroll in progress which is dragging the separator | |
43 // between the two windows. | |
44 SCROLLING, | |
45 // Split View mode is active with |left_window_| and |right_window| showing | |
46 // side by side each occupying half the screen. No scroll in progress. | |
47 ACTIVE | |
48 }; | |
49 | |
50 void UpdateLayout(bool animate); | |
51 | |
52 void SetWindowTransform(aura::Window* left_window, | |
53 const gfx::Transform& transform, | |
54 bool animate); | |
55 | |
56 void OnAnimationCompleted(aura::Window* window); | |
57 | |
58 void UpdateSeparatorPositionFromScrollDelta(float delta); | |
59 | |
60 // Returns the current activity shown to the user. Persists through the | |
61 // SCROLLING and ACTIVE states and gets updated if the current activity goes | |
62 // off screen when the user switches between activities. | |
63 aura::Window* GetCurrentActivityWindow(); | |
64 | |
65 // BezelController::ScrollDelegate overrides. | 21 // BezelController::ScrollDelegate overrides. |
66 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; | 22 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; |
67 virtual void ScrollEnd() OVERRIDE; | 23 virtual void ScrollEnd() OVERRIDE; |
68 virtual void ScrollUpdate(float delta) OVERRIDE; | 24 virtual void ScrollUpdate(float delta) OVERRIDE; |
69 virtual bool CanScroll() OVERRIDE; | 25 virtual bool CanScroll() OVERRIDE; |
70 | 26 |
71 // WindowManagerObserver | |
72 virtual void OnOverviewModeEnter() OVERRIDE; | |
73 virtual void OnOverviewModeExit() OVERRIDE; | |
74 | |
75 State state_; | |
76 | |
77 aura::Window* container_; | |
78 | |
79 // Window Manager which owns this SplitViewController. | |
80 // Must be non NULL for the duration of the lifetime. | |
81 WindowManager* window_manager_; | |
82 | |
83 // Provider of the list of windows to cycle through. Not owned. | |
84 WindowListProvider* window_list_provider_; | |
85 | |
86 // Keeps track of the current activity shown as the user switches between | |
87 // activities. Persists through the SCROLLING and ACTIVE states. Gets reset | |
88 // to NULL when overview mode is activated. | |
89 aura::Window* current_activity_window_; | |
90 | |
91 // Windows for the left and right activities shown in SCROLLING and ACTIVE | |
92 // states. In INACTIVE state these are NULL. | |
93 aura::Window* left_window_; | |
94 aura::Window* right_window_; | |
95 | |
96 // Position of the separator between left_window_ and right_window_ in | |
97 // container_ coordinates (along the x axis). | |
98 int separator_position_; | |
99 | |
100 base::WeakPtrFactory<SplitViewController> weak_factory_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(SplitViewController); | 27 DISALLOW_COPY_AND_ASSIGN(SplitViewController); |
103 }; | 28 }; |
104 | 29 |
105 } // namespace athena | 30 } // namespace athena |
106 | 31 |
107 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 32 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
OLD | NEW |