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

Side by Side Diff: ui/aura_shell/shelf_layout_manager.cc

Issue 8873036: Create a visible shelf and constrain window movement (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #include "ui/aura_shell/shelf_layout_manager.h" 5 #include "ui/aura_shell/shelf_layout_manager.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/aura/screen_aura.h" 9 #include "ui/aura/screen_aura.h"
10 #include "ui/gfx/compositor/layer.h" 10 #include "ui/gfx/compositor/layer.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 TargetBounds target_bounds; 69 TargetBounds target_bounds;
70 float target_opacity = visible ? 1.0f : 0.0f; 70 float target_opacity = visible ? 1.0f : 0.0f;
71 CalculateTargetBounds(visible, &target_bounds); 71 CalculateTargetBounds(visible, &target_bounds);
72 AnimateWidgetTo(launcher_, target_bounds.launcher_bounds, target_opacity); 72 AnimateWidgetTo(launcher_, target_bounds.launcher_bounds, target_opacity);
73 AnimateWidgetTo(status_, target_bounds.status_bounds, target_opacity); 73 AnimateWidgetTo(status_, target_bounds.status_bounds, target_opacity);
74 animating_ = true; 74 animating_ = true;
75 // |visible_| is updated once the animation completes. 75 // |visible_| is updated once the animation completes.
76 } 76 }
77 77
78 gfx::Rect ShelfLayoutManager::GetLauncherBounds() const {
79 return launcher_->GetWindowScreenBounds();
80 }
81
78 //////////////////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////////////
79 // ShelfLayoutManager, aura::LayoutManager implementation: 83 // ShelfLayoutManager, aura::LayoutManager implementation:
80 84
81 void ShelfLayoutManager::OnWindowResized() { 85 void ShelfLayoutManager::OnWindowResized() {
82 LayoutShelf(); 86 LayoutShelf();
83 } 87 }
84 88
85 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 89 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
86 } 90 }
87 91
(...skipping 20 matching lines...) Expand all
108 visible_ = !visible_; 112 visible_ = !visible_;
109 } 113 }
110 GetLayer(launcher_)->GetAnimator()->StopAnimating(); 114 GetLayer(launcher_)->GetAnimator()->StopAnimating();
111 } 115 }
112 116
113 void ShelfLayoutManager::CalculateTargetBounds(bool visible, 117 void ShelfLayoutManager::CalculateTargetBounds(bool visible,
114 TargetBounds* target_bounds) { 118 TargetBounds* target_bounds) {
115 const gfx::Rect& available_bounds(aura::RootWindow::GetInstance()->bounds()); 119 const gfx::Rect& available_bounds(aura::RootWindow::GetInstance()->bounds());
116 int y = available_bounds.bottom() - (visible ? max_height_ : 0); 120 int y = available_bounds.bottom() - (visible ? max_height_ : 0);
117 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); 121 gfx::Rect status_bounds(status_->GetWindowScreenBounds());
122 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds());
sky 2011/12/14 06:23:05 What was wrong with the old code here? This change
DaveMoore 2011/12/14 17:03:19 It was left over from when I had a background in t
123 int shelf_h = launcher_bounds.height();
124 int shelf_y = y + (max_height_ - shelf_h) / 2;
118 target_bounds->status_bounds = gfx::Rect( 125 target_bounds->status_bounds = gfx::Rect(
119 available_bounds.right() - status_bounds.width(), 126 available_bounds.right() - status_bounds.width(),
120 y + (max_height_ - status_bounds.height()) / 2, 127 shelf_y,
121 status_bounds.width(), status_bounds.height()); 128 status_bounds.width(), shelf_h);
122 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds());
123 target_bounds->launcher_bounds = gfx::Rect( 129 target_bounds->launcher_bounds = gfx::Rect(
124 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, 130 available_bounds.x(), shelf_y,
125 available_bounds.width() - status_bounds.width(), 131 available_bounds.width(),
126 launcher_bounds.height()); 132 shelf_h);
127 if (visible) 133 if (visible)
128 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); 134 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0);
129 } 135 }
130 136
131 void ShelfLayoutManager::AnimateWidgetTo(views::Widget* widget, 137 void ShelfLayoutManager::AnimateWidgetTo(views::Widget* widget,
132 const gfx::Rect& target_bounds, 138 const gfx::Rect& target_bounds,
133 float target_opacity) { 139 float target_opacity) {
134 ui::Layer* layer = GetLayer(widget); 140 ui::Layer* layer = GetLayer(widget);
135 ui::LayerAnimator::ScopedSettings animation_setter(layer->GetAnimator()); 141 ui::LayerAnimator::ScopedSettings animation_setter(layer->GetAnimator());
136 widget->SetBounds(target_bounds); 142 widget->SetBounds(target_bounds);
137 layer->SetOpacity(target_opacity); 143 layer->SetOpacity(target_opacity);
138 } 144 }
139 145
140 void ShelfLayoutManager::OnLayerAnimationEnded( 146 void ShelfLayoutManager::OnLayerAnimationEnded(
141 const ui::LayerAnimationSequence* sequence) { 147 const ui::LayerAnimationSequence* sequence) {
142 if (!animating_) 148 if (!animating_)
143 return; 149 return;
144 animating_ = false; 150 animating_ = false;
145 visible_ = !visible_; 151 visible_ = !visible_;
146 TargetBounds target_bounds; 152 TargetBounds target_bounds;
147 CalculateTargetBounds(visible_, &target_bounds); 153 CalculateTargetBounds(visible_, &target_bounds);
148 aura::RootWindow::GetInstance()->screen()->set_work_area_insets( 154 aura::RootWindow::GetInstance()->screen()->set_work_area_insets(
149 target_bounds.work_area_insets); 155 target_bounds.work_area_insets);
150 } 156 }
151 157
152 } // internal 158 } // internal
153 } // aura_shell 159 } // aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698