OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_SHELF_SHELF_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ | 6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/public/cpp/shelf_types.h" | 11 #include "ash/public/cpp/shelf_types.h" |
12 #include "ash/session/session_observer.h" | 12 #include "ash/session/session_observer.h" |
13 #include "ash/shelf/wm_shelf.h" | 13 #include "ash/shelf/shelf.h" |
14 #include "ash/shell_observer.h" | 14 #include "ash/shell_observer.h" |
15 #include "ash/wm/lock_state_observer.h" | 15 #include "ash/wm/lock_state_observer.h" |
16 #include "ash/wm/wm_snap_to_pixel_layout_manager.h" | 16 #include "ash/wm/wm_snap_to_pixel_layout_manager.h" |
17 #include "ash/wm/workspace/workspace_types.h" | 17 #include "ash/wm/workspace/workspace_types.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/scoped_observer.h" | 20 #include "base/scoped_observer.h" |
21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
22 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
24 #include "ui/keyboard/keyboard_controller_observer.h" | 24 #include "ui/keyboard/keyboard_controller_observer.h" |
25 #include "ui/wm/public/activation_change_observer.h" | 25 #include "ui/wm/public/activation_change_observer.h" |
26 | 26 |
27 namespace keyboard { | 27 namespace keyboard { |
28 class KeyboardController; | 28 class KeyboardController; |
29 } | 29 } |
30 | 30 |
31 namespace ui { | 31 namespace ui { |
32 class ImplicitAnimationObserver; | 32 class ImplicitAnimationObserver; |
33 class MouseEvent; | 33 class MouseEvent; |
34 } | 34 } |
35 | 35 |
36 namespace ash { | 36 namespace ash { |
37 | 37 |
38 enum class AnimationChangeType; | 38 enum class AnimationChangeType; |
39 class PanelLayoutManagerTest; | 39 class PanelLayoutManagerTest; |
| 40 class Shelf; |
40 class ShelfLayoutManagerObserver; | 41 class ShelfLayoutManagerObserver; |
41 class ShelfLayoutManagerTest; | 42 class ShelfLayoutManagerTest; |
42 class ShelfWidget; | 43 class ShelfWidget; |
43 class WmShelf; | |
44 | 44 |
45 // ShelfLayoutManager is the layout manager responsible for the shelf and | 45 // ShelfLayoutManager is the layout manager responsible for the shelf and |
46 // status widgets. The shelf is given the total available width and told the | 46 // status widgets. The shelf is given the total available width and told the |
47 // width of the status area. This allows the shelf to draw the background and | 47 // width of the status area. This allows the shelf to draw the background and |
48 // layout to the status area. | 48 // layout to the status area. |
49 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 49 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
50 // closely with ShelfLayoutManager. | 50 // closely with ShelfLayoutManager. |
51 // On mus, widget bounds management is handled by the window manager. | 51 // On mus, widget bounds management is handled by the window manager. |
52 class ASH_EXPORT ShelfLayoutManager | 52 class ASH_EXPORT ShelfLayoutManager |
53 : public ShellObserver, | 53 : public ShellObserver, |
54 public aura::client::ActivationChangeObserver, | 54 public aura::client::ActivationChangeObserver, |
55 public keyboard::KeyboardControllerObserver, | 55 public keyboard::KeyboardControllerObserver, |
56 public LockStateObserver, | 56 public LockStateObserver, |
57 public wm::WmSnapToPixelLayoutManager, | 57 public wm::WmSnapToPixelLayoutManager, |
58 public SessionObserver { | 58 public SessionObserver { |
59 public: | 59 public: |
60 ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf); | 60 ShelfLayoutManager(ShelfWidget* shelf_widget, Shelf* shelf); |
61 ~ShelfLayoutManager() override; | 61 ~ShelfLayoutManager() override; |
62 | 62 |
63 bool updating_bounds() const { return updating_bounds_; } | 63 bool updating_bounds() const { return updating_bounds_; } |
64 | 64 |
65 // Clears internal data for shutdown process. | 65 // Clears internal data for shutdown process. |
66 void PrepareForShutdown(); | 66 void PrepareForShutdown(); |
67 | 67 |
68 // Returns whether the shelf and its contents (shelf, status) are visible | 68 // Returns whether the shelf and its contents (shelf, status) are visible |
69 // on the screen. | 69 // on the screen. |
70 bool IsVisible() const; | 70 bool IsVisible() const; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 void OnLockStateEvent(LockStateObserver::EventType event) override; | 152 void OnLockStateEvent(LockStateObserver::EventType event) override; |
153 | 153 |
154 // Overridden from SessionObserver: | 154 // Overridden from SessionObserver: |
155 void OnSessionStateChanged(session_manager::SessionState state) override; | 155 void OnSessionStateChanged(session_manager::SessionState state) override; |
156 void OnLoginStatusChanged(LoginStatus loing_status) override; | 156 void OnLoginStatusChanged(LoginStatus loing_status) override; |
157 | 157 |
158 // TODO(harrym|oshima): These templates will be moved to a new Shelf class. | 158 // TODO(harrym|oshima): These templates will be moved to a new Shelf class. |
159 // A helper function for choosing values specific to a shelf alignment. | 159 // A helper function for choosing values specific to a shelf alignment. |
160 template <typename T> | 160 template <typename T> |
161 T SelectValueForShelfAlignment(T bottom, T left, T right) const { | 161 T SelectValueForShelfAlignment(T bottom, T left, T right) const { |
162 switch (wm_shelf_->GetAlignment()) { | 162 switch (shelf_->alignment()) { |
163 case SHELF_ALIGNMENT_BOTTOM: | 163 case SHELF_ALIGNMENT_BOTTOM: |
164 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 164 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
165 return bottom; | 165 return bottom; |
166 case SHELF_ALIGNMENT_LEFT: | 166 case SHELF_ALIGNMENT_LEFT: |
167 return left; | 167 return left; |
168 case SHELF_ALIGNMENT_RIGHT: | 168 case SHELF_ALIGNMENT_RIGHT: |
169 return right; | 169 return right; |
170 } | 170 } |
171 NOTREACHED(); | 171 NOTREACHED(); |
172 return right; | 172 return right; |
173 } | 173 } |
174 | 174 |
175 template <typename T> | 175 template <typename T> |
176 T PrimaryAxisValue(T horizontal, T vertical) const { | 176 T PrimaryAxisValue(T horizontal, T vertical) const { |
177 return wm_shelf_->IsHorizontalAlignment() ? horizontal : vertical; | 177 return shelf_->IsHorizontalAlignment() ? horizontal : vertical; |
178 } | 178 } |
179 | 179 |
180 // Returns how the shelf background should be painted. | 180 // Returns how the shelf background should be painted. |
181 ShelfBackgroundType GetShelfBackgroundType() const; | 181 ShelfBackgroundType GetShelfBackgroundType() const; |
182 | 182 |
183 // Set the height of the ChromeVox panel, which takes away space from the | 183 // Set the height of the ChromeVox panel, which takes away space from the |
184 // available work area from the top of the screen. | 184 // available work area from the top of the screen. |
185 void SetChromeVoxPanelHeight(int height); | 185 void SetChromeVoxPanelHeight(int height); |
186 | 186 |
187 private: | 187 private: |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 bool in_shutdown_ = false; | 302 bool in_shutdown_ = false; |
303 | 303 |
304 // True if the last mouse event was a mouse drag. | 304 // True if the last mouse event was a mouse drag. |
305 bool in_mouse_drag_ = false; | 305 bool in_mouse_drag_ = false; |
306 | 306 |
307 // Current state. | 307 // Current state. |
308 State state_; | 308 State state_; |
309 | 309 |
310 ShelfWidget* shelf_widget_; | 310 ShelfWidget* shelf_widget_; |
311 WmShelf* wm_shelf_; | 311 Shelf* shelf_; |
312 | 312 |
313 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 313 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
314 bool window_overlaps_shelf_; | 314 bool window_overlaps_shelf_; |
315 | 315 |
316 base::OneShotTimer auto_hide_timer_; | 316 base::OneShotTimer auto_hide_timer_; |
317 | 317 |
318 // Whether the mouse was over the shelf when the auto hide timer started. | 318 // Whether the mouse was over the shelf when the auto hide timer started. |
319 // False when neither the auto hide timer nor the timer task are running. | 319 // False when neither the auto hide timer nor the timer task are running. |
320 bool mouse_over_shelf_when_auto_hide_timer_started_; | 320 bool mouse_over_shelf_when_auto_hide_timer_started_; |
321 | 321 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 keyboard::KeyboardControllerObserver> | 365 keyboard::KeyboardControllerObserver> |
366 keyboard_observer_; | 366 keyboard_observer_; |
367 ScopedSessionObserver scoped_session_observer_; | 367 ScopedSessionObserver scoped_session_observer_; |
368 | 368 |
369 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 369 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
370 }; | 370 }; |
371 | 371 |
372 } // namespace ash | 372 } // namespace ash |
373 | 373 |
374 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ | 374 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
OLD | NEW |