| OLD | NEW |
| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 internal::FocusCycler* focus_cycler() { | 249 internal::FocusCycler* focus_cycler() { |
| 250 return focus_cycler_; | 250 return focus_cycler_; |
| 251 } | 251 } |
| 252 | 252 |
| 253 ui::Layer* opaque_background() { return &opaque_background_; } | 253 ui::Layer* opaque_background() { return &opaque_background_; } |
| 254 | 254 |
| 255 // Set if the shelf area is dimmed (eg when a window is maximized). | 255 // Set if the shelf area is dimmed (eg when a window is maximized). |
| 256 void SetDimmed(bool dimmed); | 256 void SetDimmed(bool dimmed); |
| 257 bool GetDimmed() const; | 257 bool GetDimmed() const; |
| 258 | 258 |
| 259 // Set the bounds of the widget. | |
| 260 void SetWidgetBounds(const gfx::Rect bounds); | |
| 261 | |
| 262 void SetParentLayer(ui::Layer* layer); | 259 void SetParentLayer(ui::Layer* layer); |
| 263 | 260 |
| 264 // views::View overrides: | 261 // views::View overrides: |
| 265 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 262 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; |
| 266 | 263 |
| 267 // views::WidgetDelegateView overrides: | 264 // views::WidgetDelegateView overrides: |
| 268 virtual views::Widget* GetWidget() OVERRIDE { | 265 virtual views::Widget* GetWidget() OVERRIDE { |
| 269 return View::GetWidget(); | 266 return View::GetWidget(); |
| 270 } | 267 } |
| 271 virtual const views::Widget* GetWidget() const OVERRIDE { | 268 virtual const views::Widget* GetWidget() const OVERRIDE { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } else { | 351 } else { |
| 355 dimmer_view_ = NULL; | 352 dimmer_view_ = NULL; |
| 356 dimmer_.reset(NULL); | 353 dimmer_.reset(NULL); |
| 357 } | 354 } |
| 358 } | 355 } |
| 359 | 356 |
| 360 bool ShelfWidget::DelegateView::GetDimmed() const { | 357 bool ShelfWidget::DelegateView::GetDimmed() const { |
| 361 return dimmer_.get() && dimmer_->IsVisible(); | 358 return dimmer_.get() && dimmer_->IsVisible(); |
| 362 } | 359 } |
| 363 | 360 |
| 364 void ShelfWidget::DelegateView::SetWidgetBounds(const gfx::Rect bounds) { | |
| 365 if (dimmer_) | |
| 366 dimmer_->SetBounds(bounds); | |
| 367 } | |
| 368 | |
| 369 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { | 361 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { |
| 370 layer->Add(&opaque_background_); | 362 layer->Add(&opaque_background_); |
| 371 ReorderLayers(); | 363 ReorderLayers(); |
| 372 } | 364 } |
| 373 | 365 |
| 374 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { | 366 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { |
| 375 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 367 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 376 gfx::ImageSkia launcher_background = | 368 gfx::ImageSkia launcher_background = |
| 377 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); | 369 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); |
| 378 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) | 370 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 417 } |
| 426 } | 418 } |
| 427 | 419 |
| 428 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { | 420 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { |
| 429 views::View::ReorderChildLayers(parent_layer); | 421 views::View::ReorderChildLayers(parent_layer); |
| 430 parent_layer->StackAtBottom(&opaque_background_); | 422 parent_layer->StackAtBottom(&opaque_background_); |
| 431 } | 423 } |
| 432 | 424 |
| 433 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 425 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
| 434 opaque_background_.SetBounds(GetLocalBounds()); | 426 opaque_background_.SetBounds(GetLocalBounds()); |
| 427 if (dimmer_) |
| 428 dimmer_->SetBounds(GetBoundsInScreen()); |
| 435 } | 429 } |
| 436 | 430 |
| 437 void ShelfWidget::DelegateView::ForceUndimming(bool force) { | 431 void ShelfWidget::DelegateView::ForceUndimming(bool force) { |
| 438 if (GetDimmed()) | 432 if (GetDimmed()) |
| 439 dimmer_view_->ForceUndimming(force); | 433 dimmer_view_->ForceUndimming(force); |
| 440 } | 434 } |
| 441 | 435 |
| 442 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() { | 436 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() { |
| 443 if (GetDimmed()) | 437 if (GetDimmed()) |
| 444 return dimmer_view_->get_dimming_alpha_for_test(); | 438 return dimmer_view_->get_dimming_alpha_for_test(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 internal::FocusCycler* ShelfWidget::GetFocusCycler() { | 616 internal::FocusCycler* ShelfWidget::GetFocusCycler() { |
| 623 return delegate_view_->focus_cycler(); | 617 return delegate_view_->focus_cycler(); |
| 624 } | 618 } |
| 625 | 619 |
| 626 void ShelfWidget::ShutdownStatusAreaWidget() { | 620 void ShelfWidget::ShutdownStatusAreaWidget() { |
| 627 if (status_area_widget_) | 621 if (status_area_widget_) |
| 628 status_area_widget_->Shutdown(); | 622 status_area_widget_->Shutdown(); |
| 629 status_area_widget_ = NULL; | 623 status_area_widget_ = NULL; |
| 630 } | 624 } |
| 631 | 625 |
| 632 void ShelfWidget::SetWidgetBounds(const gfx::Rect& rect) { | |
| 633 Widget::SetBounds(rect); | |
| 634 delegate_view_->SetWidgetBounds(rect); | |
| 635 } | |
| 636 | |
| 637 void ShelfWidget::ForceUndimming(bool force) { | 626 void ShelfWidget::ForceUndimming(bool force) { |
| 638 delegate_view_->ForceUndimming(force); | 627 delegate_view_->ForceUndimming(force); |
| 639 } | 628 } |
| 640 | 629 |
| 641 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, | 630 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, |
| 642 bool active) { | 631 bool active) { |
| 643 activating_as_fallback_ = false; | 632 activating_as_fallback_ = false; |
| 644 if (active) | 633 if (active) |
| 645 delegate_view_->SetPaneFocusAndFocusDefault(); | 634 delegate_view_->SetPaneFocusAndFocusDefault(); |
| 646 else | 635 else |
| (...skipping 11 matching lines...) Expand all Loading... |
| 658 return delegate_view_->GetDimmerBoundsForTest(); | 647 return delegate_view_->GetDimmerBoundsForTest(); |
| 659 return gfx::Rect(); | 648 return gfx::Rect(); |
| 660 } | 649 } |
| 661 | 650 |
| 662 void ShelfWidget::DisableDimmingAnimationsForTest() { | 651 void ShelfWidget::DisableDimmingAnimationsForTest() { |
| 663 DCHECK(delegate_view_); | 652 DCHECK(delegate_view_); |
| 664 return delegate_view_->disable_dimming_animations_for_test(); | 653 return delegate_view_->disable_dimming_animations_for_test(); |
| 665 } | 654 } |
| 666 | 655 |
| 667 } // namespace ash | 656 } // namespace ash |
| OLD | NEW |