| 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" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { | 395 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { |
| 396 // Return focus to the login view. See crbug.com/120500. | 396 // Return focus to the login view. See crbug.com/120500. |
| 397 views::View* v = GetNextFocusableView(); | 397 views::View* v = GetNextFocusableView(); |
| 398 if (v) | 398 if (v) |
| 399 v->AboutToRequestFocusFromTabTraversal(reverse); | 399 v->AboutToRequestFocusFromTabTraversal(reverse); |
| 400 } | 400 } |
| 401 | 401 |
| 402 std::unique_ptr<views::InkDropRipple> TrayBackgroundView::CreateInkDropRipple() | 402 std::unique_ptr<views::InkDropRipple> TrayBackgroundView::CreateInkDropRipple() |
| 403 const { | 403 const { |
| 404 return base::MakeUnique<views::FloodFillInkDropRipple>( | 404 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 405 GetInkDropBounds(), GetInkDropCenterBasedOnLastEvent(), | 405 size(), GetBackgroundInsets(), GetInkDropCenterBasedOnLastEvent(), |
| 406 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 406 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 407 } | 407 } |
| 408 | 408 |
| 409 std::unique_ptr<views::InkDropHighlight> | 409 std::unique_ptr<views::InkDropHighlight> |
| 410 TrayBackgroundView::CreateInkDropHighlight() const { | 410 TrayBackgroundView::CreateInkDropHighlight() const { |
| 411 gfx::Rect bounds = GetInkDropBounds(); | 411 gfx::Rect bounds = GetBackgroundBounds(); |
| 412 // Currently, we don't handle view resize. To compensate for that, enlarge the |
| 413 // bounds by two tray icons so that the hightlight looks good even if two more |
| 414 // icons are added when it is visible. Note that ink drop mask handles resize |
| 415 // correctly, so the extra highlight would be clipped. |
| 416 // TODO(mohsen): Remove this extra size when resize is handled properly (see |
| 417 // https://crbug.com/669253). |
| 418 const int icon_size = |
| 419 kTrayIconSize + 2 * GetTrayConstant(TRAY_IMAGE_ITEM_PADDING); |
| 420 bounds.set_width(bounds.width() + 2 * icon_size); |
| 421 bounds.set_height(bounds.height() + 2 * icon_size); |
| 412 std::unique_ptr<views::InkDropHighlight> highlight( | 422 std::unique_ptr<views::InkDropHighlight> highlight( |
| 413 new views::InkDropHighlight(bounds.size(), 0, | 423 new views::InkDropHighlight(bounds.size(), 0, |
| 414 gfx::RectF(bounds).CenterPoint(), | 424 gfx::RectF(bounds).CenterPoint(), |
| 415 GetInkDropBaseColor())); | 425 GetInkDropBaseColor())); |
| 416 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 426 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 417 return highlight; | 427 return highlight; |
| 418 } | 428 } |
| 419 | 429 |
| 420 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { | 430 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { |
| 421 // If there is no ink drop, show "touch feedback". | 431 // If there is no ink drop, show "touch feedback". |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // |insets| are relative to contents bounds. Change them to be relative to | 635 // |insets| are relative to contents bounds. Change them to be relative to |
| 626 // local bounds. | 636 // local bounds. |
| 627 gfx::Insets local_contents_insets = | 637 gfx::Insets local_contents_insets = |
| 628 GetLocalBounds().InsetsFrom(GetContentsBounds()); | 638 GetLocalBounds().InsetsFrom(GetContentsBounds()); |
| 629 MirrorInsetsIfNecessary(&local_contents_insets); | 639 MirrorInsetsIfNecessary(&local_contents_insets); |
| 630 insets += local_contents_insets; | 640 insets += local_contents_insets; |
| 631 | 641 |
| 632 return insets; | 642 return insets; |
| 633 } | 643 } |
| 634 | 644 |
| 635 gfx::Rect TrayBackgroundView::GetInkDropBounds() const { | 645 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 636 gfx::Insets insets = GetBackgroundInsets(); | 646 gfx::Insets insets = GetBackgroundInsets(); |
| 637 gfx::Rect bounds = GetLocalBounds(); | 647 gfx::Rect bounds = GetLocalBounds(); |
| 638 bounds.Inset(insets); | 648 bounds.Inset(insets); |
| 639 // Currently, we don't handle view resize. To compensate for that, enlarge the | |
| 640 // bounds by two tray icons so that ripple looks good even if two more icons | |
| 641 // are added when ripple is active. Note that ink drop mask handles resize | |
| 642 // correctly, so the extra ripple would be clipped. | |
| 643 // TODO(mohsen): Remove this extra size when resize is handled properly (see | |
| 644 // https://crbug.com/666175). | |
| 645 const int icon_size = | |
| 646 kTrayIconSize + 2 * GetTrayConstant(TRAY_IMAGE_ITEM_PADDING); | |
| 647 bounds.set_width(bounds.width() + 2 * icon_size); | |
| 648 bounds.set_height(bounds.height() + 2 * icon_size); | |
| 649 return bounds; | 649 return bounds; |
| 650 } | 650 } |
| 651 | 651 |
| 652 } // namespace ash | 652 } // namespace ash |
| OLD | NEW |