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