| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 UI_AURA_SHELL_SHELF_LAYOUT_MANAGER_H_ | |
| 6 #define UI_AURA_SHELL_SHELF_LAYOUT_MANAGER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "ui/aura/layout_manager.h" | |
| 12 #include "ui/gfx/compositor/layer_animation_observer.h" | |
| 13 #include "ui/gfx/insets.h" | |
| 14 #include "ui/gfx/rect.h" | |
| 15 | |
| 16 namespace views { | |
| 17 class Widget; | |
| 18 } | |
| 19 | |
| 20 namespace aura_shell { | |
| 21 namespace internal { | |
| 22 | |
| 23 // ShelfLayoutManager is a layout manager responsible for the launcher. | |
| 24 // Also supports showing and hiding the launcher/status area | |
| 25 // as well as positioning them. | |
| 26 class ShelfLayoutManager : public aura::LayoutManager, | |
| 27 public ui::LayerAnimationObserver { | |
| 28 public: | |
| 29 ShelfLayoutManager(views::Widget* launcher, | |
| 30 views::Widget* status); | |
| 31 virtual ~ShelfLayoutManager(); | |
| 32 | |
| 33 bool in_layout() const { return in_layout_; } | |
| 34 | |
| 35 // Stops any animations and sets the bounds of the launcher and status | |
| 36 // widgets. | |
| 37 void LayoutShelf(); | |
| 38 | |
| 39 // Sets the visbility of the shelf to |visible|. | |
| 40 void SetVisible(bool visible); | |
| 41 | |
| 42 // Overridden from aura::LayoutManager: | |
| 43 virtual void OnWindowResized() OVERRIDE; | |
| 44 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; | |
| 45 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; | |
| 46 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | |
| 47 bool visible) OVERRIDE; | |
| 48 virtual void SetChildBounds(aura::Window* child, | |
| 49 const gfx::Rect& requested_bounds) OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 struct TargetBounds { | |
| 53 gfx::Rect launcher_bounds; | |
| 54 gfx::Rect status_bounds; | |
| 55 gfx::Insets work_area_insets; | |
| 56 }; | |
| 57 | |
| 58 // Stops any animations. | |
| 59 void StopAnimating(); | |
| 60 | |
| 61 // Calculates the target bounds assuming visibility of |visibile|. | |
| 62 void CalculateTargetBounds(bool visible, | |
| 63 TargetBounds* target_bounds); | |
| 64 | |
| 65 // Animates |widget| to the specified bounds and opacity. | |
| 66 void AnimateWidgetTo(views::Widget* widget, | |
| 67 const gfx::Rect& target_bounds, | |
| 68 float target_opacity); | |
| 69 | |
| 70 // LayerAnimationObserver overrides: | |
| 71 virtual void OnLayerAnimationEnded( | |
| 72 const ui::LayerAnimationSequence* sequence) OVERRIDE; | |
| 73 virtual void OnLayerAnimationAborted( | |
| 74 const ui::LayerAnimationSequence* sequence) OVERRIDE {} | |
| 75 virtual void OnLayerAnimationScheduled( | |
| 76 const ui::LayerAnimationSequence* sequence) OVERRIDE {} | |
| 77 | |
| 78 // Are we animating? | |
| 79 bool animating_; | |
| 80 | |
| 81 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf | |
| 82 // again from SetChildBounds(). | |
| 83 bool in_layout_; | |
| 84 | |
| 85 // Current visibility. When the visibility changes this field is reset once | |
| 86 // the animation completes. | |
| 87 bool visible_; | |
| 88 | |
| 89 // Max height needed. | |
| 90 int max_height_; | |
| 91 | |
| 92 views::Widget* launcher_; | |
| 93 views::Widget* status_; | |
| 94 | |
| 95 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | |
| 96 }; | |
| 97 | |
| 98 } // namespace internal | |
| 99 } // namespace aura_shell | |
| 100 | |
| 101 #endif // UI_AURA_SHELL_SHELF_LAYOUT_MANAGER_H_ | |
| OLD | NEW |