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

Side by Side Diff: ash/shelf/shelf_widget.cc

Issue 24011002: Repositioning of the dimmer overlay when the shelf gets only moved and not resized. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "ash/shelf/shelf_widget.h" 5 #include "ash/shelf/shelf_widget.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/focus_cycler.h" 8 #include "ash/focus_cycler.h"
9 #include "ash/launcher/launcher_delegate.h" 9 #include "ash/launcher/launcher_delegate.h"
10 #include "ash/launcher/launcher_model.h" 10 #include "ash/launcher/launcher_model.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 231 }
232 232
233 } // namespace 233 } // namespace
234 234
235 namespace ash { 235 namespace ash {
236 236
237 // The contents view of the Shelf. This view contains LauncherView and 237 // The contents view of the Shelf. This view contains LauncherView and
238 // sizes it to the width of the shelf minus the size of the status area. 238 // sizes it to the width of the shelf minus the size of the status area.
239 class ShelfWidget::DelegateView : public views::WidgetDelegate, 239 class ShelfWidget::DelegateView : public views::WidgetDelegate,
240 public views::AccessiblePaneView, 240 public views::AccessiblePaneView,
241 public internal::BackgroundAnimatorDelegate { 241 public internal::BackgroundAnimatorDelegate,
242 public aura::WindowObserver {
242 public: 243 public:
243 explicit DelegateView(ShelfWidget* shelf); 244 explicit DelegateView(ShelfWidget* shelf);
244 virtual ~DelegateView(); 245 virtual ~DelegateView();
245 246
246 void set_focus_cycler(internal::FocusCycler* focus_cycler) { 247 void set_focus_cycler(internal::FocusCycler* focus_cycler) {
247 focus_cycler_ = focus_cycler; 248 focus_cycler_ = focus_cycler;
248 } 249 }
249 internal::FocusCycler* focus_cycler() { 250 internal::FocusCycler* focus_cycler() {
250 return focus_cycler_; 251 return focus_cycler_;
251 } 252 }
(...skipping 13 matching lines...) Expand all
265 virtual views::Widget* GetWidget() OVERRIDE { 266 virtual views::Widget* GetWidget() OVERRIDE {
266 return View::GetWidget(); 267 return View::GetWidget();
267 } 268 }
268 virtual const views::Widget* GetWidget() const OVERRIDE { 269 virtual const views::Widget* GetWidget() const OVERRIDE {
269 return View::GetWidget(); 270 return View::GetWidget();
270 } 271 }
271 272
272 virtual bool CanActivate() const OVERRIDE; 273 virtual bool CanActivate() const OVERRIDE;
273 virtual void Layout() OVERRIDE; 274 virtual void Layout() OVERRIDE;
274 virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; 275 virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE;
276 // This will be called when the parent local bounds change.
275 virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE; 277 virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE;
276 278
279 // aura::WindowObserver overrides.
James Cook 2013/09/05 23:41:00 tiny nit: "overrides:" instead of "overrides."
Mr4D (OOO till 08-26) 2013/09/05 23:47:26 Done
280 // This will be called when the shelf itself changes its absolute position.
281 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs
282 // to be repositioned. The difference to the OnBoundsChanged call above is
283 // that this gets also triggered when the shelf only moves.
284 virtual void OnWindowBoundsChanged(aura::Window* window,
285 const gfx::Rect& old_bounds,
286 const gfx::Rect& new_bounds) OVERRIDE;
287
277 // BackgroundAnimatorDelegate overrides: 288 // BackgroundAnimatorDelegate overrides:
278 virtual void UpdateBackground(int alpha) OVERRIDE; 289 virtual void UpdateBackground(int alpha) OVERRIDE;
279 290
280 // Force the shelf to be presented in an undimmed state. 291 // Force the shelf to be presented in an undimmed state.
281 void ForceUndimming(bool force); 292 void ForceUndimming(bool force);
282 293
283 // A function to test the current alpha used by the dimming bar. If there is 294 // A function to test the current alpha used by the dimming bar. If there is
284 // no dimmer active, the function will return -1. 295 // no dimmer active, the function will return -1.
285 int GetDimmingAlphaForTest(); 296 int GetDimmingAlphaForTest();
286 297
(...skipping 30 matching lines...) Expand all
317 opaque_background_(ui::LAYER_SOLID_COLOR), 328 opaque_background_(ui::LAYER_SOLID_COLOR),
318 dimmer_view_(NULL), 329 dimmer_view_(NULL),
319 disable_dimming_animations_for_test_(false) { 330 disable_dimming_animations_for_test_(false) {
320 set_allow_deactivate_on_esc(true); 331 set_allow_deactivate_on_esc(true);
321 opaque_background_.SetColor(SK_ColorBLACK); 332 opaque_background_.SetColor(SK_ColorBLACK);
322 opaque_background_.SetBounds(GetLocalBounds()); 333 opaque_background_.SetBounds(GetLocalBounds());
323 opaque_background_.SetOpacity(0.0f); 334 opaque_background_.SetOpacity(0.0f);
324 } 335 }
325 336
326 ShelfWidget::DelegateView::~DelegateView() { 337 ShelfWidget::DelegateView::~DelegateView() {
338 // Make sure that the dimmer goes away since it might have set an observer.
339 SetDimmed(false);
327 } 340 }
328 341
329 void ShelfWidget::DelegateView::SetDimmed(bool value) { 342 void ShelfWidget::DelegateView::SetDimmed(bool value) {
330 if (value == (dimmer_.get() != NULL)) 343 if (value == (dimmer_.get() != NULL))
331 return; 344 return;
332 345
333 if (value) { 346 if (value) {
334 dimmer_.reset(new views::Widget); 347 dimmer_.reset(new views::Widget);
335 views::Widget::InitParams params( 348 views::Widget::InitParams params(
336 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 349 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
337 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 350 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
338 params.can_activate = false; 351 params.can_activate = false;
339 params.accept_events = false; 352 params.accept_events = false;
340 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 353 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
341 params.parent = shelf_->GetNativeView(); 354 params.parent = shelf_->GetNativeView();
342 dimmer_->Init(params); 355 dimmer_->Init(params);
343 dimmer_->GetNativeWindow()->SetName("ShelfDimmer"); 356 dimmer_->GetNativeWindow()->SetName("ShelfDimmer");
344 dimmer_->SetBounds(shelf_->GetWindowBoundsInScreen()); 357 dimmer_->SetBounds(shelf_->GetWindowBoundsInScreen());
345 // The launcher should not take focus when it is initially shown. 358 // The launcher should not take focus when it is initially shown.
346 dimmer_->set_focus_on_creation(false); 359 dimmer_->set_focus_on_creation(false);
347 dimmer_view_ = new DimmerView(shelf_, disable_dimming_animations_for_test_); 360 dimmer_view_ = new DimmerView(shelf_, disable_dimming_animations_for_test_);
348 dimmer_->SetContentsView(dimmer_view_); 361 dimmer_->SetContentsView(dimmer_view_);
349 dimmer_->GetNativeView()->SetName("ShelfDimmerView"); 362 dimmer_->GetNativeView()->SetName("ShelfDimmerView");
350 dimmer_->Show(); 363 dimmer_->Show();
364 shelf_->GetNativeView()->AddObserver(this);
351 } else { 365 } else {
366 shelf_->GetNativeView()->RemoveObserver(this);
352 dimmer_view_ = NULL; 367 dimmer_view_ = NULL;
353 dimmer_.reset(NULL); 368 dimmer_.reset(NULL);
354 } 369 }
355 } 370 }
356 371
357 bool ShelfWidget::DelegateView::GetDimmed() const { 372 bool ShelfWidget::DelegateView::GetDimmed() const {
358 return dimmer_.get() && dimmer_->IsVisible(); 373 return dimmer_.get() && dimmer_->IsVisible();
359 } 374 }
360 375
361 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { 376 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 views::View::ReorderChildLayers(parent_layer); 436 views::View::ReorderChildLayers(parent_layer);
422 parent_layer->StackAtBottom(&opaque_background_); 437 parent_layer->StackAtBottom(&opaque_background_);
423 } 438 }
424 439
425 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { 440 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) {
426 opaque_background_.SetBounds(GetLocalBounds()); 441 opaque_background_.SetBounds(GetLocalBounds());
427 if (dimmer_) 442 if (dimmer_)
428 dimmer_->SetBounds(GetBoundsInScreen()); 443 dimmer_->SetBounds(GetBoundsInScreen());
429 } 444 }
430 445
446 void ShelfWidget::DelegateView::OnWindowBoundsChanged(
447 aura::Window* window,
448 const gfx::Rect& old_bounds,
449 const gfx::Rect& new_bounds) {
450 // coming here the shelf got repositioned and since the |dimmer_| is placed
James Cook 2013/09/05 23:41:00 nit: coming -> Coming
Mr4D (OOO till 08-26) 2013/09/05 23:47:26 Done.
451 // in screen coordinates and not relative to the parent it needs to be
452 // repositioned accordingly.
453 dimmer_->SetBounds(GetBoundsInScreen());
454 }
455
431 void ShelfWidget::DelegateView::ForceUndimming(bool force) { 456 void ShelfWidget::DelegateView::ForceUndimming(bool force) {
432 if (GetDimmed()) 457 if (GetDimmed())
433 dimmer_view_->ForceUndimming(force); 458 dimmer_view_->ForceUndimming(force);
434 } 459 }
435 460
436 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() { 461 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() {
437 if (GetDimmed()) 462 if (GetDimmed())
438 return dimmer_view_->get_dimming_alpha_for_test(); 463 return dimmer_view_->get_dimming_alpha_for_test();
439 return -1; 464 return -1;
440 } 465 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 return delegate_view_->GetDimmerBoundsForTest(); 672 return delegate_view_->GetDimmerBoundsForTest();
648 return gfx::Rect(); 673 return gfx::Rect();
649 } 674 }
650 675
651 void ShelfWidget::DisableDimmingAnimationsForTest() { 676 void ShelfWidget::DisableDimmingAnimationsForTest() {
652 DCHECK(delegate_view_); 677 DCHECK(delegate_view_);
653 return delegate_view_->disable_dimming_animations_for_test(); 678 return delegate_view_->disable_dimming_animations_for_test();
654 } 679 }
655 680
656 } // namespace ash 681 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698