| 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_impl.h" | 17 #include "ui/views/animation/ink_drop_highlight.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 // Completely removes the highlight. | 146 std::unique_ptr<InkDrop> ink_drop = LabelButton::CreateInkDrop(); |
| 147 std::unique_ptr<InkDropImpl> ink_drop = CreateDefaultInkDropImpl(); | |
| 148 ink_drop->SetShowHighlightOnHover(false); | 147 ink_drop->SetShowHighlightOnHover(false); |
| 149 ink_drop->SetAutoHighlightMode(views::InkDropImpl::AutoHighlightMode::NONE); | |
| 150 return ink_drop; | 148 return ink_drop; |
| 151 } | 149 } |
| 152 | 150 |
| 153 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const { | 151 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const { |
| 154 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. | 152 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. |
| 155 const gfx::Size size(21, 21); | 153 const gfx::Size size(21, 21); |
| 156 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( | 154 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( |
| 157 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size, | 155 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size, |
| 158 kInkDropSmallCornerRadius, image()->GetMirroredBounds().CenterPoint(), | 156 kInkDropSmallCornerRadius, image()->GetMirroredBounds().CenterPoint(), |
| 159 GetInkDropBaseColor(), ink_drop_visible_opacity())); | 157 GetInkDropBaseColor(), ink_drop_visible_opacity())); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 224 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
| 227 return ui::NativeTheme::kCheckbox; | 225 return ui::NativeTheme::kCheckbox; |
| 228 } | 226 } |
| 229 | 227 |
| 230 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 228 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
| 231 LabelButton::GetExtraParams(params); | 229 LabelButton::GetExtraParams(params); |
| 232 params->button.checked = checked_; | 230 params->button.checked = checked_; |
| 233 } | 231 } |
| 234 | 232 |
| 235 } // namespace views | 233 } // namespace views |
| OLD | NEW |