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(true, CHANGE_IMMEDIATE); |
337 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 337 hover_background_animator_.SetPaintsBackground(false, CHANGE_IMMEDIATE); |
338 hover_background_animator_.SetPaintsBackground(false, | |
339 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | |
340 | 338 |
341 tray_container_ = new TrayContainer(shelf_alignment_); | 339 tray_container_ = new TrayContainer(shelf_alignment_); |
342 SetContents(tray_container_); | 340 SetContents(tray_container_); |
343 tray_event_filter_.reset(new TrayEventFilter); | 341 tray_event_filter_.reset(new TrayEventFilter); |
344 } | 342 } |
345 | 343 |
346 TrayBackgroundView::~TrayBackgroundView() { | 344 TrayBackgroundView::~TrayBackgroundView() { |
347 if (GetWidget()) | 345 if (GetWidget()) |
348 GetWidget()->RemoveObserver(widget_observer_.get()); | 346 GetWidget()->RemoveObserver(widget_observer_.get()); |
349 } | 347 } |
350 | 348 |
351 void TrayBackgroundView::Initialize() { | 349 void TrayBackgroundView::Initialize() { |
352 GetWidget()->AddObserver(widget_observer_.get()); | 350 GetWidget()->AddObserver(widget_observer_.get()); |
353 SetBorder(); | 351 SetBorder(); |
354 } | 352 } |
355 | 353 |
356 const char* TrayBackgroundView::GetClassName() const { | 354 const char* TrayBackgroundView::GetClassName() const { |
357 return kViewClassName; | 355 return kViewClassName; |
358 } | 356 } |
359 | 357 |
360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { | 358 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { |
361 hovered_ = true; | 359 hovered_ = true; |
362 if (!background_ || draw_background_as_active_ || | 360 if (!background_ || draw_background_as_active_ || |
363 ash::switches::UseAlternateShelfLayout()) | 361 ash::switches::UseAlternateShelfLayout()) |
364 return; | 362 return; |
365 hover_background_animator_.SetPaintsBackground(true, | 363 hover_background_animator_.SetPaintsBackground(true, CHANGE_ANIMATE); |
366 internal::BackgroundAnimator::CHANGE_ANIMATE); | |
367 } | 364 } |
368 | 365 |
369 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { | 366 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { |
370 hovered_ = false; | 367 hovered_ = false; |
371 if (!background_ || draw_background_as_active_ || | 368 if (!background_ || draw_background_as_active_ || |
372 ash::switches::UseAlternateShelfLayout()) | 369 ash::switches::UseAlternateShelfLayout()) |
373 return; | 370 return; |
374 hover_background_animator_.SetPaintsBackground(false, | 371 hover_background_animator_.SetPaintsBackground(false, CHANGE_ANIMATE); |
375 internal::BackgroundAnimator::CHANGE_ANIMATE); | |
376 } | 372 } |
377 | 373 |
378 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 374 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
379 PreferredSizeChanged(); | 375 PreferredSizeChanged(); |
380 } | 376 } |
381 | 377 |
382 void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) { | 378 void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) { |
383 // The tray itself expands to the right and bottom edge of the screen to make | 379 // The tray itself expands to the right and bottom edge of the screen to make |
384 // sure clicking on the edges brings up the popup. However, the focus border | 380 // sure clicking on the edges brings up the popup. However, the focus border |
385 // should be only around the container. | 381 // should be only around the container. |
(...skipping 26 matching lines...) Expand all Loading... |
412 hover_background_animator_.alpha()); | 408 hover_background_animator_.alpha()); |
413 SchedulePaint(); | 409 SchedulePaint(); |
414 } | 410 } |
415 | 411 |
416 void TrayBackgroundView::SetContents(views::View* contents) { | 412 void TrayBackgroundView::SetContents(views::View* contents) { |
417 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 413 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
418 AddChildView(contents); | 414 AddChildView(contents); |
419 } | 415 } |
420 | 416 |
421 void TrayBackgroundView::SetPaintsBackground( | 417 void TrayBackgroundView::SetPaintsBackground( |
422 bool value, | 418 bool value, BackgroundAnimatorChangeType change_type) { |
423 internal::BackgroundAnimator::ChangeType change_type) { | |
424 DCHECK(!ash::switches::UseAlternateShelfLayout()); | 419 DCHECK(!ash::switches::UseAlternateShelfLayout()); |
425 hide_background_animator_.SetPaintsBackground(value, change_type); | 420 hide_background_animator_.SetPaintsBackground(value, change_type); |
426 } | 421 } |
427 | 422 |
428 void TrayBackgroundView::SetContentsBackground() { | 423 void TrayBackgroundView::SetContentsBackground() { |
429 background_ = new internal::TrayBackground(this); | 424 background_ = new internal::TrayBackground(this); |
430 tray_container_->set_background(background_); | 425 tray_container_->set_background(background_); |
431 } | 426 } |
432 | 427 |
433 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 428 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 ash::internal::ShelfLayoutManager* shelf = | 622 ash::internal::ShelfLayoutManager* shelf = |
628 ShelfLayoutManager::ForLauncher(root_window); | 623 ShelfLayoutManager::ForLauncher(root_window); |
629 bubble_view->SetArrowPaintType( | 624 bubble_view->SetArrowPaintType( |
630 (shelf && shelf->IsVisible()) ? | 625 (shelf && shelf->IsVisible()) ? |
631 views::BubbleBorder::PAINT_NORMAL : | 626 views::BubbleBorder::PAINT_NORMAL : |
632 views::BubbleBorder::PAINT_TRANSPARENT); | 627 views::BubbleBorder::PAINT_TRANSPARENT); |
633 } | 628 } |
634 | 629 |
635 } // namespace internal | 630 } // namespace internal |
636 } // namespace ash | 631 } // namespace ash |
OLD | NEW |