| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void Checkbox::OnPaint(gfx::Canvas* canvas) { | 139 void Checkbox::OnPaint(gfx::Canvas* canvas) { |
| 140 LabelButton::OnPaint(canvas); | 140 LabelButton::OnPaint(canvas); |
| 141 | 141 |
| 142 if (!UseMd() || !HasFocus()) | 142 if (!UseMd() || !HasFocus()) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 cc::PaintFlags focus_paint; | 145 cc::PaintFlags focus_flags; |
| 146 focus_paint.setAntiAlias(true); | 146 focus_flags.setAntiAlias(true); |
| 147 focus_paint.setColor( | 147 focus_flags.setColor( |
| 148 SkColorSetA(GetNativeTheme()->GetSystemColor( | 148 SkColorSetA(GetNativeTheme()->GetSystemColor( |
| 149 ui::NativeTheme::kColorId_FocusedBorderColor), | 149 ui::NativeTheme::kColorId_FocusedBorderColor), |
| 150 0x66)); | 150 0x66)); |
| 151 focus_paint.setStyle(cc::PaintFlags::kStroke_Style); | 151 focus_flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 152 focus_paint.setStrokeWidth(2); | 152 focus_flags.setStrokeWidth(2); |
| 153 PaintFocusRing(canvas, focus_paint); | 153 PaintFocusRing(canvas, focus_flags); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void Checkbox::OnFocus() { | 156 void Checkbox::OnFocus() { |
| 157 LabelButton::OnFocus(); | 157 LabelButton::OnFocus(); |
| 158 if (!UseMd()) | 158 if (!UseMd()) |
| 159 UpdateImage(); | 159 UpdateImage(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void Checkbox::OnBlur() { | 162 void Checkbox::OnBlur() { |
| 163 LabelButton::OnBlur(); | 163 LabelButton::OnBlur(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool focused, | 208 bool focused, |
| 209 ButtonState for_state, | 209 ButtonState for_state, |
| 210 const gfx::ImageSkia& image) { | 210 const gfx::ImageSkia& image) { |
| 211 const size_t checked_index = checked ? 1 : 0; | 211 const size_t checked_index = checked ? 1 : 0; |
| 212 const size_t focused_index = focused ? 1 : 0; | 212 const size_t focused_index = focused ? 1 : 0; |
| 213 images_[checked_index][focused_index][for_state] = image; | 213 images_[checked_index][focused_index][for_state] = image; |
| 214 UpdateImage(); | 214 UpdateImage(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void Checkbox::PaintFocusRing(gfx::Canvas* canvas, | 217 void Checkbox::PaintFocusRing(gfx::Canvas* canvas, |
| 218 const cc::PaintFlags& paint) { | 218 const cc::PaintFlags& flags) { |
| 219 gfx::RectF focus_rect(image()->bounds()); | 219 gfx::RectF focus_rect(image()->bounds()); |
| 220 canvas->DrawRoundRect(focus_rect, 2.f, paint); | 220 canvas->DrawRoundRect(focus_rect, 2.f, flags); |
| 221 } | 221 } |
| 222 | 222 |
| 223 const gfx::VectorIcon& Checkbox::GetVectorIcon() const { | 223 const gfx::VectorIcon& Checkbox::GetVectorIcon() const { |
| 224 return checked() ? kCheckboxActiveIcon : kCheckboxNormalIcon; | 224 return checked() ? kCheckboxActiveIcon : kCheckboxNormalIcon; |
| 225 } | 225 } |
| 226 | 226 |
| 227 void Checkbox::NotifyClick(const ui::Event& event) { | 227 void Checkbox::NotifyClick(const ui::Event& event) { |
| 228 SetChecked(!checked()); | 228 SetChecked(!checked()); |
| 229 LabelButton::NotifyClick(event); | 229 LabelButton::NotifyClick(event); |
| 230 } | 230 } |
| 231 | 231 |
| 232 ui::NativeTheme::Part Checkbox::GetThemePart() const { | 232 ui::NativeTheme::Part Checkbox::GetThemePart() const { |
| 233 return ui::NativeTheme::kCheckbox; | 233 return ui::NativeTheme::kCheckbox; |
| 234 } | 234 } |
| 235 | 235 |
| 236 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 236 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
| 237 LabelButton::GetExtraParams(params); | 237 LabelButton::GetExtraParams(params); |
| 238 params->button.checked = checked_; | 238 params->button.checked = checked_; |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace views | 241 } // namespace views |
| OLD | NEW |