| 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/wm/bezel_controller.h" | 9 #include "athena/wm/bezel_controller.h" |
| 10 #include "athena/wm/public/window_manager_observer.h" | |
| 11 #include "athena/wm/window_overview_mode.h" | |
| 12 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 14 | 12 |
| 15 namespace gfx { | 13 namespace gfx { |
| 16 class Transform; | 14 class Transform; |
| 17 } | 15 } |
| 18 | 16 |
| 19 namespace athena { | 17 namespace athena { |
| 20 class WindowListProvider; | 18 class WindowListProvider; |
| 21 class WindowManager; | |
| 22 class WindowOverviewModeDelegate; | |
| 23 | 19 |
| 24 // Responsible for entering split view mode, exiting from split view mode, and | 20 // Responsible for entering split view mode, exiting from split view mode, and |
| 25 // laying out the windows in split view mode. | 21 // laying out the windows in split view mode. |
| 26 class ATHENA_EXPORT SplitViewController | 22 class ATHENA_EXPORT SplitViewController |
| 27 : public BezelController::ScrollDelegate, | 23 : public BezelController::ScrollDelegate { |
| 28 public WindowManagerObserver { | |
| 29 public: | 24 public: |
| 30 SplitViewController(aura::Window* container, | 25 SplitViewController(aura::Window* container, |
| 31 WindowListProvider* window_list_provider, | 26 WindowListProvider* window_list_provider); |
| 32 WindowManager* window_manager); | |
| 33 | 27 |
| 34 virtual ~SplitViewController(); | 28 virtual ~SplitViewController(); |
| 35 | 29 |
| 36 bool IsSplitViewModeActive() const; | 30 bool IsSplitViewModeActive() const; |
| 37 | 31 |
| 38 // Activates split-view mode with |left| and |right| windows. If |left| and/or | 32 // Activates split-view mode with |left| and |right| windows. If |left| and/or |
| 39 // |right| is NULL, then the first window in the window-list (which is neither | 33 // |right| is NULL, then the first window in the window-list (which is neither |
| 40 // |left| nor |right|) is selected instead. | 34 // |left| nor |right|) is selected instead. |
| 41 void ActivateSplitMode(aura::Window* left, aura::Window* right); | 35 void ActivateSplitMode(aura::Window* left, aura::Window* right); |
| 42 | 36 |
| 37 // Resets the internal state to an inactive state. Calling this does not |
| 38 // change the window bounds/transforms etc. The caller must take care of |
| 39 // making any necessary changes. |
| 40 void DeactivateSplitMode(); |
| 41 |
| 43 aura::Window* left_window() { return left_window_; } | 42 aura::Window* left_window() { return left_window_; } |
| 44 aura::Window* right_window() { return right_window_; } | 43 aura::Window* right_window() { return right_window_; } |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 enum State { | 46 enum State { |
| 48 // Split View mode is not active. |left_window_| and |right_window| are | 47 // Split View mode is not active. |left_window_| and |right_window| are |
| 49 // NULL. | 48 // NULL. |
| 50 INACTIVE, | 49 INACTIVE, |
| 51 // Two windows |left_window_| and |right_window| are shown side by side and | 50 // Two windows |left_window_| and |right_window| are shown side by side and |
| 52 // there is a horizontal scroll in progress which is dragging the separator | 51 // there is a horizontal scroll in progress which is dragging the separator |
| 53 // between the two windows. | 52 // between the two windows. |
| 54 SCROLLING, | 53 SCROLLING, |
| 55 // Split View mode is active with |left_window_| and |right_window| showing | 54 // Split View mode is active with |left_window_| and |right_window| showing |
| 56 // side by side each occupying half the screen. No scroll in progress. | 55 // side by side each occupying half the screen. No scroll in progress. |
| 57 ACTIVE | 56 ACTIVE |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 void UpdateLayout(bool animate); | 59 void UpdateLayout(bool animate); |
| 61 | 60 |
| 62 void SetWindowTransform(aura::Window* left_window, | 61 void SetWindowTransform(aura::Window* left_window, |
| 63 const gfx::Transform& transform, | 62 const gfx::Transform& transform, |
| 64 bool animate); | 63 bool animate); |
| 65 | 64 |
| 66 void OnAnimationCompleted(aura::Window* window); | 65 void OnAnimationCompleted(aura::Window* window); |
| 67 | 66 |
| 68 void UpdateSeparatorPositionFromScrollDelta(float delta); | 67 void UpdateSeparatorPositionFromScrollDelta(float delta); |
| 69 | 68 |
| 70 // Returns the current activity shown to the user. Persists through the | 69 // BezelController::ScrollDelegate: |
| 71 // SCROLLING and ACTIVE states and gets updated if the current activity goes | |
| 72 // off screen when the user switches between activities. | |
| 73 aura::Window* GetCurrentActivityWindow(); | |
| 74 | |
| 75 // BezelController::ScrollDelegate overrides. | |
| 76 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; | 70 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; |
| 77 virtual void ScrollEnd() OVERRIDE; | 71 virtual void ScrollEnd() OVERRIDE; |
| 78 virtual void ScrollUpdate(float delta) OVERRIDE; | 72 virtual void ScrollUpdate(float delta) OVERRIDE; |
| 79 virtual bool CanScroll() OVERRIDE; | 73 virtual bool CanScroll() OVERRIDE; |
| 80 | 74 |
| 81 // WindowManagerObserver | |
| 82 virtual void OnOverviewModeEnter() OVERRIDE; | |
| 83 virtual void OnOverviewModeExit() OVERRIDE; | |
| 84 | |
| 85 State state_; | 75 State state_; |
| 86 | 76 |
| 87 aura::Window* container_; | 77 aura::Window* container_; |
| 88 | 78 |
| 89 // Window Manager which owns this SplitViewController. The window manager must | |
| 90 // be alive for the duration of the lifetime of the SplitViewController. | |
| 91 // Can be NULL (in tests). | |
| 92 WindowManager* window_manager_; | |
| 93 | |
| 94 // Provider of the list of windows to cycle through. Not owned. | 79 // Provider of the list of windows to cycle through. Not owned. |
| 95 WindowListProvider* window_list_provider_; | 80 WindowListProvider* window_list_provider_; |
| 96 | 81 |
| 97 // Keeps track of the current activity shown as the user switches between | |
| 98 // activities. Persists through the SCROLLING and ACTIVE states. Gets reset | |
| 99 // to NULL when overview mode is activated. | |
| 100 aura::Window* current_activity_window_; | |
| 101 | |
| 102 // Windows for the left and right activities shown in SCROLLING and ACTIVE | 82 // Windows for the left and right activities shown in SCROLLING and ACTIVE |
| 103 // states. In INACTIVE state these are NULL. | 83 // states. In INACTIVE state these are NULL. |
| 104 aura::Window* left_window_; | 84 aura::Window* left_window_; |
| 105 aura::Window* right_window_; | 85 aura::Window* right_window_; |
| 106 | 86 |
| 107 // Position of the separator between left_window_ and right_window_ in | 87 // Position of the separator between left_window_ and right_window_ in |
| 108 // container_ coordinates (along the x axis). | 88 // container_ coordinates (along the x axis). |
| 109 int separator_position_; | 89 int separator_position_; |
| 110 | 90 |
| 111 base::WeakPtrFactory<SplitViewController> weak_factory_; | 91 base::WeakPtrFactory<SplitViewController> weak_factory_; |
| 112 | 92 |
| 113 DISALLOW_COPY_AND_ASSIGN(SplitViewController); | 93 DISALLOW_COPY_AND_ASSIGN(SplitViewController); |
| 114 }; | 94 }; |
| 115 | 95 |
| 116 } // namespace athena | 96 } // namespace athena |
| 117 | 97 |
| 118 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ | 98 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ |
| OLD | NEW |