| 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/system/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 background_(NULL), | 326 background_(NULL), |
| 327 hide_background_animator_(this, 0, kTrayBackgroundAlpha), | 327 hide_background_animator_(this, 0, kTrayBackgroundAlpha), |
| 328 hover_background_animator_( | 328 hover_background_animator_( |
| 329 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), | 329 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), |
| 330 hovered_(false), | 330 hovered_(false), |
| 331 draw_background_as_active_(false), | 331 draw_background_as_active_(false), |
| 332 widget_observer_(new TrayWidgetObserver(this)) { | 332 widget_observer_(new TrayWidgetObserver(this)) { |
| 333 set_notify_enter_exit_on_child(true); | 333 set_notify_enter_exit_on_child(true); |
| 334 | 334 |
| 335 // Initially we want to paint the background, but without the hover effect. | 335 // Initially we want to paint the background, but without the hover effect. |
| 336 hide_background_animator_.SetPaintsBackground(true, | 336 hide_background_animator_.SetPaintsBackground( |
| 337 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 337 true, BACKGROUND_CHANGE_IMMEDIATE); |
| 338 hover_background_animator_.SetPaintsBackground(false, | 338 hover_background_animator_.SetPaintsBackground( |
| 339 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 339 false, BACKGROUND_CHANGE_IMMEDIATE); |
| 340 | 340 |
| 341 tray_container_ = new TrayContainer(shelf_alignment_); | 341 tray_container_ = new TrayContainer(shelf_alignment_); |
| 342 SetContents(tray_container_); | 342 SetContents(tray_container_); |
| 343 tray_event_filter_.reset(new TrayEventFilter); | 343 tray_event_filter_.reset(new TrayEventFilter); |
| 344 } | 344 } |
| 345 | 345 |
| 346 TrayBackgroundView::~TrayBackgroundView() { | 346 TrayBackgroundView::~TrayBackgroundView() { |
| 347 if (GetWidget()) | 347 if (GetWidget()) |
| 348 GetWidget()->RemoveObserver(widget_observer_.get()); | 348 GetWidget()->RemoveObserver(widget_observer_.get()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void TrayBackgroundView::Initialize() { | 351 void TrayBackgroundView::Initialize() { |
| 352 GetWidget()->AddObserver(widget_observer_.get()); | 352 GetWidget()->AddObserver(widget_observer_.get()); |
| 353 SetBorder(); | 353 SetBorder(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 const char* TrayBackgroundView::GetClassName() const { | 356 const char* TrayBackgroundView::GetClassName() const { |
| 357 return kViewClassName; | 357 return kViewClassName; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { | 360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { |
| 361 hovered_ = true; | 361 hovered_ = true; |
| 362 if (!background_ || draw_background_as_active_ || | 362 if (!background_ || draw_background_as_active_ || |
| 363 ash::switches::UseAlternateShelfLayout()) | 363 ash::switches::UseAlternateShelfLayout()) |
| 364 return; | 364 return; |
| 365 hover_background_animator_.SetPaintsBackground(true, | 365 hover_background_animator_.SetPaintsBackground( |
| 366 internal::BackgroundAnimator::CHANGE_ANIMATE); | 366 true, BACKGROUND_CHANGE_ANIMATE); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { | 369 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { |
| 370 hovered_ = false; | 370 hovered_ = false; |
| 371 if (!background_ || draw_background_as_active_ || | 371 if (!background_ || draw_background_as_active_ || |
| 372 ash::switches::UseAlternateShelfLayout()) | 372 ash::switches::UseAlternateShelfLayout()) |
| 373 return; | 373 return; |
| 374 hover_background_animator_.SetPaintsBackground(false, | 374 hover_background_animator_.SetPaintsBackground( |
| 375 internal::BackgroundAnimator::CHANGE_ANIMATE); | 375 false, BACKGROUND_CHANGE_ANIMATE); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 378 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
| 379 PreferredSizeChanged(); | 379 PreferredSizeChanged(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { | 382 void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 383 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 383 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 384 state->name = GetAccessibleNameForTray(); | 384 state->name = GetAccessibleNameForTray(); |
| 385 } | 385 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 411 hover_background_animator_.alpha()); | 411 hover_background_animator_.alpha()); |
| 412 SchedulePaint(); | 412 SchedulePaint(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void TrayBackgroundView::SetContents(views::View* contents) { | 415 void TrayBackgroundView::SetContents(views::View* contents) { |
| 416 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 416 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 417 AddChildView(contents); | 417 AddChildView(contents); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void TrayBackgroundView::SetPaintsBackground( | 420 void TrayBackgroundView::SetPaintsBackground( |
| 421 bool value, | 421 bool value, BackgroundAnimatorChangeType change_type) { |
| 422 internal::BackgroundAnimator::ChangeType change_type) { | |
| 423 DCHECK(!ash::switches::UseAlternateShelfLayout()); | 422 DCHECK(!ash::switches::UseAlternateShelfLayout()); |
| 424 hide_background_animator_.SetPaintsBackground(value, change_type); | 423 hide_background_animator_.SetPaintsBackground(value, change_type); |
| 425 } | 424 } |
| 426 | 425 |
| 427 void TrayBackgroundView::SetContentsBackground() { | 426 void TrayBackgroundView::SetContentsBackground() { |
| 428 background_ = new internal::TrayBackground(this); | 427 background_ = new internal::TrayBackground(this); |
| 429 tray_container_->set_background(background_); | 428 tray_container_->set_background(background_); |
| 430 } | 429 } |
| 431 | 430 |
| 432 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 431 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 ash::internal::ShelfLayoutManager* shelf = | 625 ash::internal::ShelfLayoutManager* shelf = |
| 627 ShelfLayoutManager::ForLauncher(root_window); | 626 ShelfLayoutManager::ForLauncher(root_window); |
| 628 bubble_view->SetArrowPaintType( | 627 bubble_view->SetArrowPaintType( |
| 629 (shelf && shelf->IsVisible()) ? | 628 (shelf && shelf->IsVisible()) ? |
| 630 views::BubbleBorder::PAINT_NORMAL : | 629 views::BubbleBorder::PAINT_NORMAL : |
| 631 views::BubbleBorder::PAINT_TRANSPARENT); | 630 views::BubbleBorder::PAINT_TRANSPARENT); |
| 632 } | 631 } |
| 633 | 632 |
| 634 } // namespace internal | 633 } // namespace internal |
| 635 } // namespace ash | 634 } // namespace ash |
| OLD | NEW |