Index: ui/views/controls/button/md_text_button.cc |
diff --git a/ui/views/controls/button/md_text_button.cc b/ui/views/controls/button/md_text_button.cc |
index b81c989fcee101f38a8106eb0311648cb7af6c48..8e61c1c85c7e97cd1e6337891493a92080d89729 100644 |
--- a/ui/views/controls/button/md_text_button.cc |
+++ b/ui/views/controls/button/md_text_button.cc |
@@ -16,6 +16,7 @@ |
#include "ui/views/background.h" |
#include "ui/views/border.h" |
#include "ui/views/controls/button/blue_button.h" |
+#include "ui/views/controls/focus_ring.h" |
#include "ui/views/painter.h" |
#include "ui/views/style/platform_style.h" |
@@ -26,12 +27,6 @@ namespace { |
// Minimum size to reserve for the button contents. |
const int kMinWidth = 48; |
-// The stroke width of the focus border in dp. |
-const int kFocusBorderThickness = 2; |
- |
-// The corner radius of the focus border roundrect. |
-const int kFocusBorderCornerRadius = 3; |
- |
LabelButton* CreateButton(ButtonListener* listener, |
const base::string16& text, |
bool md) { |
@@ -54,39 +49,6 @@ const gfx::FontList& GetMdFontList() { |
} // namespace |
-namespace internal { |
- |
-class MdFocusRing : public View { |
- public: |
- MdFocusRing() { |
- SetPaintToLayer(true); |
- layer()->SetFillsBoundsOpaquely(false); |
- } |
- ~MdFocusRing() override {} |
- |
- // View: |
- bool CanProcessEventsWithinSubtree() const override { return false; } |
- |
- void OnPaint(gfx::Canvas* canvas) override { |
- SkPaint paint; |
- paint.setAntiAlias(true); |
- paint.setColor( |
- SkColorSetA(GetNativeTheme()->GetSystemColor( |
- ui::NativeTheme::kColorId_FocusedBorderColor), |
- 0x66)); |
- paint.setStyle(SkPaint::kStroke_Style); |
- paint.setStrokeWidth(kFocusBorderThickness); |
- gfx::RectF rect(GetLocalBounds()); |
- rect.Inset(gfx::InsetsF(kFocusBorderThickness / 2.f)); |
- canvas->DrawRoundRect(rect, kFocusBorderCornerRadius, paint); |
- } |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(MdFocusRing); |
-}; |
- |
-} // namespace internal |
- |
// static |
LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener, |
const base::string16& text) { |
@@ -124,13 +86,6 @@ void MdTextButton::SetProminent(bool is_prominent) { |
UpdateColors(); |
} |
-void MdTextButton::Layout() { |
- LabelButton::Layout(); |
- gfx::Rect focus_bounds = GetLocalBounds(); |
- focus_bounds.Inset(gfx::Insets(-kFocusBorderThickness)); |
- focus_ring_->SetBoundsRect(focus_bounds); |
-} |
- |
void MdTextButton::OnFocus() { |
LabelButton::OnFocus(); |
focus_ring_->SetVisible(true); |
@@ -219,7 +174,7 @@ void MdTextButton::SetFontList(const gfx::FontList& font_list) { |
MdTextButton::MdTextButton(ButtonListener* listener) |
: LabelButton(listener, base::string16()), |
- focus_ring_(new internal::MdFocusRing()), |
+ focus_ring_(new FocusRing()), |
is_prominent_(false) { |
SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON |
: InkDropMode::OFF); |