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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 // In the given |canvas|, for a horizontal shelf draw a separator line to the | 471 // In the given |canvas|, for a horizontal shelf draw a separator line to the |
472 // right or left of the TrayBackgroundView when the system is LTR or RTL | 472 // right or left of the TrayBackgroundView when the system is LTR or RTL |
473 // aligned, respectively. For a vertical shelf draw the separator line | 473 // aligned, respectively. For a vertical shelf draw the separator line |
474 // underneath the items instead. | 474 // underneath the items instead. |
475 const gfx::Rect local_bounds = GetLocalBounds(); | 475 const gfx::Rect local_bounds = GetLocalBounds(); |
476 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); | 476 const SkColor color = SkColorSetA(SK_ColorWHITE, 0x4D); |
477 | 477 |
478 if (IsHorizontalAlignment(shelf_alignment_)) { | 478 if (IsHorizontalAlignment(shelf_alignment_)) { |
479 const gfx::PointF point( | 479 const gfx::PointF point( |
480 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), | 480 base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth), |
481 (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2); | 481 (kShelfSize - kTrayItemSize) / 2); |
482 const gfx::Vector2dF vector(0, kTrayItemSize); | 482 const gfx::Vector2dF vector(0, kTrayItemSize); |
483 canvas->Draw1pxLine(point, point + vector, color); | 483 canvas->Draw1pxLine(point, point + vector, color); |
484 } else { | 484 } else { |
485 const gfx::PointF point((GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2, | 485 const gfx::PointF point((kShelfSize - kTrayItemSize) / 2, |
486 local_bounds.height() - kSeparatorWidth); | 486 local_bounds.height() - kSeparatorWidth); |
487 const gfx::Vector2dF vector(kTrayItemSize, 0); | 487 const gfx::Vector2dF vector(kTrayItemSize, 0); |
488 canvas->Draw1pxLine(point, point + vector, color); | 488 canvas->Draw1pxLine(point, point + vector, color); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { | 492 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { |
493 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); | 493 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); |
494 | 494 |
495 // |insets| are relative to contents bounds. Change them to be relative to | 495 // |insets| are relative to contents bounds. Change them to be relative to |
496 // local bounds. | 496 // local bounds. |
497 gfx::Insets local_contents_insets = | 497 gfx::Insets local_contents_insets = |
498 GetLocalBounds().InsetsFrom(GetContentsBounds()); | 498 GetLocalBounds().InsetsFrom(GetContentsBounds()); |
499 MirrorInsetsIfNecessary(&local_contents_insets); | 499 MirrorInsetsIfNecessary(&local_contents_insets); |
500 insets += local_contents_insets; | 500 insets += local_contents_insets; |
501 | 501 |
502 return insets; | 502 return insets; |
503 } | 503 } |
504 | 504 |
505 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 505 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
506 gfx::Insets insets = GetBackgroundInsets(); | 506 gfx::Insets insets = GetBackgroundInsets(); |
507 gfx::Rect bounds = GetLocalBounds(); | 507 gfx::Rect bounds = GetLocalBounds(); |
508 bounds.Inset(insets); | 508 bounds.Inset(insets); |
509 return bounds; | 509 return bounds; |
510 } | 510 } |
511 | 511 |
512 } // namespace ash | 512 } // namespace ash |
OLD | NEW |