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

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

Issue 2032683003: Add ripples to md checkboxes/radio buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/md_text_button.h » ('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 c1db4715f33b532cdc2a7204ff02568972166a93..06570d89fb49f15633a32a44ee4ab6a41bb30136 100644
--- a/ui/views/controls/button/checkbox.cc
+++ b/ui/views/controls/button/checkbox.cc
@@ -15,6 +15,9 @@
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/resources/grit/ui_resources.h"
+#include "ui/views/animation/button_ink_drop_delegate.h"
+#include "ui/views/animation/ink_drop_hover.h"
+#include "ui/views/animation/ink_drop_ripple.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/painter.h"
#include "ui/views/resources/grit/views_resources.h"
@@ -32,6 +35,11 @@ Checkbox::Checkbox(const base::string16& label)
if (UseMd()) {
set_request_focus_on_press(false);
+ set_ink_drop_delegate(
+ base::WrapUnique(new ButtonInkDropDelegate(this, this)));
+ 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));
} else {
std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder());
// Inset the trailing side by a couple pixels for the focus border.
@@ -152,6 +160,24 @@ void Checkbox::OnNativeThemeChanged(const ui::NativeTheme* theme) {
UpdateImage();
}
+std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const {
+ // Skip over the LabelButton override.
+ return InkDropHostView::CreateInkDropRipple();
+}
+
+std::unique_ptr<InkDropHover> Checkbox::CreateInkDropHover() const {
+ return nullptr;
+}
+
+gfx::Point Checkbox::GetInkDropCenter() const {
+ return image()->bounds().CenterPoint();
+}
+
+SkColor Checkbox::GetInkDropBaseColor() const {
+ return GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_UnfocusedBorderColor);
sky 2016/06/02 03:13:30 This seems like a weird choice for a base color. I
Evan Stade 2016/06/02 19:40:18 How so? It's the color of the checkbox square/radi
sky 2016/06/02 21:47:59 I didn't realize we use 'unfocused border color' i
+}
+
gfx::ImageSkia Checkbox::GetImage(ButtonState for_state) const {
if (UseMd()) {
return gfx::CreateVectorIcon(
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698