| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 alpha_(0) {} | 120 alpha_(0) {} |
| 121 | 121 |
| 122 ~TrayBackground() override {} | 122 ~TrayBackground() override {} |
| 123 | 123 |
| 124 void set_alpha(int alpha) { alpha_ = alpha; } | 124 void set_alpha(int alpha) { alpha_ = alpha; } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } | 127 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } |
| 128 | 128 |
| 129 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 129 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 130 cc::PaintFlags background_paint; | 130 cc::PaintFlags background_flags; |
| 131 background_paint.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 131 background_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
| 132 background_paint.setColor(SkColorSetA(kShelfBaseColor, alpha_)); | 132 background_flags.setColor(SkColorSetA(kShelfBaseColor, alpha_)); |
| 133 gfx::Insets insets = | 133 gfx::Insets insets = |
| 134 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); | 134 GetMirroredBackgroundInsets(GetShelf()->GetAlignment()); |
| 135 gfx::Rect bounds = view->GetLocalBounds(); | 135 gfx::Rect bounds = view->GetLocalBounds(); |
| 136 bounds.Inset(insets); | 136 bounds.Inset(insets); |
| 137 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_paint); | 137 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_flags); |
| 138 | 138 |
| 139 if (draws_active_ && tray_background_view_->is_active()) { | 139 if (draws_active_ && tray_background_view_->is_active()) { |
| 140 cc::PaintFlags highlight_paint; | 140 cc::PaintFlags highlight_flags; |
| 141 highlight_paint.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 141 highlight_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); |
| 142 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 142 highlight_flags.setColor(kShelfButtonActivatedHighlightColor); |
| 143 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint); | 143 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_flags); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | 147 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 148 const static int kImageTypeDefault = 0; | 148 const static int kImageTypeDefault = 0; |
| 149 // TODO(estade): leftover type which should be removed along with the rest | 149 // TODO(estade): leftover type which should be removed along with the rest |
| 150 // of pre-MD code. | 150 // of pre-MD code. |
| 151 // const static int kImageTypeOnBlack = 1; | 151 // const static int kImageTypeOnBlack = 1; |
| 152 const static int kImageTypePressed = 2; | 152 const static int kImageTypePressed = 2; |
| 153 const static int kNumStates = 3; | 153 const static int kNumStates = 3; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); | 593 const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_); |
| 594 const gfx::Rect local_bounds = GetLocalBounds(); | 594 const gfx::Rect local_bounds = GetLocalBounds(); |
| 595 const int height = kTrayItemSize; | 595 const int height = kTrayItemSize; |
| 596 const int x = | 596 const int x = |
| 597 horizontal_shelf | 597 horizontal_shelf |
| 598 ? (base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth)) | 598 ? (base::i18n::IsRTL() ? 0 : (local_bounds.width() - kSeparatorWidth)) |
| 599 : (local_bounds.height() - kSeparatorWidth); | 599 : (local_bounds.height() - kSeparatorWidth); |
| 600 const int y = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2; | 600 const int y = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2; |
| 601 gfx::ScopedCanvas scoped_canvas(canvas); | 601 gfx::ScopedCanvas scoped_canvas(canvas); |
| 602 const float scale = canvas->UndoDeviceScaleFactor(); | 602 const float scale = canvas->UndoDeviceScaleFactor(); |
| 603 cc::PaintFlags paint; | 603 cc::PaintFlags flags; |
| 604 paint.setColor(kSeparatorColor); | 604 flags.setColor(kSeparatorColor); |
| 605 paint.setAntiAlias(true); | 605 flags.setAntiAlias(true); |
| 606 | 606 |
| 607 const gfx::Rect bounds = horizontal_shelf | 607 const gfx::Rect bounds = horizontal_shelf |
| 608 ? gfx::Rect(x, y, kSeparatorWidth, height) | 608 ? gfx::Rect(x, y, kSeparatorWidth, height) |
| 609 : gfx::Rect(y, x, height, kSeparatorWidth); | 609 : gfx::Rect(y, x, height, kSeparatorWidth); |
| 610 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); | 610 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); |
| 611 gfx::PointF line_start = | 611 gfx::PointF line_start = |
| 612 horizontal_shelf | 612 horizontal_shelf |
| 613 ? (base::i18n::IsRTL() ? rect.origin() : rect.top_right()) | 613 ? (base::i18n::IsRTL() ? rect.origin() : rect.top_right()) |
| 614 : rect.bottom_left(); | 614 : rect.bottom_left(); |
| 615 gfx::PointF line_end = | 615 gfx::PointF line_end = |
| 616 (horizontal_shelf && base::i18n::IsRTL() ? rect.bottom_left() | 616 (horizontal_shelf && base::i18n::IsRTL() ? rect.bottom_left() |
| 617 : rect.bottom_right()); | 617 : rect.bottom_right()); |
| 618 | 618 |
| 619 canvas->DrawLine(line_start, line_end, paint); | 619 canvas->DrawLine(line_start, line_end, flags); |
| 620 } | 620 } |
| 621 | 621 |
| 622 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { | 622 gfx::Insets TrayBackgroundView::GetBackgroundInsets() const { |
| 623 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); | 623 gfx::Insets insets = GetMirroredBackgroundInsets(shelf_alignment_); |
| 624 | 624 |
| 625 // |insets| are relative to contents bounds. Change them to be relative to | 625 // |insets| are relative to contents bounds. Change them to be relative to |
| 626 // local bounds. | 626 // local bounds. |
| 627 gfx::Insets local_contents_insets = | 627 gfx::Insets local_contents_insets = |
| 628 GetLocalBounds().InsetsFrom(GetContentsBounds()); | 628 GetLocalBounds().InsetsFrom(GetContentsBounds()); |
| 629 MirrorInsetsIfNecessary(&local_contents_insets); | 629 MirrorInsetsIfNecessary(&local_contents_insets); |
| 630 insets += local_contents_insets; | 630 insets += local_contents_insets; |
| 631 | 631 |
| 632 return insets; | 632 return insets; |
| 633 } | 633 } |
| 634 | 634 |
| 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { | 635 gfx::Rect TrayBackgroundView::GetBackgroundBounds() const { |
| 636 gfx::Insets insets = GetBackgroundInsets(); | 636 gfx::Insets insets = GetBackgroundInsets(); |
| 637 gfx::Rect bounds = GetLocalBounds(); | 637 gfx::Rect bounds = GetLocalBounds(); |
| 638 bounds.Inset(insets); | 638 bounds.Inset(insets); |
| 639 return bounds; | 639 return bounds; |
| 640 } | 640 } |
| 641 | 641 |
| 642 } // namespace ash | 642 } // namespace ash |
| OLD | NEW |