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

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

Issue 2240603002: Harmony checkbox/radio tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 4 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/checkbox.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/checkbox.cc
diff --git a/ui/views/controls/button/checkbox.cc b/ui/views/controls/button/checkbox.cc
index 4feb92f2aa5c8a221e9361c8592c3d30d3258ad7..b8431f4ee27b59078dd26807136cd25a4aed6080 100644
--- a/ui/views/controls/button/checkbox.cc
+++ b/ui/views/controls/button/checkbox.cc
@@ -12,6 +12,7 @@
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/resources/grit/ui_resources.h"
@@ -38,6 +39,7 @@ Checkbox::Checkbox(const base::string16& label)
set_has_ink_drop_action_on_click(true);
// The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp.
set_ink_drop_size(gfx::Size(21, 21));
+ SetFocusPainter(nullptr);
} else {
std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder());
// Inset the trailing side by a couple pixels for the focus border.
@@ -133,10 +135,12 @@ void Checkbox::OnPaint(gfx::Canvas* canvas) {
SkPaint focus_paint;
focus_paint.setAntiAlias(true);
- focus_paint.setColor(GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_FocusedBorderColor));
+ focus_paint.setColor(
+ SkColorSetA(GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_FocusedBorderColor),
+ 0x66));
focus_paint.setStyle(SkPaint::kStroke_Style);
- focus_paint.setStrokeWidth(1);
+ focus_paint.setStrokeWidth(2);
PaintFocusRing(canvas, focus_paint);
}
@@ -174,11 +178,11 @@ SkColor Checkbox::GetInkDropBaseColor() const {
gfx::ImageSkia Checkbox::GetImage(ButtonState for_state) const {
if (UseMd()) {
return gfx::CreateVectorIcon(
- checked_ ? gfx::VectorIconId::CHECKBOX_ACTIVE
- : gfx::VectorIconId::CHECKBOX_NORMAL,
- 16, GetNativeTheme()->GetSystemColor(
- checked_ ? ui::NativeTheme::kColorId_FocusedBorderColor
- : ui::NativeTheme::kColorId_UnfocusedBorderColor));
+ GetVectorIconId(), 16,
+ // When not checked, the icon color matches the button text color.
+ GetNativeTheme()->GetSystemColor(
+ checked_ ? ui::NativeTheme::kColorId_CallToActionColor
+ : ui::NativeTheme::kColorId_ButtonEnabledColor));
}
const size_t checked_index = checked_ ? 1 : 0;
@@ -201,10 +205,14 @@ void Checkbox::SetCustomImage(bool checked,
void Checkbox::PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint) {
gfx::RectF focus_rect(image()->bounds());
- focus_rect.Inset(gfx::InsetsF(-.5f));
canvas->DrawRoundRect(focus_rect, 2.f, paint);
}
+gfx::VectorIconId Checkbox::GetVectorIconId() const {
+ return checked() ? gfx::VectorIconId::CHECKBOX_ACTIVE
+ : gfx::VectorIconId::CHECKBOX_NORMAL;
+}
+
void Checkbox::NotifyClick(const ui::Event& event) {
SetChecked(!checked());
LabelButton::NotifyClick(event);
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698