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" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 |
| 14 namespace gfx { |
| 15 class Transform; |
| 16 } |
10 | 17 |
11 namespace athena { | 18 namespace athena { |
| 19 class WindowListProvider; |
| 20 class WindowManager; |
| 21 class WindowOverviewModeDelegate; |
12 | 22 |
13 // Responsible for entering split view mode, exiting from split view mode, and | 23 // Responsible for entering split view mode, exiting from split view mode, and |
14 // laying out the windows in split view mode. | 24 // laying out the windows in split view mode. |
15 class SplitViewController : public BezelController::ScrollDelegate { | 25 class SplitViewController : public BezelController::ScrollDelegate, |
| 26 public WindowManagerObserver { |
16 public: | 27 public: |
17 SplitViewController(); | 28 SplitViewController(aura::Window* container, |
| 29 WindowListProvider* window_list_provider, |
| 30 WindowManager* window_manager); |
| 31 |
18 virtual ~SplitViewController(); | 32 virtual ~SplitViewController(); |
19 | 33 |
| 34 bool IsSplitViewModeActive() const; |
| 35 |
20 private: | 36 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 |
21 // BezelController::ScrollDelegate overrides. | 65 // BezelController::ScrollDelegate overrides. |
22 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; | 66 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; |
23 virtual void ScrollEnd() OVERRIDE; | 67 virtual void ScrollEnd() OVERRIDE; |
24 virtual void ScrollUpdate(float delta) OVERRIDE; | 68 virtual void ScrollUpdate(float delta) OVERRIDE; |
25 virtual bool CanScroll() OVERRIDE; | 69 virtual bool CanScroll() OVERRIDE; |
26 | 70 |
| 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 |
27 DISALLOW_COPY_AND_ASSIGN(SplitViewController); | 102 DISALLOW_COPY_AND_ASSIGN(SplitViewController); |
28 }; | 103 }; |
29 | 104 |
30 } // namespace athena | 105 } // namespace athena |
31 | 106 |
32 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 107 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
OLD | NEW |