Chromium Code Reviews| Index: ui/aura_shell/shelf_layout_manager.cc |
| diff --git a/ui/aura_shell/shelf_layout_controller.cc b/ui/aura_shell/shelf_layout_manager.cc |
| similarity index 70% |
| rename from ui/aura_shell/shelf_layout_controller.cc |
| rename to ui/aura_shell/shelf_layout_manager.cc |
| index d26af3c875590636eb09f8cd3b1f3280ee90552c..46622d3b34e534f07ab05b4de63bea6e92b30354 100644 |
| --- a/ui/aura_shell/shelf_layout_controller.cc |
| +++ b/ui/aura_shell/shelf_layout_manager.cc |
| @@ -2,8 +2,9 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ui/aura_shell/shelf_layout_controller.h" |
| +#include "ui/aura_shell/shelf_layout_manager.h" |
| +#include "base/auto_reset.h" |
| #include "ui/aura/desktop.h" |
| #include "ui/aura/screen_aura.h" |
| #include "ui/gfx/compositor/layer.h" |
| @@ -21,9 +22,13 @@ ui::Layer* GetLayer(views::Widget* widget) { |
| } // namespace |
| -ShelfLayoutController::ShelfLayoutController(views::Widget* launcher, |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ShelfLayoutManager, public: |
| + |
| +ShelfLayoutManager::ShelfLayoutManager(views::Widget* launcher, |
| views::Widget* status) |
| : animating_(false), |
| + in_layout_(false), |
| visible_(true), |
| max_height_(-1), |
| launcher_(launcher), |
| @@ -34,12 +39,14 @@ ShelfLayoutController::ShelfLayoutController(views::Widget* launcher, |
| GetLayer(launcher)->GetAnimator()->AddObserver(this); |
| } |
| -ShelfLayoutController::~ShelfLayoutController() { |
| + |
| +ShelfLayoutManager::~ShelfLayoutManager() { |
| // Do not try to remove observer from layer as the Launcher is |
| // already deleted. |
| } |
| -void ShelfLayoutController::LayoutShelf() { |
| +void ShelfLayoutManager::LayoutShelf() { |
| + AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| StopAnimating(); |
| TargetBounds target_bounds; |
| float target_opacity = visible_ ? 1.0f : 0.0f; |
| @@ -52,7 +59,7 @@ void ShelfLayoutController::LayoutShelf() { |
| target_bounds.work_area_insets); |
| } |
| -void ShelfLayoutController::SetVisible(bool visible) { |
| +void ShelfLayoutManager::SetVisible(bool visible) { |
| bool current_visibility = animating_ ? !visible_ : visible_; |
| if (visible == current_visibility) |
| return; // Nothing changed. |
| @@ -68,7 +75,34 @@ void ShelfLayoutController::SetVisible(bool visible) { |
| // |visible_| is updated once the animation completes. |
| } |
| -void ShelfLayoutController::StopAnimating() { |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ShelfLayoutManager, aura::LayoutManager implementation: |
| + |
| +void ShelfLayoutManager::OnWindowResized() { |
| + LayoutShelf(); |
| +} |
| + |
| +void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| +} |
| + |
| +void ShelfLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { |
| +} |
| + |
| +void ShelfLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, |
| + bool visible) { |
| +} |
| + |
| +void ShelfLayoutManager::SetChildBounds(aura::Window* child, |
| + const gfx::Rect& requested_bounds) { |
| + SetChildBoundsDirect(child, requested_bounds); |
| + if (!in_layout_) |
| + LayoutShelf(); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ShelfLayoutManager, private: |
| + |
| +void ShelfLayoutManager::StopAnimating() { |
| if (animating_) { |
| animating_ = false; |
| visible_ = !visible_; |
| @@ -76,7 +110,7 @@ void ShelfLayoutController::StopAnimating() { |
| GetLayer(launcher_)->GetAnimator()->StopAnimating(); |
| } |
| -void ShelfLayoutController::CalculateTargetBounds(bool visible, |
| +void ShelfLayoutManager::CalculateTargetBounds(bool visible, |
| TargetBounds* target_bounds) { |
|
sky
2011/12/05 15:42:21
nit: reformat
sky
2011/12/05 15:42:21
nit: fix indentation.
Nikita (slow)
2011/12/05 17:44:05
Done.
|
| const gfx::Rect& available_bounds(aura::Desktop::GetInstance()->bounds()); |
| int y = available_bounds.bottom() - (visible ? max_height_ : 0); |
| @@ -94,7 +128,7 @@ void ShelfLayoutController::CalculateTargetBounds(bool visible, |
| target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); |
| } |
| -void ShelfLayoutController::AnimateWidgetTo(views::Widget* widget, |
| +void ShelfLayoutManager::AnimateWidgetTo(views::Widget* widget, |
| const gfx::Rect& target_bounds, |
|
sky
2011/12/05 15:42:21
nit: fix indentation
sky
2011/12/05 15:42:21
nit: fix indentation
Nikita (slow)
2011/12/05 17:44:05
Done.
|
| float target_opacity) { |
| ui::Layer* layer = GetLayer(widget); |
| @@ -103,7 +137,7 @@ void ShelfLayoutController::AnimateWidgetTo(views::Widget* widget, |
| layer->SetOpacity(target_opacity); |
| } |
| -void ShelfLayoutController::OnLayerAnimationEnded( |
| +void ShelfLayoutManager::OnLayerAnimationEnded( |
| const ui::LayerAnimationSequence* sequence) { |
| if (!animating_) |
| return; |