| 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/focus_cycler.h" | 7 #include "ash/focus_cycler.h" |
| 8 #include "ash/launcher/launcher_delegate.h" | 8 #include "ash/launcher/launcher_delegate.h" |
| 9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
| 10 #include "ash/launcher/launcher_navigator.h" | 10 #include "ash/launcher/launcher_navigator.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 internal::FocusCycler* focus_cycler() { | 247 internal::FocusCycler* focus_cycler() { |
| 248 return focus_cycler_; | 248 return focus_cycler_; |
| 249 } | 249 } |
| 250 | 250 |
| 251 ui::Layer* opaque_background() { return &opaque_background_; } | 251 ui::Layer* opaque_background() { return &opaque_background_; } |
| 252 | 252 |
| 253 // Set if the shelf area is dimmed (eg when a window is maximized). | 253 // Set if the shelf area is dimmed (eg when a window is maximized). |
| 254 void SetDimmed(bool dimmed); | 254 void SetDimmed(bool dimmed); |
| 255 bool GetDimmed() const; | 255 bool GetDimmed() const; |
| 256 | 256 |
| 257 // Set the bounds of the widget. | |
| 258 void SetWidgetBounds(const gfx::Rect bounds); | |
| 259 | |
| 260 void SetParentLayer(ui::Layer* layer); | 257 void SetParentLayer(ui::Layer* layer); |
| 261 | 258 |
| 262 // views::View overrides: | 259 // views::View overrides: |
| 263 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 260 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; |
| 264 | 261 |
| 265 // views::WidgetDelegateView overrides: | 262 // views::WidgetDelegateView overrides: |
| 266 virtual views::Widget* GetWidget() OVERRIDE { | 263 virtual views::Widget* GetWidget() OVERRIDE { |
| 267 return View::GetWidget(); | 264 return View::GetWidget(); |
| 268 } | 265 } |
| 269 virtual const views::Widget* GetWidget() const OVERRIDE { | 266 virtual const views::Widget* GetWidget() const OVERRIDE { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } else { | 349 } else { |
| 353 dimmer_view_ = NULL; | 350 dimmer_view_ = NULL; |
| 354 dimmer_.reset(NULL); | 351 dimmer_.reset(NULL); |
| 355 } | 352 } |
| 356 } | 353 } |
| 357 | 354 |
| 358 bool ShelfWidget::DelegateView::GetDimmed() const { | 355 bool ShelfWidget::DelegateView::GetDimmed() const { |
| 359 return dimmer_.get() && dimmer_->IsVisible(); | 356 return dimmer_.get() && dimmer_->IsVisible(); |
| 360 } | 357 } |
| 361 | 358 |
| 362 void ShelfWidget::DelegateView::SetWidgetBounds(const gfx::Rect bounds) { | |
| 363 if (dimmer_) | |
| 364 dimmer_->SetBounds(bounds); | |
| 365 } | |
| 366 | |
| 367 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { | 359 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { |
| 368 layer->Add(&opaque_background_); | 360 layer->Add(&opaque_background_); |
| 369 ReorderLayers(); | 361 ReorderLayers(); |
| 370 } | 362 } |
| 371 | 363 |
| 372 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { | 364 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { |
| 373 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 365 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 374 gfx::ImageSkia launcher_background = | 366 gfx::ImageSkia launcher_background = |
| 375 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); | 367 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); |
| 376 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) | 368 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 415 } |
| 424 } | 416 } |
| 425 | 417 |
| 426 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { | 418 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { |
| 427 views::View::ReorderChildLayers(parent_layer); | 419 views::View::ReorderChildLayers(parent_layer); |
| 428 parent_layer->StackAtBottom(&opaque_background_); | 420 parent_layer->StackAtBottom(&opaque_background_); |
| 429 } | 421 } |
| 430 | 422 |
| 431 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 423 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
| 432 opaque_background_.SetBounds(GetLocalBounds()); | 424 opaque_background_.SetBounds(GetLocalBounds()); |
| 425 if (dimmer_) |
| 426 dimmer_->SetBounds(GetBoundsInScreen()); |
| 433 } | 427 } |
| 434 | 428 |
| 435 void ShelfWidget::DelegateView::ForceUndimming(bool force) { | 429 void ShelfWidget::DelegateView::ForceUndimming(bool force) { |
| 436 if (GetDimmed()) | 430 if (GetDimmed()) |
| 437 dimmer_view_->ForceUndimming(force); | 431 dimmer_view_->ForceUndimming(force); |
| 438 } | 432 } |
| 439 | 433 |
| 440 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() { | 434 int ShelfWidget::DelegateView::GetDimmingAlphaForTest() { |
| 441 if (GetDimmed()) | 435 if (GetDimmed()) |
| 442 return dimmer_view_->get_dimming_alpha_for_test(); | 436 return dimmer_view_->get_dimming_alpha_for_test(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 internal::FocusCycler* ShelfWidget::GetFocusCycler() { | 587 internal::FocusCycler* ShelfWidget::GetFocusCycler() { |
| 594 return delegate_view_->focus_cycler(); | 588 return delegate_view_->focus_cycler(); |
| 595 } | 589 } |
| 596 | 590 |
| 597 void ShelfWidget::ShutdownStatusAreaWidget() { | 591 void ShelfWidget::ShutdownStatusAreaWidget() { |
| 598 if (status_area_widget_) | 592 if (status_area_widget_) |
| 599 status_area_widget_->Shutdown(); | 593 status_area_widget_->Shutdown(); |
| 600 status_area_widget_ = NULL; | 594 status_area_widget_ = NULL; |
| 601 } | 595 } |
| 602 | 596 |
| 603 void ShelfWidget::SetWidgetBounds(const gfx::Rect& rect) { | |
| 604 Widget::SetBounds(rect); | |
| 605 delegate_view_->SetWidgetBounds(rect); | |
| 606 } | |
| 607 | |
| 608 void ShelfWidget::ForceUndimming(bool force) { | 597 void ShelfWidget::ForceUndimming(bool force) { |
| 609 delegate_view_->ForceUndimming(force); | 598 delegate_view_->ForceUndimming(force); |
| 610 } | 599 } |
| 611 | 600 |
| 612 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, | 601 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, |
| 613 bool active) { | 602 bool active) { |
| 614 activating_as_fallback_ = false; | 603 activating_as_fallback_ = false; |
| 615 if (active) | 604 if (active) |
| 616 delegate_view_->SetPaneFocusAndFocusDefault(); | 605 delegate_view_->SetPaneFocusAndFocusDefault(); |
| 617 else | 606 else |
| (...skipping 11 matching lines...) Expand all Loading... |
| 629 return delegate_view_->GetDimmerBoundsForTest(); | 618 return delegate_view_->GetDimmerBoundsForTest(); |
| 630 return gfx::Rect(); | 619 return gfx::Rect(); |
| 631 } | 620 } |
| 632 | 621 |
| 633 void ShelfWidget::DisableDimmingAnimationsForTest() { | 622 void ShelfWidget::DisableDimmingAnimationsForTest() { |
| 634 DCHECK(delegate_view_); | 623 DCHECK(delegate_view_); |
| 635 return delegate_view_->disable_dimming_animations_for_test(); | 624 return delegate_view_->disable_dimming_animations_for_test(); |
| 636 } | 625 } |
| 637 | 626 |
| 638 } // namespace ash | 627 } // namespace ash |
| OLD | NEW |