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/athena_export.h" | 8 #include "athena/athena_export.h" |
9 #include "athena/util/drag_handle.h" | |
9 #include "athena/wm/bezel_controller.h" | 10 #include "athena/wm/bezel_controller.h" |
11 #include "athena/wm/public/window_manager_observer.h" | |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
14 class Rect; | 16 class Rect; |
15 class Transform; | 17 class Transform; |
16 } | 18 } |
17 | 19 |
20 namespace aura { | |
21 class ScopedWindowTargeter; | |
22 class Window; | |
23 class WindowTargeter; | |
24 } | |
25 | |
26 namespace views { | |
27 class Widget; | |
28 } | |
29 | |
18 namespace athena { | 30 namespace athena { |
19 class WindowListProvider; | 31 class WindowListProvider; |
20 class SplitViewControllerTest; | 32 class SplitViewControllerTest; |
21 | 33 |
22 // Responsible for entering split view mode, exiting from split view mode, and | 34 // Responsible for entering split view mode, exiting from split view mode, and |
23 // laying out the windows in split view mode. | 35 // laying out the windows in split view mode. |
24 class ATHENA_EXPORT SplitViewController | 36 class ATHENA_EXPORT SplitViewController |
25 : public BezelController::ScrollDelegate { | 37 : public BezelController::ScrollDelegate, |
38 public DragHandle::ScrollDelegate, | |
39 public WindowManagerObserver { | |
26 public: | 40 public: |
27 SplitViewController(aura::Window* container, | 41 SplitViewController(aura::Window* container, |
28 WindowListProvider* window_list_provider); | 42 WindowListProvider* window_list_provider); |
29 | 43 |
30 virtual ~SplitViewController(); | 44 virtual ~SplitViewController(); |
31 | 45 |
32 bool IsSplitViewModeActive() const; | 46 bool IsSplitViewModeActive() const; |
33 | 47 |
34 // Activates split-view mode with |left| and |right| windows. If |left| and/or | 48 // Activates split-view mode with |left| and |right| windows. If |left| and/or |
35 // |right| is NULL, then the first window in the window-list (which is neither | 49 // |right| is NULL, then the first window in the window-list (which is neither |
36 // |left| nor |right|) is selected instead. | 50 // |left| nor |right|) is selected instead. |
37 void ActivateSplitMode(aura::Window* left, aura::Window* right); | 51 void ActivateSplitMode(aura::Window* left, aura::Window* right); |
38 | 52 |
39 // Resets the internal state to an inactive state. | 53 // Resets the internal state to an inactive state. |
40 void DeactivateSplitMode(); | 54 void DeactivateSplitMode(); |
41 | 55 |
42 // Replaces |window| in split-view mode with |replace_with|. Adjusts | 56 // Replaces |window| in split-view mode with |replace_with|. Adjusts |
43 // |replace_with|'s visibility, transform and bounds. Resets |window|'s | 57 // |replace_with|'s visibility, transform and bounds. Resets |window|'s |
44 // visibility and transform but does not change its bounds. | 58 // visibility and transform but does not change its bounds. |
45 void ReplaceWindow(aura::Window* window, | 59 void ReplaceWindow(aura::Window* window, |
46 aura::Window* replace_with); | 60 aura::Window* replace_with); |
47 | 61 |
48 // Returns the bounds that the left and right windows will have once split | 62 // Returns the bounds of the left and right parts of the |container_| based |
49 // view is active and they are done animating. If |left_window_| and | 63 // on the current value of |divider_position_|. |
50 // |right_window_| are still animating this may be different than their | 64 gfx::Rect GetLeftAreaBounds(); |
51 // current bounds. | 65 gfx::Rect GetRightAreaBounds(); |
52 gfx::Rect GetLeftTargetBounds(); | |
53 gfx::Rect GetRightTargetBounds(); | |
54 | 66 |
55 aura::Window* left_window() { return left_window_; } | 67 aura::Window* left_window() { return left_window_; } |
56 aura::Window* right_window() { return right_window_; } | 68 aura::Window* right_window() { return right_window_; } |
57 | 69 |
58 private: | 70 private: |
59 friend class SplitViewControllerTest; | 71 friend class SplitViewControllerTest; |
60 | 72 |
61 enum State { | 73 enum State { |
62 // Split View mode is not active. |left_window_| and |right_window| are | 74 // Split View mode is not active. |left_window_| and |right_window| are |
63 // NULL. | 75 // NULL. |
64 INACTIVE, | 76 INACTIVE, |
65 // Two windows |left_window_| and |right_window| are shown side by side and | 77 // Two windows |left_window_| and |right_window| are shown side by side and |
66 // there is a horizontal scroll in progress which is dragging the separator | 78 // there is a horizontal scroll in progress which is dragging the separator |
67 // between the two windows. | 79 // between the two windows. |
68 SCROLLING, | 80 SCROLLING, |
69 // Split View mode is active with |left_window_| and |right_window| showing | 81 // Split View mode is active with |left_window_| and |right_window| showing |
70 // side by side each occupying half the screen. No scroll in progress. | 82 // side by side each occupying half the screen. No scroll in progress. |
71 ACTIVE | 83 ACTIVE |
72 }; | 84 }; |
73 | 85 |
74 void SetState(State state); | 86 void SetState(State state); |
87 | |
88 void InitializeDivider(); | |
89 void HideDivider(); | |
90 void ShowDivider(); | |
91 | |
75 void UpdateLayout(bool animate); | 92 void UpdateLayout(bool animate); |
76 | 93 |
77 void SetWindowTransforms(const gfx::Transform& left_transform, | 94 void SetWindowTransforms(const gfx::Transform& left_transform, |
78 const gfx::Transform& right_transform, | 95 const gfx::Transform& right_transform, |
96 const gfx::Transform& divider_transform, | |
79 bool animate); | 97 bool animate); |
80 | 98 |
81 // Called when the animation initiated by SetWindowTransforms() completes. | 99 // Called when the animation initiated by SetWindowTransforms() completes. |
82 void OnAnimationCompleted(); | 100 void OnAnimationCompleted(); |
83 | 101 |
84 void UpdateSeparatorPositionFromScrollDelta(float delta); | 102 void UpdateSeparatorPositionFromScrollDelta(float delta); |
85 | 103 |
86 // BezelController::ScrollDelegate: | 104 // BezelController::ScrollDelegate: |
87 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; | 105 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; |
88 virtual void ScrollEnd() OVERRIDE; | 106 virtual void ScrollEnd() OVERRIDE; |
89 virtual void ScrollUpdate(float delta) OVERRIDE; | 107 virtual void ScrollUpdate(float delta) OVERRIDE; |
90 virtual bool CanScroll() OVERRIDE; | 108 virtual bool CanScroll() OVERRIDE; |
91 | 109 |
110 // DragHandle::ScrollDelegate: | |
111 virtual void HandleScrollBegin(float delta) OVERRIDE; | |
112 virtual void HandleScrollEnd() OVERRIDE; | |
113 virtual void HandleScrollUpdate(float delta) OVERRIDE; | |
114 virtual bool HandleCanScroll() OVERRIDE; | |
115 | |
116 // WindowManagerObserver: | |
117 virtual void OnOverviewModeEnter() OVERRIDE; | |
118 virtual void OnOverviewModeExit() OVERRIDE; | |
119 virtual void OnSplitViewModeEnter() OVERRIDE; | |
120 virtual void OnSplitViewModeExit() OVERRIDE; | |
121 | |
92 State state_; | 122 State state_; |
93 | 123 |
94 aura::Window* container_; | 124 aura::Window* container_; |
95 | 125 |
96 // Provider of the list of windows to cycle through. Not owned. | 126 // Provider of the list of windows to cycle through. Not owned. |
97 WindowListProvider* window_list_provider_; | 127 WindowListProvider* window_list_provider_; |
98 | 128 |
99 // Windows for the left and right activities shown in SCROLLING and ACTIVE | 129 // Windows for the left and right activities shown in SCROLLING and ACTIVE |
100 // states. In INACTIVE state these are NULL. | 130 // states. In INACTIVE state these are NULL. |
101 aura::Window* left_window_; | 131 aura::Window* left_window_; |
102 aura::Window* right_window_; | 132 aura::Window* right_window_; |
103 | 133 |
104 // Position of the separator between left_window_ and right_window_ in | 134 // X-Coordinate of the (center of the) divider between left_window_ and |
105 // container_ coordinates (along the x axis). | 135 // right_window_ in |container_| coordinates. |
106 int separator_position_; | 136 int divider_position_; |
137 | |
138 // Covers the empty space between the left and right windows when split view | |
139 // is active. | |
140 scoped_ptr<aura::Window> divider_window_; | |
tdanderson
2014/09/15 17:48:19
nit: newline after 140.
mfomitchev
2014/09/15 21:43:47
Done.
| |
141 // Contains the drag handle which can be used when split view is active to | |
142 // exit the split view mode. | |
143 views::Widget* divider_widget_; | |
144 | |
145 scoped_ptr<aura::ScopedWindowTargeter> window_targeter_; | |
107 | 146 |
108 base::WeakPtrFactory<SplitViewController> weak_factory_; | 147 base::WeakPtrFactory<SplitViewController> weak_factory_; |
109 | 148 |
110 DISALLOW_COPY_AND_ASSIGN(SplitViewController); | 149 DISALLOW_COPY_AND_ASSIGN(SplitViewController); |
111 }; | 150 }; |
112 | 151 |
113 } // namespace athena | 152 } // namespace athena |
114 | 153 |
115 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 154 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
OLD | NEW |