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

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

Issue 15061006: views: Switch Checkbox over to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disabled images Created 7 years, 7 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
Index: ui/views/controls/button/label_button.cc
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index bc1c06351ee9ed514c0c2f62b20c4e6cec259a59..971439af7eab2dbb67f43b656f9a7d37411c73ec 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -68,7 +68,7 @@ const gfx::ImageSkia& LabelButton::GetImage(ButtonState for_state) {
void LabelButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) {
button_state_images_[for_state] = image;
- image_->SetImage(GetImage(state()));
+ UpdateImage();
}
const string16& LabelButton::GetText() const {
@@ -194,6 +194,21 @@ const char* LabelButton::GetClassName() const {
return kViewClassName;
}
+void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
+ params->button.checked = false;
+ params->button.indeterminate = false;
+ params->button.is_default = is_default_;
+ params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
+ params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
+ params->button.classic_state = 0;
+ params->button.background_color = GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_ButtonBackgroundColor);
+}
+
+void LabelButton::UpdateImage() {
+ image_->SetImage(GetImage(state()));
+}
+
void LabelButton::ResetColorsFromNativeTheme() {
const ui::NativeTheme* theme = GetNativeTheme();
SkColor colors[STATE_COUNT] = {
@@ -222,7 +237,7 @@ void LabelButton::ResetColorsFromNativeTheme() {
void LabelButton::StateChanged() {
const gfx::Size previous_image_size(image_->GetPreferredSize());
- image_->SetImage(GetImage(state()));
+ UpdateImage();
const SkColor color = button_state_colors_[state()];
if (state() != STATE_DISABLED && label_->enabled_color() != color)
label_->SetEnabledColor(color);
@@ -292,7 +307,7 @@ gfx::Rect LabelButton::GetThemePaintRect() const {
ui::NativeTheme::State LabelButton::GetThemeState(
ui::NativeTheme::ExtraParams* params) const {
GetExtraParams(params);
- switch(state()) {
+ switch (state()) {
case STATE_NORMAL: return ui::NativeTheme::kNormal;
case STATE_HOVERED: return ui::NativeTheme::kHovered;
case STATE_PRESSED: return ui::NativeTheme::kPressed;
@@ -325,15 +340,4 @@ ui::NativeTheme::State LabelButton::GetForegroundThemeState(
return ui::NativeTheme::kHovered;
}
-void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
- params->button.checked = false;
- params->button.indeterminate = false;
- params->button.is_default = is_default_;
- params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
- params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
- params->button.classic_state = 0;
- params->button.background_color = GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_ButtonBackgroundColor);
-}
-
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698