Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: athena/wm/split_view_controller.h

Issue 545393002: Adding split view divider widget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/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"
14 #include "ui/views/widget/widget.h"
12 15
13 namespace gfx { 16 namespace gfx {
14 class Rect; 17 class Rect;
15 class Transform; 18 class Transform;
16 } 19 }
17 20
18 namespace athena { 21 namespace athena {
19 class WindowListProvider; 22 class WindowListProvider;
20 class SplitViewControllerTest; 23 class SplitViewControllerTest;
21 24
22 // Responsible for entering split view mode, exiting from split view mode, and 25 // Responsible for entering split view mode, exiting from split view mode, and
23 // laying out the windows in split view mode. 26 // laying out the windows in split view mode.
24 class ATHENA_EXPORT SplitViewController 27 class ATHENA_EXPORT SplitViewController
25 : public BezelController::ScrollDelegate { 28 : public BezelController::ScrollDelegate,
29 public DragHandle::ScrollDelegate,
30 public WindowManagerObserver {
26 public: 31 public:
27 SplitViewController(aura::Window* container, 32 SplitViewController(aura::Window* container,
28 WindowListProvider* window_list_provider); 33 WindowListProvider* window_list_provider);
29 34
30 virtual ~SplitViewController(); 35 virtual ~SplitViewController();
31 36
32 bool IsSplitViewModeActive() const; 37 bool IsSplitViewModeActive() const;
33 38
34 // Activates split-view mode with |left| and |right| windows. If |left| and/or 39 // 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 40 // |right| is NULL, then the first window in the window-list (which is neither
36 // |left| nor |right|) is selected instead. 41 // |left| nor |right|) is selected instead.
37 void ActivateSplitMode(aura::Window* left, aura::Window* right); 42 void ActivateSplitMode(aura::Window* left, aura::Window* right);
38 43
39 // Resets the internal state to an inactive state. 44 // Resets the internal state to an inactive state.
40 void DeactivateSplitMode(); 45 void DeactivateSplitMode();
41 46
42 // Replaces |window| in split-view mode with |replace_with|. Adjusts 47 // Replaces |window| in split-view mode with |replace_with|. Adjusts
43 // |replace_with|'s visibility, transform and bounds. Resets |window|'s 48 // |replace_with|'s visibility, transform and bounds. Resets |window|'s
44 // visibility and transform but does not change its bounds. 49 // visibility and transform but does not change its bounds.
45 void ReplaceWindow(aura::Window* window, 50 void ReplaceWindow(aura::Window* window,
46 aura::Window* replace_with); 51 aura::Window* replace_with);
47 52
48 // Returns the bounds that the left and right windows will have once split 53 // 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 54 // on the current value of |divider_position_|.
50 // |right_window_| are still animating this may be different than their 55 gfx::Rect GetLeftAreaBounds();
51 // current bounds. 56 gfx::Rect GetRightAreaBounds();
52 gfx::Rect GetLeftTargetBounds();
53 gfx::Rect GetRightTargetBounds();
54 57
55 aura::Window* left_window() { return left_window_; } 58 aura::Window* left_window() { return left_window_; }
56 aura::Window* right_window() { return right_window_; } 59 aura::Window* right_window() { return right_window_; }
57 60
58 private: 61 private:
59 friend class SplitViewControllerTest; 62 friend class SplitViewControllerTest;
60 63
61 enum State { 64 enum State {
62 // Split View mode is not active. |left_window_| and |right_window| are 65 // Split View mode is not active. |left_window_| and |right_window| are
63 // NULL. 66 // NULL.
64 INACTIVE, 67 INACTIVE,
65 // Two windows |left_window_| and |right_window| are shown side by side and 68 // 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 69 // there is a horizontal scroll in progress which is dragging the separator
67 // between the two windows. 70 // between the two windows.
68 SCROLLING, 71 SCROLLING,
69 // Split View mode is active with |left_window_| and |right_window| showing 72 // 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. 73 // side by side each occupying half the screen. No scroll in progress.
71 ACTIVE 74 ACTIVE
72 }; 75 };
73 76
74 void SetState(State state); 77 void SetState(State state);
78
79 views::Widget* CreateDividerWidget();
80
75 void UpdateLayout(bool animate); 81 void UpdateLayout(bool animate);
76 82
77 void SetWindowTransforms(const gfx::Transform& left_transform, 83 void SetWindowTransforms(const gfx::Transform& left_transform,
78 const gfx::Transform& right_transform, 84 const gfx::Transform& right_transform,
85 const gfx::Transform& divider_transform,
79 bool animate); 86 bool animate);
80 87
81 // Called when the animation initiated by SetWindowTransforms() completes. 88 // Called when the animation initiated by SetWindowTransforms() completes.
82 void OnAnimationCompleted(); 89 void OnAnimationCompleted();
83 90
84 void UpdateSeparatorPositionFromScrollDelta(float delta); 91 void UpdateSeparatorPositionFromScrollDelta(float delta);
85 92
86 // BezelController::ScrollDelegate: 93 // BezelController::ScrollDelegate:
87 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE; 94 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE;
88 virtual void ScrollEnd() OVERRIDE; 95 virtual void ScrollEnd() OVERRIDE;
89 virtual void ScrollUpdate(float delta) OVERRIDE; 96 virtual void ScrollUpdate(float delta) OVERRIDE;
90 virtual bool CanScroll() OVERRIDE; 97 virtual bool CanScroll() OVERRIDE;
91 98
99 // DragHandle::ScrollDelegate:
100 virtual void HandleScrollBegin(float delta) OVERRIDE;
101 virtual void HandleScrollEnd() OVERRIDE;
102 virtual void HandleScrollUpdate(float delta) OVERRIDE;
103 virtual bool HandleCanScroll() OVERRIDE;
104
105 // WindowManagerObserver:
106 virtual void OnOverviewModeEnter() OVERRIDE;
107 virtual void OnOverviewModeExit() OVERRIDE;
108 virtual void OnActivityOrderHasChanged() OVERRIDE;
Jun Mukai 2014/09/08 19:32:00 You'll have to update and reimplement the new obse
mfomitchev 2014/09/12 19:58:42 Done.
109
92 State state_; 110 State state_;
93 111
94 aura::Window* container_; 112 aura::Window* container_;
95 113
96 // Provider of the list of windows to cycle through. Not owned. 114 // Provider of the list of windows to cycle through. Not owned.
97 WindowListProvider* window_list_provider_; 115 WindowListProvider* window_list_provider_;
98 116
99 // Windows for the left and right activities shown in SCROLLING and ACTIVE 117 // Windows for the left and right activities shown in SCROLLING and ACTIVE
100 // states. In INACTIVE state these are NULL. 118 // states. In INACTIVE state these are NULL.
101 aura::Window* left_window_; 119 aura::Window* left_window_;
102 aura::Window* right_window_; 120 aura::Window* right_window_;
103 121
104 // Position of the separator between left_window_ and right_window_ in 122 // X-Coordinate of the (center of the) divider between left_window_ and
105 // container_ coordinates (along the x axis). 123 // right_window_ in |container_| coordinates.
106 int separator_position_; 124 int divider_position_;
125
126 scoped_ptr<views::Widget> divider_widget_;
Jun Mukai 2014/09/08 19:32:00 Usually views::Widget is used as self-owned, not s
mfomitchev 2014/09/12 19:58:42 Done. The widget is now created once and never des
107 127
108 base::WeakPtrFactory<SplitViewController> weak_factory_; 128 base::WeakPtrFactory<SplitViewController> weak_factory_;
109 129
110 DISALLOW_COPY_AND_ASSIGN(SplitViewController); 130 DISALLOW_COPY_AND_ASSIGN(SplitViewController);
111 }; 131 };
112 132
113 } // namespace athena 133 } // namespace athena
114 134
115 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_ 135 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698