| 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 "ui/views/border.h" | 5 #include "ui/views/border.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(RoundedRectBorder); | 82 DISALLOW_COPY_AND_ASSIGN(RoundedRectBorder); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 RoundedRectBorder::RoundedRectBorder(int thickness, | 85 RoundedRectBorder::RoundedRectBorder(int thickness, |
| 86 int corner_radius, | 86 int corner_radius, |
| 87 SkColor color) | 87 SkColor color) |
| 88 : thickness_(thickness), corner_radius_(corner_radius), color_(color) {} | 88 : thickness_(thickness), corner_radius_(corner_radius), color_(color) {} |
| 89 | 89 |
| 90 void RoundedRectBorder::Paint(const View& view, gfx::Canvas* canvas) { | 90 void RoundedRectBorder::Paint(const View& view, gfx::Canvas* canvas) { |
| 91 cc::PaintFlags paint; | 91 cc::PaintFlags flags; |
| 92 paint.setStrokeWidth(thickness_); | 92 flags.setStrokeWidth(thickness_); |
| 93 paint.setColor(color_); | 93 flags.setColor(color_); |
| 94 paint.setStyle(cc::PaintFlags::kStroke_Style); | 94 flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 95 paint.setAntiAlias(true); | 95 flags.setAntiAlias(true); |
| 96 | 96 |
| 97 float half_thickness = thickness_ / 2.0f; | 97 float half_thickness = thickness_ / 2.0f; |
| 98 gfx::RectF bounds(view.GetLocalBounds()); | 98 gfx::RectF bounds(view.GetLocalBounds()); |
| 99 bounds.Inset(half_thickness, half_thickness); | 99 bounds.Inset(half_thickness, half_thickness); |
| 100 canvas->DrawRoundRect(bounds, corner_radius_, paint); | 100 canvas->DrawRoundRect(bounds, corner_radius_, flags); |
| 101 } | 101 } |
| 102 | 102 |
| 103 gfx::Insets RoundedRectBorder::GetInsets() const { | 103 gfx::Insets RoundedRectBorder::GetInsets() const { |
| 104 return gfx::Insets(thickness_); | 104 return gfx::Insets(thickness_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 gfx::Size RoundedRectBorder::GetMinimumSize() const { | 107 gfx::Size RoundedRectBorder::GetMinimumSize() const { |
| 108 return gfx::Size(thickness_ * 2, thickness_ * 2); | 108 return gfx::Size(thickness_ * 2, thickness_ * 2); |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 const gfx::Insets& insets) { | 249 const gfx::Insets& insets) { |
| 250 return base::MakeUnique<ExtraInsetsBorder>(std::move(border), insets); | 250 return base::MakeUnique<ExtraInsetsBorder>(std::move(border), insets); |
| 251 } | 251 } |
| 252 | 252 |
| 253 std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter, | 253 std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter, |
| 254 const gfx::Insets& insets) { | 254 const gfx::Insets& insets) { |
| 255 return base::WrapUnique(new BorderPainter(std::move(painter), insets)); | 255 return base::WrapUnique(new BorderPainter(std::move(painter), insets)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace views | 258 } // namespace views |
| OLD | NEW |