Chromium Code Reviews| 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" | |
| 11 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| 12 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 13 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 14 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/system/tray/tray_event_filter.h" | 15 #include "ash/common/system/tray/tray_event_filter.h" |
| 17 #include "ash/common/wm_lookup.h" | 16 #include "ash/common/wm_lookup.h" |
| 18 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 19 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 20 #include "ash/public/cpp/shell_window_ids.h" | 19 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 if (action_performed) | 559 if (action_performed) |
| 561 return; | 560 return; |
| 562 ActionableView::HandlePerformActionResult(action_performed, event); | 561 ActionableView::HandlePerformActionResult(action_performed, event); |
| 563 } | 562 } |
| 564 | 563 |
| 565 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { | 564 void TrayBackgroundView::OnPaintFocus(gfx::Canvas* canvas) { |
| 566 // The tray itself expands to the right and bottom edge of the screen to make | 565 // The tray itself expands to the right and bottom edge of the screen to make |
| 567 // sure clicking on the edges brings up the popup. However, the focus border | 566 // sure clicking on the edges brings up the popup. However, the focus border |
| 568 // should be only around the container. | 567 // should be only around the container. |
| 569 gfx::RectF paint_bounds; | 568 gfx::RectF paint_bounds; |
| 570 if (MaterialDesignController::IsShelfMaterial()) { | 569 paint_bounds = gfx::RectF(GetBackgroundBounds()); |
| 571 paint_bounds = gfx::RectF(GetBackgroundBounds()); | 570 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); |
| 572 paint_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); | |
| 573 } else { | |
| 574 paint_bounds = gfx::RectF(GetContentsBounds()); | |
| 575 paint_bounds.Inset(gfx::Insets(1)); | |
| 576 } | |
| 577 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, | 571 canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor, |
| 578 kFocusBorderThickness); | 572 kFocusBorderThickness); |
| 579 } | 573 } |
| 580 | 574 |
| 581 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { | 575 void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 582 ActionableView::OnPaint(canvas); | 576 ActionableView::OnPaint(canvas); |
| 583 if (!MaterialDesignController::IsShelfMaterial() || | 577 if (shelf()->GetBackgroundType() == |
| 584 shelf()->GetBackgroundType() == | |
| 585 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || | 578 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT || |
| 586 !separator_visible_) { | 579 !separator_visible_) { |
| 587 return; | 580 return; |
| 588 } | 581 } |
| 589 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 582 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
| 590 // right or left of the TrayBackgroundView when the system is LTR or RTL | 583 // right or left of the TrayBackgroundView when the system is LTR or RTL |
| 591 // aligned, respectively. For a vertical shelf draw the separator line | 584 // aligned, respectively. For a vertical shelf draw the separator line |
| 592 // underneath the items instead. | 585 // underneath the items instead. |
| 593 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | |
| 594 const gfx::Rect local_bounds = GetLocalBounds(); | 586 const gfx::Rect local_bounds = GetLocalBounds(); |
| 595 const int height = kTrayItemSize; | 587 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); |
|
tdanderson
2017/02/28 17:18:19
Why are you changing the alpha from 0x99 to 0x4D?
Evan Stade
2017/02/28 18:15:26
see my comment that I sent out with the review for
tdanderson
2017/02/28 18:41:34
Acknowledged.
| |
| 596 const int x = | |
| 597 horizontal_shelf | |
| 598 ? (base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth)) | |
| 599 : (local_bounds.height() - kSeparatorWidth); | |
| 600 const int y = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2; | |
| 601 gfx::ScopedCanvas scoped_canvas(canvas); | |
| 602 const float scale = canvas->UndoDeviceScaleFactor(); | |
| 603 cc::PaintFlags flags; | |
| 604 flags.setColor(kTraySeparatorColor); | |
| 605 flags.setAntiAlias(true); | |
| 606 | 588 |
| 607 const gfx::Rect bounds = horizontal_shelf | 589 if (IsHorizontalAlignment(shelf_alignment_)) { |
| 608 ? gfx::Rect(x, y, kSeparatorWidth, height) | 590 const gfx::PointF point( |
| 609 : gfx::Rect(y, x, height, kSeparatorWidth); | 591 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), |
| 610 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); | 592 (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2); |
|
tdanderson
2017/02/28 17:18:19
looks like a case of a missing )
| |
| 611 gfx::PointF line_start = | 593 const gfx::Vector2dF vector(0, kTrayItemSize); |
| 612 horizontal_shelf | 594 canvas->Draw1pxLine(point, point + vector, color); |
| 613 ? (base::i18n::IsRTL() ? rect.origin() : rect.top_right()) | 595 } else { |
| 614 : rect.bottom_left(); | 596 const gfx::PointF point((GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2, |
|
tdanderson
2017/02/28 17:18:19
I think your x and y should be reversed here
Evan Stade
2017/02/28 18:15:26
I don't think so. This is for vertical shelf.
tdanderson
2017/02/28 18:41:34
My mistake, I was just looking at the current code
| |
| 615 gfx::PointF line_end = | 597 local_bounds.height() - kSeparatorWidth); |
| 616 (horizontal_shelf && base::i18n::IsRTL() ? rect.bottom_left() | 598 const gfx::Vector2dF vector(kTrayItemSize, 0); |
| 617 : rect.bottom_right()); | 599 canvas->Draw1pxLine(point, point + vector, color); |
| 618 | 600 } |
| 619 canvas->DrawLine(line_start, line_end, flags); | |
| 620 } | 601 } |
| 621 | 602 |
| 622 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { | 603 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { |
| 623 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); | 604 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); |
| 624 | 605 |
| 625 // |insets| are relative to contents bounds. Change them to be relative to | 606 // |insets| are relative to contents bounds. Change them to be relative to |
| 626 // local bounds. | 607 // local bounds. |
| 627 gfx::Insets local_contents_insets = | 608 gfx::Insets local_contents_insets = |
| 628 GetLocalBounds().InsetsFrom(GetContentsBounds()); | 609 GetLocalBounds().InsetsFrom(GetContentsBounds()); |
| 629 MirrorInsetsIfNecessary(&local_contents_insets); | 610 MirrorInsetsIfNecessary(&local_contents_insets); |
| 630 insets += local_contents_insets; | 611 insets += local_contents_insets; |
| 631 | 612 |
| 632 return insets; | 613 return insets; |
| 633 } | 614 } |
| 634 | 615 |
| 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 616 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 636 gfx::Insets insets = GetBackgroundInsets(); | 617 gfx::Insets insets = GetBackgroundInsets(); |
| 637 gfx::Rect bounds = GetLocalBounds(); | 618 gfx::Rect bounds = GetLocalBounds(); |
| 638 bounds.Inset(insets); | 619 bounds.Inset(insets); |
| 639 return bounds; | 620 return bounds; |
| 640 } | 621 } |
| 641 | 622 |
| 642 } // namespace ash | 623 } // namespace ash |
| OLD | NEW |