| 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_view_state.h" | 11 #include "ui/accessibility/ax_view_state.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/gfx/vector_icons_public.h" | 17 #include "ui/gfx/vector_icons_public.h" |
| 18 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
| 19 #include "ui/views/animation/ink_drop_highlight.h" | 19 #include "ui/views/animation/ink_drop_highlight.h" |
| 20 #include "ui/views/animation/ink_drop_ripple.h" | 20 #include "ui/views/animation/ink_drop_ripple.h" |
| 21 #include "ui/views/controls/button/label_button_border.h" | 21 #include "ui/views/controls/button/label_button_border.h" |
| 22 #include "ui/views/painter.h" | 22 #include "ui/views/painter.h" |
| 23 #include "ui/views/resources/grit/views_resources.h" | 23 #include "ui/views/resources/grit/views_resources.h" |
| 24 #include "ui/views/style/platform_style.h" |
| 24 | 25 |
| 25 namespace views { | 26 namespace views { |
| 26 | 27 |
| 27 // static | 28 // static |
| 28 const char Checkbox::kViewClassName[] = "Checkbox"; | 29 const char Checkbox::kViewClassName[] = "Checkbox"; |
| 29 | 30 |
| 30 Checkbox::Checkbox(const base::string16& label) | 31 Checkbox::Checkbox(const base::string16& label) |
| 31 : LabelButton(NULL, label), | 32 : LabelButton(NULL, label), |
| 32 checked_(false) { | 33 checked_(false) { |
| 33 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 34 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 34 SetFocusForPlatform(); | 35 SetFocusForPlatform(); |
| 35 | 36 |
| 36 if (UseMd()) { | 37 if (UseMd()) { |
| 37 set_request_focus_on_press(false); | 38 set_request_focus_on_press(false); |
| 38 SetInkDropMode(InkDropMode::ON); | 39 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON |
| 40 : InkDropMode::OFF); |
| 39 set_has_ink_drop_action_on_click(true); | 41 set_has_ink_drop_action_on_click(true); |
| 40 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. | 42 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. |
| 41 set_ink_drop_size(gfx::Size(21, 21)); | 43 set_ink_drop_size(gfx::Size(21, 21)); |
| 42 SetFocusPainter(nullptr); | 44 SetFocusPainter(nullptr); |
| 43 } else { | 45 } else { |
| 44 std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder()); | 46 std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder()); |
| 45 // Inset the trailing side by a couple pixels for the focus border. | 47 // Inset the trailing side by a couple pixels for the focus border. |
| 46 button_border->set_insets(gfx::Insets(0, 0, 0, 2)); | 48 button_border->set_insets(gfx::Insets(0, 0, 0, 2)); |
| 47 SetBorder(std::move(button_border)); | 49 SetBorder(std::move(button_border)); |
| 48 set_request_focus_on_press(true); | 50 set_request_focus_on_press(true); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 223 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
| 222 return ui::NativeTheme::kCheckbox; | 224 return ui::NativeTheme::kCheckbox; |
| 223 } | 225 } |
| 224 | 226 |
| 225 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 227 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
| 226 LabelButton::GetExtraParams(params); | 228 LabelButton::GetExtraParams(params); |
| 227 params->button.checked = checked_; | 229 params->button.checked = checked_; |
| 228 } | 230 } |
| 229 | 231 |
| 230 } // namespace views | 232 } // namespace views |
| OLD | NEW |