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

Unified Diff: ui/views/controls/button/radio_button.cc

Issue 2240603002: Harmony checkbox/radio tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/radio_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/radio_button.cc
diff --git a/ui/views/controls/button/radio_button.cc b/ui/views/controls/button/radio_button.cc
index cf1008020ac1d49d2e526288862252cc7f1183d9..451df585bb22fe5030c6926f3a6d6ceba3d86a86 100644
--- a/ui/views/controls/button/radio_button.cc
+++ b/ui/views/controls/button/radio_button.cc
@@ -67,40 +67,6 @@ RadioButton::RadioButton(const base::string16& label, int group_id)
RadioButton::~RadioButton() {
}
-void RadioButton::SetChecked(bool checked) {
- if (checked == RadioButton::checked())
- return;
- if (checked) {
- // We can't just get the root view here because sometimes the radio
- // button isn't attached to a root view (e.g., if it's part of a tab page
- // that is currently not active).
- View* container = parent();
- while (container && container->parent())
- container = container->parent();
- if (container) {
- Views other;
- container->GetViewsInGroup(GetGroup(), &other);
- for (Views::iterator i(other.begin()); i != other.end(); ++i) {
- if (*i != this) {
- if (strcmp((*i)->GetClassName(), kViewClassName)) {
- NOTREACHED() << "radio-button-nt has same group as other non "
- "radio-button-nt views.";
- continue;
- }
- RadioButton* peer = static_cast<RadioButton*>(*i);
- peer->SetChecked(false);
- }
- }
- }
- }
- Checkbox::SetChecked(checked);
-}
-
-void RadioButton::PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint) {
- canvas->DrawCircle(gfx::PointF(image()->bounds().CenterPoint()),
- image()->width() / 2 + .5f, paint);
-}
-
const char* RadioButton::GetClassName() const {
return kViewClassName;
}
@@ -152,16 +118,43 @@ ui::NativeTheme::Part RadioButton::GetThemePart() const {
return ui::NativeTheme::kRadio;
}
-gfx::ImageSkia RadioButton::GetImage(ButtonState for_state) const {
- if (!UseMd())
- return Checkbox::GetImage(for_state);
+void RadioButton::SetChecked(bool checked) {
+ if (checked == RadioButton::checked())
+ return;
+ if (checked) {
+ // We can't just get the root view here because sometimes the radio
+ // button isn't attached to a root view (e.g., if it's part of a tab page
+ // that is currently not active).
+ View* container = parent();
+ while (container && container->parent())
+ container = container->parent();
+ if (container) {
+ Views other;
+ container->GetViewsInGroup(GetGroup(), &other);
+ for (Views::iterator i(other.begin()); i != other.end(); ++i) {
+ if (*i != this) {
+ if (strcmp((*i)->GetClassName(), kViewClassName)) {
+ NOTREACHED() << "radio-button-nt has same group as other non "
+ "radio-button-nt views.";
+ continue;
+ }
+ RadioButton* peer = static_cast<RadioButton*>(*i);
+ peer->SetChecked(false);
+ }
+ }
+ }
+ }
+ Checkbox::SetChecked(checked);
+}
+
+void RadioButton::PaintFocusRing(gfx::Canvas* canvas, const SkPaint& paint) {
+ canvas->DrawCircle(gfx::RectF(image()->bounds()).CenterPoint(),
+ image()->width() / 2, paint);
+}
- return gfx::CreateVectorIcon(
- checked() ? gfx::VectorIconId::RADIO_BUTTON_ACTIVE
- : gfx::VectorIconId::RADIO_BUTTON_NORMAL,
- 16, GetNativeTheme()->GetSystemColor(
- checked() ? ui::NativeTheme::kColorId_FocusedBorderColor
- : ui::NativeTheme::kColorId_UnfocusedBorderColor));
+gfx::VectorIconId RadioButton::GetVectorIconId() const {
+ return checked() ? gfx::VectorIconId::RADIO_BUTTON_ACTIVE
+ : gfx::VectorIconId::RADIO_BUTTON_NORMAL;
}
} // namespace views
« no previous file with comments | « ui/views/controls/button/radio_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698