Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / athena / wm / split_view_controller.h
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.
4
5 #ifndef ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_
6 #define ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_
7
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"
12
13 namespace gfx {
14 class Transform;
15 }
16
17 namespace athena {
18 class WindowListProvider;
19
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 {
24  public:
25   SplitViewController(aura::Window* container,
26                       WindowListProvider* window_list_provider);
27
28   virtual ~SplitViewController();
29
30   bool IsSplitViewModeActive() const;
31
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);
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
42   void ReplaceWindow(aura::Window* window,
43                      aura::Window* replace_with);
44
45   aura::Window* left_window() { return left_window_; }
46   aura::Window* right_window() { return right_window_; }
47
48  private:
49   enum State {
50     // Split View mode is not active. |left_window_| and |right_window| are
51     // NULL.
52     INACTIVE,
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.
56     SCROLLING,
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.
59     ACTIVE
60   };
61
62   void UpdateLayout(bool animate);
63
64   void SetWindowTransform(aura::Window* left_window,
65                           const gfx::Transform& transform,
66                           bool animate);
67
68   void OnAnimationCompleted(aura::Window* window);
69
70   void UpdateSeparatorPositionFromScrollDelta(float delta);
71
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;
77
78   State state_;
79
80   aura::Window* container_;
81
82   // Provider of the list of windows to cycle through. Not owned.
83   WindowListProvider* window_list_provider_;
84
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_;
89
90   // Position of the separator between left_window_ and right_window_ in
91   // container_ coordinates (along the x axis).
92   int separator_position_;
93
94   base::WeakPtrFactory<SplitViewController> weak_factory_;
95
96   DISALLOW_COPY_AND_ASSIGN(SplitViewController);
97 };
98
99 }  // namespace athena
100
101 #endif  // ATHENA_WM_SPLIT_VIEW_CONTROLLER_H_