Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: ui/aura_shell/shelf_layout_manager.cc

Issue 8743014: [cros, Aura] Refresh status area widget bounds on StatusAreaView layout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 71%
rename from ui/aura_shell/shelf_layout_controller.cc
rename to ui/aura_shell/shelf_layout_manager.cc
index 7e7f851a68ed3a7e064679ea0e3ff1e70dc1e976..cd0181336021a861a02080027ec2248254d6efdf 100644
--- a/ui/aura_shell/shelf_layout_controller.cc
+++ b/ui/aura_shell/shelf_layout_manager.cc
@@ -2,7 +2,7 @@
// 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 "ui/aura/desktop.h"
#include "ui/aura/screen_aura.h"
@@ -21,7 +21,10 @@ ui::Layer* GetLayer(views::Widget* widget) {
} // namespace
-ShelfLayoutController::ShelfLayoutController(views::Widget* launcher,
+////////////////////////////////////////////////////////////////////////////////
+// ShelfLayoutManager, public:
+
+ShelfLayoutManager::ShelfLayoutManager(views::Widget* launcher,
views::Widget* status)
: animating_(false),
visible_(true),
@@ -34,24 +37,11 @@ ShelfLayoutController::ShelfLayoutController(views::Widget* launcher,
GetLayer(launcher)->GetAnimator()->AddObserver(this);
}
-ShelfLayoutController::~ShelfLayoutController() {
+ShelfLayoutManager::~ShelfLayoutManager() {
GetLayer(launcher_)->GetAnimator()->RemoveObserver(this);
}
-void ShelfLayoutController::LayoutShelf() {
- StopAnimating();
- TargetBounds target_bounds;
- float target_opacity = visible_ ? 1.0f : 0.0f;
- CalculateTargetBounds(visible_, &target_bounds);
- GetLayer(launcher_)->SetOpacity(target_opacity);
- GetLayer(status_)->SetOpacity(target_opacity);
- launcher_->SetBounds(target_bounds.launcher_bounds);
- status_->SetBounds(target_bounds.status_bounds);
- aura::Desktop::GetInstance()->screen()->set_work_area_insets(
- 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.
@@ -67,7 +57,49 @@ 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);
sky 2011/12/02 19:25:53 I think you want if/else, eg: if (!in_layout_)
Nikita (slow) 2011/12/05 14:41:46 Not really. It works like: GetWidget()->SetSize(Ge
+ if (!in_layout_)
+ LayoutShelf();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ShelfLayoutManager, private:
+
+void ShelfLayoutManager::LayoutShelf() {
+ in_layout_ = true;
sky 2011/12/02 19:25:53 use base/auto_reset
Nikita (slow) 2011/12/05 14:41:46 Done.
+ StopAnimating();
+ TargetBounds target_bounds;
+ float target_opacity = visible_ ? 1.0f : 0.0f;
+ CalculateTargetBounds(visible_, &target_bounds);
+ GetLayer(launcher_)->SetOpacity(target_opacity);
+ GetLayer(status_)->SetOpacity(target_opacity);
+ launcher_->SetBounds(target_bounds.launcher_bounds);
+ status_->SetBounds(target_bounds.status_bounds);
+ aura::Desktop::GetInstance()->screen()->set_work_area_insets(
+ target_bounds.work_area_insets);
+ in_layout_ = false;
+}
+
+void ShelfLayoutManager::StopAnimating() {
if (animating_) {
animating_ = false;
visible_ = !visible_;
@@ -75,7 +107,7 @@ void ShelfLayoutController::StopAnimating() {
GetLayer(launcher_)->GetAnimator()->StopAnimating();
}
-void ShelfLayoutController::CalculateTargetBounds(bool visible,
+void ShelfLayoutManager::CalculateTargetBounds(bool visible,
TargetBounds* target_bounds) {
const gfx::Rect& available_bounds(aura::Desktop::GetInstance()->bounds());
int y = available_bounds.bottom() - (visible ? max_height_ : 0);
@@ -93,7 +125,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,
float target_opacity) {
ui::Layer* layer = GetLayer(widget);
@@ -102,7 +134,7 @@ void ShelfLayoutController::AnimateWidgetTo(views::Widget* widget,
layer->SetOpacity(target_opacity);
}
-void ShelfLayoutController::OnLayerAnimationEnded(
+void ShelfLayoutManager::OnLayerAnimationEnded(
const ui::LayerAnimationSequence* sequence) {
if (!animating_)
return;

Powered by Google App Engine
This is Rietveld 408576698