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_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ |
6 #define ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ | 6 #define ASH_COMMON_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/common/session/session_state_observer.h" | 11 #include "ash/common/session/session_state_observer.h" |
12 #include "ash/common/shelf/wm_shelf.h" | 12 #include "ash/common/shelf/wm_shelf.h" |
13 #include "ash/common/shell_observer.h" | 13 #include "ash/common/shell_observer.h" |
14 #include "ash/common/wm/dock/docked_window_layout_manager_observer.h" | |
15 #include "ash/common/wm/lock_state_observer.h" | 14 #include "ash/common/wm/lock_state_observer.h" |
16 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h" | 15 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h" |
17 #include "ash/common/wm/workspace/workspace_types.h" | 16 #include "ash/common/wm/workspace/workspace_types.h" |
18 #include "ash/common/wm_activation_observer.h" | 17 #include "ash/common/wm_activation_observer.h" |
19 #include "ash/public/cpp/shelf_types.h" | 18 #include "ash/public/cpp/shelf_types.h" |
20 #include "base/macros.h" | 19 #include "base/macros.h" |
21 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
22 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
23 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
24 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
(...skipping 16 matching lines...) Expand all Loading... |
41 // ShelfLayoutManager is the layout manager responsible for the shelf and | 40 // ShelfLayoutManager is the layout manager responsible for the shelf and |
42 // status widgets. The shelf is given the total available width and told the | 41 // status widgets. The shelf is given the total available width and told the |
43 // width of the status area. This allows the shelf to draw the background and | 42 // width of the status area. This allows the shelf to draw the background and |
44 // layout to the status area. | 43 // layout to the status area. |
45 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 44 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
46 // closely with ShelfLayoutManager. | 45 // closely with ShelfLayoutManager. |
47 // On mus, widget bounds management is handled by the window manager. | 46 // On mus, widget bounds management is handled by the window manager. |
48 class ASH_EXPORT ShelfLayoutManager | 47 class ASH_EXPORT ShelfLayoutManager |
49 : public ShellObserver, | 48 : public ShellObserver, |
50 public WmActivationObserver, | 49 public WmActivationObserver, |
51 public DockedWindowLayoutManagerObserver, | |
52 public keyboard::KeyboardControllerObserver, | 50 public keyboard::KeyboardControllerObserver, |
53 public LockStateObserver, | 51 public LockStateObserver, |
54 public wm::WmSnapToPixelLayoutManager, | 52 public wm::WmSnapToPixelLayoutManager, |
55 public SessionStateObserver { | 53 public SessionStateObserver { |
56 public: | 54 public: |
57 ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf); | 55 ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf); |
58 ~ShelfLayoutManager() override; | 56 ~ShelfLayoutManager() override; |
59 | 57 |
60 bool updating_bounds() const { return updating_bounds_; } | 58 bool updating_bounds() const { return updating_bounds_; } |
61 | 59 |
62 // Clears internal data for shutdown process. | 60 // Clears internal data for shutdown process. |
63 void PrepareForShutdown(); | 61 void PrepareForShutdown(); |
64 | 62 |
65 // Returns whether the shelf and its contents (shelf, status) are visible | 63 // Returns whether the shelf and its contents (shelf, status) are visible |
66 // on the screen. | 64 // on the screen. |
67 bool IsVisible() const; | 65 bool IsVisible() const; |
68 | 66 |
69 // Returns the ideal bounds of the shelf assuming it is visible. | 67 // Returns the ideal bounds of the shelf assuming it is visible. |
70 gfx::Rect GetIdealBounds(); | 68 gfx::Rect GetIdealBounds(); |
71 | 69 |
72 // Returns the preferred size of the shelf for the target visibility state. | 70 // Returns the preferred size of the shelf for the target visibility state. |
73 gfx::Size GetPreferredSize(); | 71 gfx::Size GetPreferredSize(); |
74 | 72 |
75 // Returns the docked area bounds. | |
76 const gfx::Rect& dock_bounds() const { return dock_bounds_; } | |
77 | |
78 // Returns the bounds within the root window not occupied by the shelf nor the | 73 // Returns the bounds within the root window not occupied by the shelf nor the |
79 // virtual keyboard. | 74 // virtual keyboard. |
80 const gfx::Rect& user_work_area_bounds() const { | 75 const gfx::Rect& user_work_area_bounds() const { |
81 return user_work_area_bounds_; | 76 return user_work_area_bounds_; |
82 } | 77 } |
83 | 78 |
84 // Stops any animations and sets the bounds of the shelf and status widgets. | 79 // Stops any animations and sets the bounds of the shelf and status widgets. |
85 void LayoutShelfAndUpdateBounds(bool change_work_area); | 80 void LayoutShelfAndUpdateBounds(bool change_work_area); |
86 | 81 |
87 // Stops any animations, sets the bounds of the shelf and status widgets, and | 82 // Stops any animations, sets the bounds of the shelf and status widgets, and |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Returns the AutoHideState. This value is determined from the shelf and | 255 // Returns the AutoHideState. This value is determined from the shelf and |
261 // tray. | 256 // tray. |
262 ShelfAutoHideState CalculateAutoHideState( | 257 ShelfAutoHideState CalculateAutoHideState( |
263 ShelfVisibilityState visibility_state) const; | 258 ShelfVisibilityState visibility_state) const; |
264 | 259 |
265 // Returns true if |window| is a descendant of the shelf. | 260 // Returns true if |window| is a descendant of the shelf. |
266 bool IsShelfWindow(WmWindow* window); | 261 bool IsShelfWindow(WmWindow* window); |
267 | 262 |
268 int GetWorkAreaInsets(const State& state, int size) const; | 263 int GetWorkAreaInsets(const State& state, int size) const; |
269 | 264 |
270 // Overridden from DockedWindowLayoutManagerObserver: | |
271 void OnDockBoundsChanging( | |
272 const gfx::Rect& dock_bounds, | |
273 DockedWindowLayoutManagerObserver::Reason reason) override; | |
274 | |
275 // Called when the LoginUI changes from visible to invisible. | 265 // Called when the LoginUI changes from visible to invisible. |
276 void UpdateShelfVisibilityAfterLoginUIChange(); | 266 void UpdateShelfVisibilityAfterLoginUIChange(); |
277 | 267 |
278 // Compute |target_bounds| opacity based on gesture and shelf visibility. | 268 // Compute |target_bounds| opacity based on gesture and shelf visibility. |
279 float ComputeTargetOpacity(const State& state); | 269 float ComputeTargetOpacity(const State& state); |
280 | 270 |
281 // Returns true if there is a fullscreen window open that causes the shelf | 271 // Returns true if there is a fullscreen window open that causes the shelf |
282 // to be hidden. | 272 // to be hidden. |
283 bool IsShelfHiddenForFullscreen() const; | 273 bool IsShelfHiddenForFullscreen() const; |
284 | 274 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 322 |
333 // Manage the auto-hide state during the gesture. | 323 // Manage the auto-hide state during the gesture. |
334 ShelfAutoHideState gesture_drag_auto_hide_state_; | 324 ShelfAutoHideState gesture_drag_auto_hide_state_; |
335 | 325 |
336 // Used to delay updating shelf background. | 326 // Used to delay updating shelf background. |
337 UpdateShelfObserver* update_shelf_observer_; | 327 UpdateShelfObserver* update_shelf_observer_; |
338 | 328 |
339 // The bounds of the keyboard. | 329 // The bounds of the keyboard. |
340 gfx::Rect keyboard_bounds_; | 330 gfx::Rect keyboard_bounds_; |
341 | 331 |
342 // The bounds of the dock. | |
343 gfx::Rect dock_bounds_; | |
344 | |
345 // The bounds within the root window not occupied by the shelf nor the virtual | 332 // The bounds within the root window not occupied by the shelf nor the virtual |
346 // keyboard. | 333 // keyboard. |
347 gfx::Rect user_work_area_bounds_; | 334 gfx::Rect user_work_area_bounds_; |
348 | 335 |
349 // The height of the ChromeVox panel at the top of the screen, which | 336 // The height of the ChromeVox panel at the top of the screen, which |
350 // needs to be removed from the available work area. | 337 // needs to be removed from the available work area. |
351 int chromevox_panel_height_; | 338 int chromevox_panel_height_; |
352 | 339 |
353 // The show hide animation duration override or 0 for default. | 340 // The show hide animation duration override or 0 for default. |
354 int duration_override_in_ms_; | 341 int duration_override_in_ms_; |
355 | 342 |
356 // The current shelf background. Should not be assigned to directly, use | 343 // The current shelf background. Should not be assigned to directly, use |
357 // MaybeUpdateShelfBackground() instead. | 344 // MaybeUpdateShelfBackground() instead. |
358 ShelfBackgroundType shelf_background_type_; | 345 ShelfBackgroundType shelf_background_type_; |
359 | 346 |
360 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 347 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
361 }; | 348 }; |
362 | 349 |
363 } // namespace ash | 350 } // namespace ash |
364 | 351 |
365 #endif // ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ | 352 #endif // ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ |
OLD | NEW |