| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/controls/focus_ring.h" | 5 #include "ui/views/controls/focus_ring.h" |
| 6 | 6 |
| 7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/native_theme/native_theme.h" | 8 #include "ui/native_theme/native_theme.h" |
| 9 #include "ui/views/controls/focusable_border.h" | 9 #include "ui/views/controls/focusable_border.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 void FocusRing::Layout() { | 63 void FocusRing::Layout() { |
| 64 // The focus ring handles its own sizing, which is simply to fill the parent | 64 // The focus ring handles its own sizing, which is simply to fill the parent |
| 65 // and extend a little beyond its borders. | 65 // and extend a little beyond its borders. |
| 66 gfx::Rect focus_bounds = parent()->GetLocalBounds(); | 66 gfx::Rect focus_bounds = parent()->GetLocalBounds(); |
| 67 focus_bounds.Inset(gfx::Insets(-kFocusHaloThicknessDp)); | 67 focus_bounds.Inset(gfx::Insets(-kFocusHaloThicknessDp)); |
| 68 SetBoundsRect(focus_bounds); | 68 SetBoundsRect(focus_bounds); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void FocusRing::OnPaint(gfx::Canvas* canvas) { | 71 void FocusRing::OnPaint(gfx::Canvas* canvas) { |
| 72 cc::PaintFlags paint; | 72 cc::PaintFlags flags; |
| 73 paint.setAntiAlias(true); | 73 flags.setAntiAlias(true); |
| 74 paint.setColor( | 74 flags.setColor( |
| 75 SkColorSetA(GetNativeTheme()->GetSystemColor( | 75 SkColorSetA(GetNativeTheme()->GetSystemColor( |
| 76 override_color_id_ != ui::NativeTheme::kColorId_NumColors | 76 override_color_id_ != ui::NativeTheme::kColorId_NumColors |
| 77 ? override_color_id_ | 77 ? override_color_id_ |
| 78 : ui::NativeTheme::kColorId_FocusedBorderColor), | 78 : ui::NativeTheme::kColorId_FocusedBorderColor), |
| 79 0x66)); | 79 0x66)); |
| 80 paint.setStyle(cc::PaintFlags::kStroke_Style); | 80 flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 81 paint.setStrokeWidth(kFocusHaloThicknessDp); | 81 flags.setStrokeWidth(kFocusHaloThicknessDp); |
| 82 gfx::RectF rect(GetLocalBounds()); | 82 gfx::RectF rect(GetLocalBounds()); |
| 83 rect.Inset(gfx::InsetsF(kFocusHaloThicknessDp / 2.f)); | 83 rect.Inset(gfx::InsetsF(kFocusHaloThicknessDp / 2.f)); |
| 84 canvas->DrawRoundRect(rect, kFocusHaloCornerRadiusDp, paint); | 84 canvas->DrawRoundRect(rect, kFocusHaloCornerRadiusDp, flags); |
| 85 } | 85 } |
| 86 | 86 |
| 87 FocusRing::FocusRing() | 87 FocusRing::FocusRing() |
| 88 : override_color_id_(ui::NativeTheme::kColorId_NumColors) { | 88 : override_color_id_(ui::NativeTheme::kColorId_NumColors) { |
| 89 // A layer is necessary to paint beyond the parent's bounds. | 89 // A layer is necessary to paint beyond the parent's bounds. |
| 90 SetPaintToLayer(); | 90 SetPaintToLayer(); |
| 91 layer()->SetFillsBoundsOpaquely(false); | 91 layer()->SetFillsBoundsOpaquely(false); |
| 92 } | 92 } |
| 93 | 93 |
| 94 FocusRing::~FocusRing() {} | 94 FocusRing::~FocusRing() {} |
| 95 | 95 |
| 96 } // namespace views | 96 } // namespace views |
| OLD | NEW |