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/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/base/animation/throb_animation.h" | 9 #include "ui/base/animation/throb_animation.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 return ui::NativeTheme::kPushButton; | 289 return ui::NativeTheme::kPushButton; |
| 290 } | 290 } |
| 291 | 291 |
| 292 gfx::Rect LabelButton::GetThemePaintRect() const { | 292 gfx::Rect LabelButton::GetThemePaintRect() const { |
| 293 return GetLocalBounds(); | 293 return GetLocalBounds(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 ui::NativeTheme::State LabelButton::GetThemeState( | 296 ui::NativeTheme::State LabelButton::GetThemeState( |
| 297 ui::NativeTheme::ExtraParams* params) const { | 297 ui::NativeTheme::ExtraParams* params) const { |
| 298 GetExtraParams(params); | 298 GetExtraParams(params); |
| 299 switch(state()) { | 299 switch (state()) { |
| 300 case STATE_NORMAL: return ui::NativeTheme::kNormal; | 300 case STATE_NORMAL: return ui::NativeTheme::kNormal; |
| 301 case STATE_HOVERED: return ui::NativeTheme::kHovered; | 301 case STATE_HOVERED: return ui::NativeTheme::kHovered; |
| 302 case STATE_PRESSED: return ui::NativeTheme::kPressed; | 302 case STATE_PRESSED: return ui::NativeTheme::kPressed; |
| 303 case STATE_DISABLED: return ui::NativeTheme::kDisabled; | 303 case STATE_DISABLED: return ui::NativeTheme::kDisabled; |
| 304 case STATE_TOGGLED: return ui::NativeTheme::kToggled; | |
|
msw
2013/05/16 22:40:05
nit: I'd prefer this to come before STATE_DISABLED
tfarina
2013/05/18 00:54:08
ditto.
| |
| 304 case STATE_COUNT: NOTREACHED() << "Unknown state: " << state(); | 305 case STATE_COUNT: NOTREACHED() << "Unknown state: " << state(); |
| 305 } | 306 } |
| 306 return ui::NativeTheme::kNormal; | 307 return ui::NativeTheme::kNormal; |
| 307 } | 308 } |
| 308 | 309 |
| 309 const ui::Animation* LabelButton::GetThemeAnimation() const { | 310 const ui::Animation* LabelButton::GetThemeAnimation() const { |
| 310 #if defined(OS_WIN) | 311 #if defined(OS_WIN) |
| 311 if (style() == STYLE_NATIVE_TEXTBUTTON && | 312 if (style() == STYLE_NATIVE_TEXTBUTTON && |
| 312 GetNativeTheme() == ui::NativeThemeWin::instance()) { | 313 GetNativeTheme() == ui::NativeThemeWin::instance()) { |
| 313 return ui::NativeThemeWin::instance()->IsThemingActive() ? | 314 return ui::NativeThemeWin::instance()->IsThemingActive() ? |
| 314 hover_animation_.get() : NULL; | 315 hover_animation_.get() : NULL; |
| 315 } | 316 } |
| 316 #endif | 317 #endif |
| 317 return hover_animation_.get(); | 318 return hover_animation_.get(); |
| 318 } | 319 } |
| 319 | 320 |
| 320 ui::NativeTheme::State LabelButton::GetBackgroundThemeState( | 321 ui::NativeTheme::State LabelButton::GetBackgroundThemeState( |
| 321 ui::NativeTheme::ExtraParams* params) const { | 322 ui::NativeTheme::ExtraParams* params) const { |
| 322 GetExtraParams(params); | 323 GetExtraParams(params); |
| 323 return ui::NativeTheme::kNormal; | 324 return ui::NativeTheme::kNormal; |
| 324 } | 325 } |
| 325 | 326 |
| 326 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 327 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
| 327 ui::NativeTheme::ExtraParams* params) const { | 328 ui::NativeTheme::ExtraParams* params) const { |
| 328 GetExtraParams(params); | 329 GetExtraParams(params); |
| 329 return ui::NativeTheme::kHovered; | 330 return ui::NativeTheme::kHovered; |
| 330 } | 331 } |
| 331 | 332 |
| 332 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 333 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
|
msw
2013/05/16 22:40:05
Move this impl to match the changed decl ordering.
tfarina
2013/05/18 00:54:08
Done.
| |
| 333 params->button.checked = false; | 334 params->button.checked = false; |
| 334 params->button.indeterminate = false; | 335 params->button.indeterminate = false; |
| 335 params->button.is_default = is_default_; | 336 params->button.is_default = is_default_; |
| 336 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); | 337 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); |
| 337 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; | 338 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; |
| 338 params->button.classic_state = 0; | 339 params->button.classic_state = 0; |
| 339 params->button.background_color = GetNativeTheme()->GetSystemColor( | 340 params->button.background_color = GetNativeTheme()->GetSystemColor( |
| 340 ui::NativeTheme::kColorId_TextButtonBackgroundColor); | 341 ui::NativeTheme::kColorId_TextButtonBackgroundColor); |
| 341 } | 342 } |
| 342 | 343 |
| 343 } // namespace views | 344 } // namespace views |
| OLD | NEW |