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

Side by Side Diff: ash/wm/overview/window_selector.h

Issue 2918403006: CrOS Tablet Window management - Split Screen part I (Closed)
Patch Set: Add unittests. Will split the CL into two CLs. Created 3 years, 5 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
« no previous file with comments | « ash/wm/overview/window_grid.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <vector> 13 #include <vector>
14 14
15 #include "ash/ash_export.h" 15 #include "ash/ash_export.h"
16 #include "ash/wm/splitview/split_view_controller.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "ui/aura/window_observer.h" 19 #include "ui/aura/window_observer.h"
19 #include "ui/display/display_observer.h" 20 #include "ui/display/display_observer.h"
21 #include "ui/gfx/geometry/point.h"
20 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
21 #include "ui/views/controls/textfield/textfield_controller.h" 23 #include "ui/views/controls/textfield/textfield_controller.h"
22 #include "ui/wm/public/activation_change_observer.h" 24 #include "ui/wm/public/activation_change_observer.h"
23 25
24 namespace views { 26 namespace views {
25 class Textfield; 27 class Textfield;
26 class Widget; 28 class Widget;
27 } 29 }
28 30
29 namespace ash { 31 namespace ash {
30 class WindowSelectorDelegate; 32 class WindowSelectorDelegate;
31 class WindowSelectorItem; 33 class WindowSelectorItem;
32 class WindowSelectorTest; 34 class WindowSelectorTest;
33 class WindowGrid; 35 class WindowGrid;
36 class OverviewWindowDragController;
34 37
35 // The WindowSelector shows a grid of all of your windows, allowing to select 38 // The WindowSelector shows a grid of all of your windows, allowing to select
36 // one by clicking or tapping on it. 39 // one by clicking or tapping on it.
37 class ASH_EXPORT WindowSelector : public display::DisplayObserver, 40 class ASH_EXPORT WindowSelector : public display::DisplayObserver,
38 public aura::WindowObserver, 41 public aura::WindowObserver,
39 public ::wm::ActivationChangeObserver, 42 public ::wm::ActivationChangeObserver,
40 public views::TextfieldController { 43 public views::TextfieldController,
44 public SplitViewController::Observer {
41 public: 45 public:
42 // Returns true if the window can be selected in overview mode. 46 // Returns true if the window can be selected in overview mode.
43 static bool IsSelectable(aura::Window* window); 47 static bool IsSelectable(aura::Window* window);
44 48
45 enum Direction { LEFT, UP, RIGHT, DOWN }; 49 enum Direction { LEFT, UP, RIGHT, DOWN };
46 50
47 using WindowList = std::vector<aura::Window*>; 51 using WindowList = std::vector<aura::Window*>;
48 52
49 explicit WindowSelector(WindowSelectorDelegate* delegate); 53 explicit WindowSelector(WindowSelectorDelegate* delegate);
50 ~WindowSelector() override; 54 ~WindowSelector() override;
(...skipping 17 matching lines...) Expand all
68 // Accepts current selection if any. Returns true if a selection was made, 72 // Accepts current selection if any. Returns true if a selection was made,
69 // false otherwise. 73 // false otherwise.
70 bool AcceptSelection(); 74 bool AcceptSelection();
71 75
72 // Activates |item's| window. 76 // Activates |item's| window.
73 void SelectWindow(WindowSelectorItem* item); 77 void SelectWindow(WindowSelectorItem* item);
74 78
75 // Called when |window| is about to get closed. 79 // Called when |window| is about to get closed.
76 void WindowClosing(WindowSelectorItem* window); 80 void WindowClosing(WindowSelectorItem* window);
77 81
82 // Called to set bounds for window grids. Used for split view.
83 void SetBoundsForWindowGridsInScreen(const gfx::Rect& bounds);
84
85 // Removes the window selector item from the overview window grid.
86 void RemoveWindowSelectorItem(WindowSelectorItem* item);
87
88 void InitiateDrag(WindowSelectorItem* item,
89 const gfx::Point& location_in_screen);
90 void Drag(WindowSelectorItem* item, const gfx::Point& location_in_screen);
91 void CompleteDrag(WindowSelectorItem* item);
92
93 // Positions all of the windows in the overview.
94 void PositionWindows(bool animate);
95
78 WindowSelectorDelegate* delegate() { return delegate_; } 96 WindowSelectorDelegate* delegate() { return delegate_; }
79 97
80 bool restoring_minimized_windows() const { 98 bool restoring_minimized_windows() const {
81 return restoring_minimized_windows_; 99 return restoring_minimized_windows_;
82 } 100 }
83 101
84 int text_filter_bottom() const { return text_filter_bottom_; } 102 int text_filter_bottom() const { return text_filter_bottom_; }
85 103
86 bool is_shut_down() const { return is_shut_down_; } 104 bool is_shut_down() const { return is_shut_down_; }
87 105
106 const std::vector<std::unique_ptr<WindowGrid>>& grid_list_for_testing() {
107 return grid_list_;
108 }
109
88 // display::DisplayObserver: 110 // display::DisplayObserver:
89 void OnDisplayAdded(const display::Display& display) override; 111 void OnDisplayAdded(const display::Display& display) override;
90 void OnDisplayRemoved(const display::Display& display) override; 112 void OnDisplayRemoved(const display::Display& display) override;
91 void OnDisplayMetricsChanged(const display::Display& display, 113 void OnDisplayMetricsChanged(const display::Display& display,
92 uint32_t metrics) override; 114 uint32_t metrics) override;
93 115
94 // aura::WindowObserver: 116 // aura::WindowObserver:
95 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; 117 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
96 void OnWindowDestroying(aura::Window* window) override; 118 void OnWindowDestroying(aura::Window* window) override;
97 119
98 // wm::ActivationChangeObserver: 120 // wm::ActivationChangeObserver:
99 void OnWindowActivated(ActivationReason reason, 121 void OnWindowActivated(ActivationReason reason,
100 aura::Window* gained_active, 122 aura::Window* gained_active,
101 aura::Window* lost_active) override; 123 aura::Window* lost_active) override;
102 void OnAttemptToReactivateWindow(aura::Window* request_active, 124 void OnAttemptToReactivateWindow(aura::Window* request_active,
103 aura::Window* actual_active) override; 125 aura::Window* actual_active) override;
104 126
105 // views::TextfieldController: 127 // views::TextfieldController:
106 void ContentsChanged(views::Textfield* sender, 128 void ContentsChanged(views::Textfield* sender,
107 const base::string16& new_contents) override; 129 const base::string16& new_contents) override;
108 bool HandleKeyEvent(views::Textfield* sender, 130 bool HandleKeyEvent(views::Textfield* sender,
109 const ui::KeyEvent& key_event) override; 131 const ui::KeyEvent& key_event) override;
110 132
133 // SplitViewController::Observer:
134 void OnSplitViewStateChanged(SplitViewController::State previous_state,
135 SplitViewController::State state) override;
136
111 private: 137 private:
112 friend class WindowSelectorTest; 138 friend class WindowSelectorTest;
113 139
114 // Returns the aura::Window for |text_filter_widget_|. 140 // Returns the aura::Window for |text_filter_widget_|.
115 aura::Window* GetTextFilterWidgetWindow(); 141 aura::Window* GetTextFilterWidgetWindow();
116 142
117 // Position all of the windows in the overview.
118 void PositionWindows(bool animate);
119
120 // Repositions and resizes |text_filter_widget_| on 143 // Repositions and resizes |text_filter_widget_| on
121 // DisplayMetricsChanged event. 144 // DisplayMetricsChanged event.
122 void RepositionTextFilterOnDisplayMetricsChange(); 145 void RepositionTextFilterOnDisplayMetricsChange();
123 146
124 // |focus|, restores focus to the stored window. 147 // |focus|, restores focus to the stored window.
125 void ResetFocusRestoreWindow(bool focus); 148 void ResetFocusRestoreWindow(bool focus);
126 149
127 // Helper function that moves the selection widget to |direction| on the 150 // Helper function that moves the selection widget to |direction| on the
128 // corresponding window grid. 151 // corresponding window grid.
129 void Move(Direction direction, bool animate); 152 void Move(Direction direction, bool animate);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Tracks whether minimized windows are currently being restored for overview 209 // Tracks whether minimized windows are currently being restored for overview
187 // mode. 210 // mode.
188 bool restoring_minimized_windows_; 211 bool restoring_minimized_windows_;
189 212
190 // The distance between the top edge of the screen and the bottom edge of 213 // The distance between the top edge of the screen and the bottom edge of
191 // the text filtering textfield. 214 // the text filtering textfield.
192 int text_filter_bottom_; 215 int text_filter_bottom_;
193 216
194 bool is_shut_down_ = false; 217 bool is_shut_down_ = false;
195 218
219 // The drag controller for a window in the overview mode.
220 std::unique_ptr<OverviewWindowDragController> window_drag_controller_;
221
196 DISALLOW_COPY_AND_ASSIGN(WindowSelector); 222 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
197 }; 223 };
198 224
199 } // namespace ash 225 } // namespace ash
200 226
201 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 227 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
OLDNEW
« no previous file with comments | « ash/wm/overview/window_grid.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698