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/public/cpp/shelf_types.h" | 17 #include "ash/public/cpp/shelf_types.h" |
19 #include "base/macros.h" | 18 #include "base/macros.h" |
20 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
21 #include "base/scoped_observer.h" | 20 #include "base/scoped_observer.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 21 matching lines...) Expand all Loading... |
46 // ShelfLayoutManager is the layout manager responsible for the shelf and | 45 // ShelfLayoutManager is the layout manager responsible for the shelf and |
47 // 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 |
48 // 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 |
49 // layout to the status area. | 48 // layout to the status area. |
50 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 49 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
51 // closely with ShelfLayoutManager. | 50 // closely with ShelfLayoutManager. |
52 // On mus, widget bounds management is handled by the window manager. | 51 // On mus, widget bounds management is handled by the window manager. |
53 class ASH_EXPORT ShelfLayoutManager | 52 class ASH_EXPORT ShelfLayoutManager |
54 : public ShellObserver, | 53 : public ShellObserver, |
55 public aura::client::ActivationChangeObserver, | 54 public aura::client::ActivationChangeObserver, |
56 public DockedWindowLayoutManagerObserver, | |
57 public keyboard::KeyboardControllerObserver, | 55 public keyboard::KeyboardControllerObserver, |
58 public LockStateObserver, | 56 public LockStateObserver, |
59 public wm::WmSnapToPixelLayoutManager, | 57 public wm::WmSnapToPixelLayoutManager, |
60 public SessionStateObserver { | 58 public SessionStateObserver { |
61 public: | 59 public: |
62 ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf); | 60 ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf); |
63 ~ShelfLayoutManager() override; | 61 ~ShelfLayoutManager() override; |
64 | 62 |
65 bool updating_bounds() const { return updating_bounds_; } | 63 bool updating_bounds() const { return updating_bounds_; } |
66 | 64 |
67 // Clears internal data for shutdown process. | 65 // Clears internal data for shutdown process. |
68 void PrepareForShutdown(); | 66 void PrepareForShutdown(); |
69 | 67 |
70 // Returns whether the shelf and its contents (shelf, status) are visible | 68 // Returns whether the shelf and its contents (shelf, status) are visible |
71 // on the screen. | 69 // on the screen. |
72 bool IsVisible() const; | 70 bool IsVisible() const; |
73 | 71 |
74 // Returns the ideal bounds of the shelf assuming it is visible. | 72 // Returns the ideal bounds of the shelf assuming it is visible. |
75 gfx::Rect GetIdealBounds(); | 73 gfx::Rect GetIdealBounds(); |
76 | 74 |
77 // Returns the preferred size of the shelf for the target visibility state. | 75 // Returns the preferred size of the shelf for the target visibility state. |
78 gfx::Size GetPreferredSize(); | 76 gfx::Size GetPreferredSize(); |
79 | 77 |
80 // Returns the docked area bounds. | |
81 const gfx::Rect& dock_bounds() const { return dock_bounds_; } | |
82 | |
83 // Returns the bounds within the root window not occupied by the shelf nor the | 78 // Returns the bounds within the root window not occupied by the shelf nor the |
84 // virtual keyboard. | 79 // virtual keyboard. |
85 const gfx::Rect& user_work_area_bounds() const { | 80 const gfx::Rect& user_work_area_bounds() const { |
86 return user_work_area_bounds_; | 81 return user_work_area_bounds_; |
87 } | 82 } |
88 | 83 |
89 // Stops any animations and sets the bounds of the shelf and status widgets. | 84 // Stops any animations and sets the bounds of the shelf and status widgets. |
90 void LayoutShelfAndUpdateBounds(bool change_work_area); | 85 void LayoutShelfAndUpdateBounds(bool change_work_area); |
91 | 86 |
92 // Stops any animations, sets the bounds of the shelf and status widgets, and | 87 // Stops any animations, sets the bounds of the shelf and status widgets, and |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Returns the AutoHideState. This value is determined from the shelf and | 263 // Returns the AutoHideState. This value is determined from the shelf and |
269 // tray. | 264 // tray. |
270 ShelfAutoHideState CalculateAutoHideState( | 265 ShelfAutoHideState CalculateAutoHideState( |
271 ShelfVisibilityState visibility_state) const; | 266 ShelfVisibilityState visibility_state) const; |
272 | 267 |
273 // Returns true if |window| is a descendant of the shelf. | 268 // Returns true if |window| is a descendant of the shelf. |
274 bool IsShelfWindow(WmWindow* window); | 269 bool IsShelfWindow(WmWindow* window); |
275 | 270 |
276 int GetWorkAreaInsets(const State& state, int size) const; | 271 int GetWorkAreaInsets(const State& state, int size) const; |
277 | 272 |
278 // Overridden from DockedWindowLayoutManagerObserver: | |
279 void OnDockBoundsChanging( | |
280 const gfx::Rect& dock_bounds, | |
281 DockedWindowLayoutManagerObserver::Reason reason) override; | |
282 | |
283 // Called when the LoginUI changes from visible to invisible. | 273 // Called when the LoginUI changes from visible to invisible. |
284 void UpdateShelfVisibilityAfterLoginUIChange(); | 274 void UpdateShelfVisibilityAfterLoginUIChange(); |
285 | 275 |
286 // Compute |target_bounds| opacity based on gesture and shelf visibility. | 276 // Compute |target_bounds| opacity based on gesture and shelf visibility. |
287 float ComputeTargetOpacity(const State& state); | 277 float ComputeTargetOpacity(const State& state); |
288 | 278 |
289 // Returns true if there is a fullscreen window open that causes the shelf | 279 // Returns true if there is a fullscreen window open that causes the shelf |
290 // to be hidden. | 280 // to be hidden. |
291 bool IsShelfHiddenForFullscreen() const; | 281 bool IsShelfHiddenForFullscreen() const; |
292 | 282 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 330 |
341 // Manage the auto-hide state during the gesture. | 331 // Manage the auto-hide state during the gesture. |
342 ShelfAutoHideState gesture_drag_auto_hide_state_; | 332 ShelfAutoHideState gesture_drag_auto_hide_state_; |
343 | 333 |
344 // Used to delay updating shelf background. | 334 // Used to delay updating shelf background. |
345 UpdateShelfObserver* update_shelf_observer_; | 335 UpdateShelfObserver* update_shelf_observer_; |
346 | 336 |
347 // The bounds of the keyboard. | 337 // The bounds of the keyboard. |
348 gfx::Rect keyboard_bounds_; | 338 gfx::Rect keyboard_bounds_; |
349 | 339 |
350 // The bounds of the dock. | |
351 gfx::Rect dock_bounds_; | |
352 | |
353 // The bounds within the root window not occupied by the shelf nor the virtual | 340 // The bounds within the root window not occupied by the shelf nor the virtual |
354 // keyboard. | 341 // keyboard. |
355 gfx::Rect user_work_area_bounds_; | 342 gfx::Rect user_work_area_bounds_; |
356 | 343 |
357 // The height of the ChromeVox panel at the top of the screen, which | 344 // The height of the ChromeVox panel at the top of the screen, which |
358 // needs to be removed from the available work area. | 345 // needs to be removed from the available work area. |
359 int chromevox_panel_height_; | 346 int chromevox_panel_height_; |
360 | 347 |
361 // The show hide animation duration override or 0 for default. | 348 // The show hide animation duration override or 0 for default. |
362 int duration_override_in_ms_; | 349 int duration_override_in_ms_; |
363 | 350 |
364 // The current shelf background. Should not be assigned to directly, use | 351 // The current shelf background. Should not be assigned to directly, use |
365 // MaybeUpdateShelfBackground() instead. | 352 // MaybeUpdateShelfBackground() instead. |
366 ShelfBackgroundType shelf_background_type_; | 353 ShelfBackgroundType shelf_background_type_; |
367 | 354 |
368 ScopedObserver<keyboard::KeyboardController, | 355 ScopedObserver<keyboard::KeyboardController, |
369 keyboard::KeyboardControllerObserver> | 356 keyboard::KeyboardControllerObserver> |
370 keyboard_observer_; | 357 keyboard_observer_; |
371 | 358 |
372 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 359 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
373 }; | 360 }; |
374 | 361 |
375 } // namespace ash | 362 } // namespace ash |
376 | 363 |
377 #endif // ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ | 364 #endif // ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_ |
OLD | NEW |