Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: ui/views/controls/button/md_text_button.cc

Issue 1817253003: [MD] Use same focus ring on BarControlButton as MdTextButton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update docs Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46e201e3aac07361ae99ec3018b3b64a23184b35..bf0c9bd03ddc10166f5bf76beb8050246ffb57f8 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -6,7 +6,6 @@
#include "base/i18n/case_conversion.h"
#include "ui/base/material_design/material_design_controller.h"
-#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
@@ -24,37 +23,6 @@ const int kVerticalPadding = 6;
// Minimum size to reserve for the button contents.
const int kMinWidth = 48;
-// The amount to enlarge the focus border in all directions relative to the
-// button.
-const int kFocusBorderOutset = -2;
-
-// The corner radius of the focus border roundrect.
-const int kFocusBorderCornerRadius = 3;
-
-class MdFocusRing : public views::View {
- public:
- MdFocusRing() {
- SetPaintToLayer(true);
- layer()->SetFillsBoundsOpaquely(false);
- }
- ~MdFocusRing() override {}
-
- void OnPaint(gfx::Canvas* canvas) override {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_CallToActionColor));
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(1);
- gfx::RectF rect(GetLocalBounds());
- rect.Inset(gfx::InsetsF(0.5));
- canvas->DrawRoundRect(rect, kFocusBorderCornerRadius, paint);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MdFocusRing);
-};
-
} // namespace
// static
@@ -88,14 +56,6 @@ void MdTextButton::SetCallToAction(CallToAction cta) {
UpdateColorsFromNativeTheme();
}
-void MdTextButton::Layout() {
- LabelButton::Layout();
-
- gfx::Rect focus_bounds = GetLocalBounds();
- focus_bounds.Inset(gfx::Insets(kFocusBorderOutset));
- focus_ring_->SetBoundsRect(focus_bounds);
-}
-
void MdTextButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
LabelButton::OnNativeThemeChanged(theme);
UpdateColorsFromNativeTheme();
@@ -109,32 +69,17 @@ void MdTextButton::SetText(const base::string16& text) {
LabelButton::SetText(base::i18n::ToUpper(text));
}
-void MdTextButton::OnFocus() {
- View::OnFocus();
- focus_ring_->SetVisible(true);
-}
-
-void MdTextButton::OnBlur() {
- View::OnBlur();
- focus_ring_->SetVisible(false);
-}
-
MdTextButton::MdTextButton(ButtonListener* listener)
: LabelButton(listener, base::string16()),
ink_drop_delegate_(this, this),
- focus_ring_(new MdFocusRing()),
cta_(NO_CALL_TO_ACTION) {
set_ink_drop_delegate(&ink_drop_delegate_);
set_has_ink_drop_action_on_click(true);
SetHorizontalAlignment(gfx::ALIGN_CENTER);
SetFocusable(true);
SetMinSize(gfx::Size(kMinWidth, 0));
-
- AddChildView(focus_ring_);
- focus_ring_->SetVisible(false);
SetFocusPainter(nullptr);
- set_request_focus_on_press(false);
-
+ UseMdFocusRing();
label()->SetAutoColorReadabilityEnabled(false);
}
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698