Remove implicit conversions from scoped_refptr to T* in sandbox/
[chromium-blink-merge.git] / athena / wm / split_view_controller.h
blobd0e70735e3899f6d892cf028048dddc985ee249e
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
3 // found in the LICENSE file.
5 #ifndef ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_
6 #define ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_
8 #include "athena/athena_export.h"
9 #include "athena/wm/bezel_controller.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
13 namespace gfx {
14 class Rect;
15 class Transform;
18 namespace athena {
19 class WindowListProvider;
21 // Responsible for entering split view mode, exiting from split view mode, and
22 // laying out the windows in split view mode.
23 class ATHENA_EXPORT SplitViewController
24 : public BezelController::ScrollDelegate {
25 public:
26 SplitViewController(aura::Window* container,
27 WindowListProvider* window_list_provider);
29 virtual ~SplitViewController();
31 bool IsSplitViewModeActive() const;
33 // Activates split-view mode with |left| and |right| windows. If |left| and/or
34 // |right| is NULL, then the first window in the window-list (which is neither
35 // |left| nor |right|) is selected instead.
36 void ActivateSplitMode(aura::Window* left, aura::Window* right);
38 // Resets the internal state to an inactive state. Calling this does not
39 // change the window bounds/transforms etc. The caller must take care of
40 // making any necessary changes.
41 void DeactivateSplitMode();
43 void ReplaceWindow(aura::Window* window,
44 aura::Window* replace_with);
46 // Returns the bounds that the left and right windows will have once split
47 // view is active and they are done animating. If |left_window_| and
48 // |right_window_| are still animating this may be different than their
49 // current bounds.
50 gfx::Rect GetLeftTargetBounds();
51 gfx::Rect GetRightTargetBounds();
53 aura::Window* left_window() { return left_window_; }
54 aura::Window* right_window() { return right_window_; }
56 private:
57 enum State {
58 // Split View mode is not active. |left_window_| and |right_window| are
59 // NULL.
60 INACTIVE,
61 // Two windows |left_window_| and |right_window| are shown side by side and
62 // there is a horizontal scroll in progress which is dragging the separator
63 // between the two windows.
64 SCROLLING,
65 // Split View mode is active with |left_window_| and |right_window| showing
66 // side by side each occupying half the screen. No scroll in progress.
67 ACTIVE
70 void UpdateLayout(bool animate);
72 void SetWindowTransform(aura::Window* left_window,
73 const gfx::Transform& transform,
74 bool animate);
76 void OnAnimationCompleted(aura::Window* window);
78 void UpdateSeparatorPositionFromScrollDelta(float delta);
80 // BezelController::ScrollDelegate:
81 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE;
82 virtual void ScrollEnd() OVERRIDE;
83 virtual void ScrollUpdate(float delta) OVERRIDE;
84 virtual bool CanScroll() OVERRIDE;
86 State state_;
88 aura::Window* container_;
90 // Provider of the list of windows to cycle through. Not owned.
91 WindowListProvider* window_list_provider_;
93 // Windows for the left and right activities shown in SCROLLING and ACTIVE
94 // states. In INACTIVE state these are NULL.
95 aura::Window* left_window_;
96 aura::Window* right_window_;
98 // Position of the separator between left_window_ and right_window_ in
99 // container_ coordinates (along the x axis).
100 int separator_position_;
102 base::WeakPtrFactory<SplitViewController> weak_factory_;
104 DISALLOW_COPY_AND_ASSIGN(SplitViewController);
107 } // namespace athena
109 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_