| 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/common/system/tray/tray_background_view.h" | 5 #include "ash/common/system/tray/tray_background_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
| 12 #include "ash/common/shelf/wm_shelf.h" | 12 #include "ash/common/shelf/wm_shelf.h" |
| 13 #include "ash/common/shelf/wm_shelf_util.h" | 13 #include "ash/common/shelf/wm_shelf_util.h" |
| 14 #include "ash/common/system/status_area_widget.h" | |
| 15 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 16 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 17 #include "ash/common/system/tray/tray_event_filter.h" | 16 #include "ash/common/system/tray/tray_event_filter.h" |
| 18 #include "ash/common/wm_lookup.h" | 17 #include "ash/common/wm_lookup.h" |
| 19 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 20 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 21 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
| 22 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
| 23 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
| 24 #include "ui/base/nine_image_painter_factory.h" | 23 #include "ui/base/nine_image_painter_factory.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // TrayBackgroundView | 282 // TrayBackgroundView |
| 284 | 283 |
| 285 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) | 284 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) |
| 286 // Note the ink drop style is ignored. | 285 // Note the ink drop style is ignored. |
| 287 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), | 286 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
| 288 wm_shelf_(wm_shelf), | 287 wm_shelf_(wm_shelf), |
| 289 tray_container_(NULL), | 288 tray_container_(NULL), |
| 290 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 289 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 291 background_(NULL), | 290 background_(NULL), |
| 292 is_active_(false), | 291 is_active_(false), |
| 293 is_separator_visible_(false), | |
| 294 widget_observer_(new TrayWidgetObserver(this)) { | 292 widget_observer_(new TrayWidgetObserver(this)) { |
| 295 DCHECK(wm_shelf_); | 293 DCHECK(wm_shelf_); |
| 296 set_notify_enter_exit_on_child(true); | 294 set_notify_enter_exit_on_child(true); |
| 297 set_ink_drop_base_color(kShelfInkDropBaseColor); | 295 set_ink_drop_base_color(kShelfInkDropBaseColor); |
| 298 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | 296 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); |
| 299 | 297 |
| 300 tray_container_ = new TrayContainer(shelf_alignment_); | 298 tray_container_ = new TrayContainer(shelf_alignment_); |
| 301 SetContents(tray_container_); | 299 SetContents(tray_container_); |
| 302 tray_event_filter_.reset(new TrayEventFilter); | 300 tray_event_filter_.reset(new TrayEventFilter); |
| 303 | 301 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 layer()->SetTransform(transform); | 367 layer()->SetTransform(transform); |
| 370 } else { | 368 } else { |
| 371 // Listen only to the hide animation. As we cannot turn off visibility | 369 // Listen only to the hide animation. As we cannot turn off visibility |
| 372 // until the animation is over. | 370 // until the animation is over. |
| 373 animation.AddObserver(this); | 371 animation.AddObserver(this); |
| 374 animation.SetTweenType(gfx::Tween::EASE_IN); | 372 animation.SetTweenType(gfx::Tween::EASE_IN); |
| 375 layer()->SetOpacity(0.0f); | 373 layer()->SetOpacity(0.0f); |
| 376 layer()->SetVisible(false); | 374 layer()->SetVisible(false); |
| 377 HideTransformation(); | 375 HideTransformation(); |
| 378 } | 376 } |
| 379 wm_shelf_->GetStatusAreaWidget()->OnTrayVisibilityChanged(this); | |
| 380 } | 377 } |
| 381 | 378 |
| 382 const char* TrayBackgroundView::GetClassName() const { | 379 const char* TrayBackgroundView::GetClassName() const { |
| 383 return kViewClassName; | 380 return kViewClassName; |
| 384 } | 381 } |
| 385 | 382 |
| 386 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 383 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
| 387 PreferredSizeChanged(); | 384 PreferredSizeChanged(); |
| 388 } | 385 } |
| 389 | 386 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // Nothing to do here. | 511 // Nothing to do here. |
| 515 } | 512 } |
| 516 | 513 |
| 517 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { | 514 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { |
| 518 if (background_) { | 515 if (background_) { |
| 519 background_->set_alpha(alpha); | 516 background_->set_alpha(alpha); |
| 520 SchedulePaint(); | 517 SchedulePaint(); |
| 521 } | 518 } |
| 522 } | 519 } |
| 523 | 520 |
| 524 void TrayBackgroundView::SetSeparatorVisibility(bool is_shown) { | |
| 525 is_separator_visible_ = is_shown; | |
| 526 SchedulePaint(); | |
| 527 } | |
| 528 | |
| 529 views::View* TrayBackgroundView::GetBubbleAnchor() const { | 521 views::View* TrayBackgroundView::GetBubbleAnchor() const { |
| 530 return tray_container_; | 522 return tray_container_; |
| 531 } | 523 } |
| 532 | 524 |
| 533 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { | 525 gfx::Insets TrayBackgroundView::GetBubbleAnchorInsets() const { |
| 534 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); | 526 gfx::Insets anchor_insets = GetBubbleAnchor()->GetInsets(); |
| 535 gfx::Insets tray_bg_insets = GetInsets(); | 527 gfx::Insets tray_bg_insets = GetInsets(); |
| 536 // TODO(estade): for reasons I don't understand, BubbleBorder distances the | 528 // TODO(estade): for reasons I don't understand, BubbleBorder distances the |
| 537 // bubble by the arrow's "interior" thickness even when the paint type is | 529 // bubble by the arrow's "interior" thickness even when the paint type is |
| 538 // PAINT_NONE. | 530 // PAINT_NONE. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { | 577 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { |
| 586 gfx::Rect paint_bounds(GetFocusBounds()); | 578 gfx::Rect paint_bounds(GetFocusBounds()); |
| 587 paint_bounds.Inset(2, -2, 3, -2); | 579 paint_bounds.Inset(2, -2, 3, -2); |
| 588 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor); | 580 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor); |
| 589 } | 581 } |
| 590 | 582 |
| 591 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 583 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 592 ActionableView::OnPaint(canvas); | 584 ActionableView::OnPaint(canvas); |
| 593 if (!MaterialDesignController::IsShelfMaterial() || | 585 if (!MaterialDesignController::IsShelfMaterial() || |
| 594 shelf()->GetBackgroundType() == | 586 shelf()->GetBackgroundType() == |
| 595 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 587 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { |
| 596 !is_separator_visible_) { | |
| 597 return; | 588 return; |
| 598 } | 589 } |
| 599 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 590 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
| 600 // right or left of the TrayBackgroundView when the system is LTR or RTL | 591 // right or left of the TrayBackgroundView when the system is LTR or RTL |
| 601 // aligned, respectively. For a vertical shelf draw the separator line | 592 // aligned, respectively. For a vertical shelf draw the separator line |
| 602 // underneath the items instead. | 593 // underneath the items instead. |
| 603 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | 594 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); |
| 604 const gfx::Rect local_bounds = GetLocalBounds(); | 595 const gfx::Rect local_bounds = GetLocalBounds(); |
| 605 const int height = kTrayItemSize; | 596 const int height = kTrayItemSize; |
| 606 const int x = | 597 const int x = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 634 } |
| 644 | 635 |
| 645 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 636 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 646 gfx::Insets insets = GetBackgroundInsets(); | 637 gfx::Insets insets = GetBackgroundInsets(); |
| 647 gfx::Rect bounds = GetLocalBounds(); | 638 gfx::Rect bounds = GetLocalBounds(); |
| 648 bounds.Inset(insets); | 639 bounds.Inset(insets); |
| 649 return bounds; | 640 return bounds; |
| 650 } | 641 } |
| 651 | 642 |
| 652 } // namespace ash | 643 } // namespace ash |
| OLD | NEW |