OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/button/checkbox.h" | 5 #include "ui/views/controls/button/checkbox.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "ui/accessibility/ax_node_data.h" | 11 #include "ui/accessibility/ax_node_data.h" |
12 #include "ui/base/material_design/material_design_controller.h" | 12 #include "ui/base/material_design/material_design_controller.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/color_utils.h" | 15 #include "ui/gfx/color_utils.h" |
16 #include "ui/gfx/paint_vector_icon.h" | 16 #include "ui/gfx/paint_vector_icon.h" |
17 #include "ui/views/animation/ink_drop_highlight.h" | 17 #include "ui/views/animation/ink_drop_impl.h" |
18 #include "ui/views/animation/ink_drop_ripple.h" | 18 #include "ui/views/animation/ink_drop_ripple.h" |
19 #include "ui/views/animation/square_ink_drop_ripple.h" | 19 #include "ui/views/animation/square_ink_drop_ripple.h" |
20 #include "ui/views/controls/button/label_button_border.h" | 20 #include "ui/views/controls/button/label_button_border.h" |
21 #include "ui/views/painter.h" | 21 #include "ui/views/painter.h" |
22 #include "ui/views/resources/grit/views_resources.h" | 22 #include "ui/views/resources/grit/views_resources.h" |
23 #include "ui/views/style/platform_style.h" | 23 #include "ui/views/style/platform_style.h" |
24 #include "ui/views/vector_icons.h" | 24 #include "ui/views/vector_icons.h" |
25 | 25 |
26 namespace views { | 26 namespace views { |
27 | 27 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 UpdateImage(); | 136 UpdateImage(); |
137 } | 137 } |
138 | 138 |
139 void Checkbox::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 139 void Checkbox::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
140 LabelButton::OnNativeThemeChanged(theme); | 140 LabelButton::OnNativeThemeChanged(theme); |
141 if (UseMd()) | 141 if (UseMd()) |
142 UpdateImage(); | 142 UpdateImage(); |
143 } | 143 } |
144 | 144 |
145 std::unique_ptr<InkDrop> Checkbox::CreateInkDrop() { | 145 std::unique_ptr<InkDrop> Checkbox::CreateInkDrop() { |
146 std::unique_ptr<InkDrop> ink_drop = LabelButton::CreateInkDrop(); | 146 // Completely removes the highlight. |
| 147 std::unique_ptr<InkDropImpl> ink_drop = CreateDefaultInkDropImpl(); |
147 ink_drop->SetShowHighlightOnHover(false); | 148 ink_drop->SetShowHighlightOnHover(false); |
| 149 ink_drop->SetAutoHighlightMode(views::InkDropImpl::AutoHighlightMode::NONE); |
148 return ink_drop; | 150 return ink_drop; |
149 } | 151 } |
150 | 152 |
151 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const { | 153 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const { |
152 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. | 154 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. |
153 const gfx::Size size(21, 21); | 155 const gfx::Size size(21, 21); |
154 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( | 156 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( |
155 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size, | 157 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size, |
156 kInkDropSmallCornerRadius, image()->GetMirroredBounds().CenterPoint(), | 158 kInkDropSmallCornerRadius, image()->GetMirroredBounds().CenterPoint(), |
157 GetInkDropBaseColor(), ink_drop_visible_opacity())); | 159 GetInkDropBaseColor(), ink_drop_visible_opacity())); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 226 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
225 return ui::NativeTheme::kCheckbox; | 227 return ui::NativeTheme::kCheckbox; |
226 } | 228 } |
227 | 229 |
228 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 230 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
229 LabelButton::GetExtraParams(params); | 231 LabelButton::GetExtraParams(params); |
230 params->button.checked = checked_; | 232 params->button.checked = checked_; |
231 } | 233 } |
232 | 234 |
233 } // namespace views | 235 } // namespace views |
OLD | NEW |