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"
18 class WindowListProvider;
20 // Responsible for entering split view mode, exiting from split view mode, and
21 // laying out the windows in split view mode.
22 class ATHENA_EXPORT SplitViewController
23 : public BezelController::ScrollDelegate {
25 SplitViewController(aura::Window* container,
26 WindowListProvider* window_list_provider);
28 virtual ~SplitViewController();
30 bool IsSplitViewModeActive() const;
32 // Activates split-view mode with |left| and |right| windows. If |left| and/or
33 // |right| is NULL, then the first window in the window-list (which is neither
34 // |left| nor |right|) is selected instead.
35 void ActivateSplitMode(aura::Window* left, aura::Window* right);
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();
42 void ReplaceWindow(aura::Window* window,
43 aura::Window* replace_with);
45 aura::Window* left_window() { return left_window_; }
46 aura::Window* right_window() { return right_window_; }
50 // Split View mode is not active. |left_window_| and |right_window| are
53 // Two windows |left_window_| and |right_window| are shown side by side and
54 // there is a horizontal scroll in progress which is dragging the separator
55 // between the two windows.
57 // Split View mode is active with |left_window_| and |right_window| showing
58 // side by side each occupying half the screen. No scroll in progress.
62 void UpdateLayout(bool animate);
64 void SetWindowTransform(aura::Window* left_window,
65 const gfx::Transform& transform,
68 void OnAnimationCompleted(aura::Window* window);
70 void UpdateSeparatorPositionFromScrollDelta(float delta);
72 // BezelController::ScrollDelegate:
73 virtual void ScrollBegin(BezelController::Bezel bezel, float delta) OVERRIDE;
74 virtual void ScrollEnd() OVERRIDE;
75 virtual void ScrollUpdate(float delta) OVERRIDE;
76 virtual bool CanScroll() OVERRIDE;
80 aura::Window* container_;
82 // Provider of the list of windows to cycle through. Not owned.
83 WindowListProvider* window_list_provider_;
85 // Windows for the left and right activities shown in SCROLLING and ACTIVE
86 // states. In INACTIVE state these are NULL.
87 aura::Window* left_window_;
88 aura::Window* right_window_;
90 // Position of the separator between left_window_ and right_window_ in
91 // container_ coordinates (along the x axis).
92 int separator_position_;
94 base::WeakPtrFactory<SplitViewController> weak_factory_;
96 DISALLOW_COPY_AND_ASSIGN(SplitViewController);
101 #endif // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_