Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: ui/views/controls/button/checkbox.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/label_button_border.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (checked()) 126 if (checked())
127 node_data->AddStateFlag(ui::AX_STATE_CHECKED); 127 node_data->AddStateFlag(ui::AX_STATE_CHECKED);
128 } 128 }
129 129
130 void Checkbox::OnPaint(gfx::Canvas* canvas) { 130 void Checkbox::OnPaint(gfx::Canvas* canvas) {
131 LabelButton::OnPaint(canvas); 131 LabelButton::OnPaint(canvas);
132 132
133 if (!UseMd() || !HasFocus()) 133 if (!UseMd() || !HasFocus())
134 return; 134 return;
135 135
136 SkPaint focus_paint; 136 CdlPaint focus_paint;
137 focus_paint.setAntiAlias(true); 137 focus_paint.setAntiAlias(true);
138 focus_paint.setColor( 138 focus_paint.setColor(
139 SkColorSetA(GetNativeTheme()->GetSystemColor( 139 SkColorSetA(GetNativeTheme()->GetSystemColor(
140 ui::NativeTheme::kColorId_FocusedBorderColor), 140 ui::NativeTheme::kColorId_FocusedBorderColor),
141 0x66)); 141 0x66));
142 focus_paint.setStyle(SkPaint::kStroke_Style); 142 focus_paint.setStyle(CdlPaint::kStroke_Style);
143 focus_paint.setStrokeWidth(2); 143 focus_paint.setStrokeWidth(2);
144 PaintFocusRing(canvas, focus_paint); 144 PaintFocusRing(canvas, focus_paint);
145 } 145 }
146 146
147 void Checkbox::OnFocus() { 147 void Checkbox::OnFocus() {
148 LabelButton::OnFocus(); 148 LabelButton::OnFocus();
149 if (!UseMd()) 149 if (!UseMd())
150 UpdateImage(); 150 UpdateImage();
151 } 151 }
152 152
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void Checkbox::SetCustomImage(bool checked, 198 void Checkbox::SetCustomImage(bool checked,
199 bool focused, 199 bool focused,
200 ButtonState for_state, 200 ButtonState for_state,
201 const gfx::ImageSkia& image) { 201 const gfx::ImageSkia& image) {
202 const size_t checked_index = checked ? 1 : 0; 202 const size_t checked_index = checked ? 1 : 0;
203 const size_t focused_index = focused ? 1 : 0; 203 const size_t focused_index = focused ? 1 : 0;
204 images_[checked_index][focused_index][for_state] = image; 204 images_[checked_index][focused_index][for_state] = image;
205 UpdateImage(); 205 UpdateImage();
206 } 206 }
207 207
208 void Checkbox::PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint) { 208 void Checkbox::PaintFocusRing(gfx::Canvas* canvas, const CdlPaint& paint) {
209 gfx::RectF focus_rect(image()->bounds()); 209 gfx::RectF focus_rect(image()->bounds());
210 canvas->DrawRoundRect(focus_rect, 2.f, paint); 210 canvas->DrawRoundRect(focus_rect, 2.f, paint);
211 } 211 }
212 212
213 gfx::VectorIconId Checkbox::GetVectorIconId() const { 213 gfx::VectorIconId Checkbox::GetVectorIconId() const {
214 return checked() ? gfx::VectorIconId::CHECKBOX_ACTIVE 214 return checked() ? gfx::VectorIconId::CHECKBOX_ACTIVE
215 : gfx::VectorIconId::CHECKBOX_NORMAL; 215 : gfx::VectorIconId::CHECKBOX_NORMAL;
216 } 216 }
217 217
218 void Checkbox::NotifyClick(const ui::Event& event) { 218 void Checkbox::NotifyClick(const ui::Event& event) {
219 SetChecked(!checked()); 219 SetChecked(!checked());
220 LabelButton::NotifyClick(event); 220 LabelButton::NotifyClick(event);
221 } 221 }
222 222
223 ui::NativeTheme::Part Checkbox::GetThemePart() const { 223 ui::NativeTheme::Part Checkbox::GetThemePart() const {
224 return ui::NativeTheme::kCheckbox; 224 return ui::NativeTheme::kCheckbox;
225 } 225 }
226 226
227 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { 227 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
228 LabelButton::GetExtraParams(params); 228 LabelButton::GetExtraParams(params);
229 params->button.checked = checked_; 229 params->button.checked = checked_;
230 } 230 }
231 231
232 } // namespace views 232 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/label_button_border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698