Chromium Code Reviews| 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 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 void Checkbox::SetChecked(bool checked) { | 97 void Checkbox::SetChecked(bool checked) { |
| 98 checked_ = checked; | 98 checked_ = checked; |
| 99 UpdateImage(); | 99 UpdateImage(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // static | 102 // static |
| 103 bool Checkbox::UseMd() { | 103 bool Checkbox::UseMd() { |
| 104 return ui::MaterialDesignController::IsSecondaryUiMaterial(); | 104 return ui::MaterialDesignController::IsSecondaryUiMaterial(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void Checkbox::Layout() { | |
| 108 LabelButton::Layout(); | |
| 109 | |
| 110 if (!UseMd()) { | |
| 111 // Construct a focus painter that only surrounds the label area. | |
| 112 gfx::Rect rect = label()->GetMirroredBounds(); | |
| 113 rect.Inset(-2, 3); | |
| 114 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( | |
|
tapted
2017/03/08 00:26:43
The LabelButton constructor still sets a FocusPain
Evan Stade
2017/03/08 00:38:17
yes!
| |
| 115 rect.y(), rect.x(), height() - rect.bottom(), width() - rect.right()))); | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 const char* Checkbox::GetClassName() const { | 107 const char* Checkbox::GetClassName() const { |
| 120 return kViewClassName; | 108 return kViewClassName; |
| 121 } | 109 } |
| 122 | 110 |
| 123 void Checkbox::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 111 void Checkbox::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 124 LabelButton::GetAccessibleNodeData(node_data); | 112 LabelButton::GetAccessibleNodeData(node_data); |
| 125 node_data->role = ui::AX_ROLE_CHECK_BOX; | 113 node_data->role = ui::AX_ROLE_CHECK_BOX; |
| 126 if (checked()) | 114 if (checked()) |
| 127 node_data->AddStateFlag(ui::AX_STATE_CHECKED); | 115 node_data->AddStateFlag(ui::AX_STATE_CHECKED); |
| 128 if (enabled()) { | 116 if (enabled()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 220 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
| 233 return ui::NativeTheme::kCheckbox; | 221 return ui::NativeTheme::kCheckbox; |
| 234 } | 222 } |
| 235 | 223 |
| 236 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 224 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
| 237 LabelButton::GetExtraParams(params); | 225 LabelButton::GetExtraParams(params); |
| 238 params->button.checked = checked_; | 226 params->button.checked = checked_; |
| 239 } | 227 } |
| 240 | 228 |
| 241 } // namespace views | 229 } // namespace views |
| OLD | NEW |