| 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 16 matching lines...) Expand all Loading... |
| 27 return static_cast<FocusRing*>(parent->child_at(i)); | 27 return static_cast<FocusRing*>(parent->child_at(i)); |
| 28 } | 28 } |
| 29 return nullptr; | 29 return nullptr; |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 const char FocusRing::kViewClassName[] = "FocusRing"; | 34 const char FocusRing::kViewClassName[] = "FocusRing"; |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 void FocusRing::Install(views::View* parent, | 37 views::View* FocusRing::Install(views::View* parent, |
| 38 ui::NativeTheme::ColorId override_color_id) { | 38 ui::NativeTheme::ColorId override_color_id) { |
| 39 DCHECK(parent->HasFocus()); | 39 DCHECK(parent->HasFocus()); |
| 40 FocusRing* ring = GetFocusRing(parent); | 40 FocusRing* ring = GetFocusRing(parent); |
| 41 if (!ring) { | 41 if (!ring) { |
| 42 ring = new FocusRing(); | 42 ring = new FocusRing(); |
| 43 parent->AddChildView(ring); | 43 parent->AddChildView(ring); |
| 44 } | 44 } |
| 45 ring->override_color_id_ = override_color_id; | 45 ring->override_color_id_ = override_color_id; |
| 46 ring->Layout(); | 46 ring->Layout(); |
| 47 ring->SchedulePaint(); | 47 ring->SchedulePaint(); |
| 48 return ring; |
| 48 } | 49 } |
| 49 | 50 |
| 50 // static | 51 // static |
| 51 void FocusRing::Uninstall(views::View* parent) { | 52 void FocusRing::Uninstall(views::View* parent) { |
| 52 delete GetFocusRing(parent); | 53 delete GetFocusRing(parent); |
| 53 } | 54 } |
| 54 | 55 |
| 55 const char* FocusRing::GetClassName() const { | 56 const char* FocusRing::GetClassName() const { |
| 56 return kViewClassName; | 57 return kViewClassName; |
| 57 } | 58 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 FocusRing::FocusRing() | 88 FocusRing::FocusRing() |
| 88 : override_color_id_(ui::NativeTheme::kColorId_NumColors) { | 89 : override_color_id_(ui::NativeTheme::kColorId_NumColors) { |
| 89 // A layer is necessary to paint beyond the parent's bounds. | 90 // A layer is necessary to paint beyond the parent's bounds. |
| 90 SetPaintToLayer(true); | 91 SetPaintToLayer(true); |
| 91 layer()->SetFillsBoundsOpaquely(false); | 92 layer()->SetFillsBoundsOpaquely(false); |
| 92 } | 93 } |
| 93 | 94 |
| 94 FocusRing::~FocusRing() {} | 95 FocusRing::~FocusRing() {} |
| 95 | 96 |
| 96 } // namespace views | 97 } // namespace views |
| OLD | NEW |