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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 void LabelButton::SetIsDefault(bool is_default) { | 112 void LabelButton::SetIsDefault(bool is_default) { |
| 113 if (is_default == is_default_) | 113 if (is_default == is_default_) |
| 114 return; | 114 return; |
| 115 is_default_ = is_default; | 115 is_default_ = is_default; |
| 116 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); | 116 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); |
| 117 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); | 117 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void LabelButton::SetStyle(ButtonStyle style) { | 120 void LabelButton::SetStyle(ButtonStyle style) { |
| 121 style_ = style; | 121 style_ = style; |
| 122 set_border(new LabelButtonBorder(style)); | 122 set_border(new LabelButtonBorder(style)); |
|
tfarina
2013/04/04 22:58:46
things are getting messier here, inconsistent use
msw
2013/04/04 23:34:45
Done; I changed the one use of |style_| in this fu
| |
| 123 // Inset the button focus rect from the actual border; roughly match Windows. | 123 // Inset the button focus rect from the actual border; roughly match Windows. |
| 124 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON) | 124 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON) |
|
tfarina
2013/04/04 22:58:46
should we start refactoring here, and have a singl
msw
2013/04/04 23:34:45
I think it's okay for now, but might switch it up
| |
| 125 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); | 125 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); |
| 126 if (style == STYLE_BUTTON || style_ == STYLE_NATIVE_TEXTBUTTON) | 126 if (style == STYLE_BUTTON || style_ == STYLE_NATIVE_TEXTBUTTON) |
| 127 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 127 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 128 if (style == STYLE_NATIVE_TEXTBUTTON) | |
| 129 set_focusable(true); | |
| 128 if (style == STYLE_BUTTON) { | 130 if (style == STYLE_BUTTON) { |
| 129 set_min_size(gfx::Size(70, 31)); | 131 set_min_size(gfx::Size(70, 31)); |
| 130 const SkColor color = GetNativeTheme()->GetSystemColor( | 132 const SkColor color = GetNativeTheme()->GetSystemColor( |
| 131 ui::NativeTheme::kColorId_WindowBackground); | 133 ui::NativeTheme::kColorId_WindowBackground); |
| 132 label_->SetShadowColors(color, color); | 134 label_->SetShadowColors(color, color); |
| 133 label_->SetShadowOffset(0, 1); | 135 label_->SetShadowOffset(0, 1); |
| 134 } | 136 } |
| 135 // Invalidate the layout to pickup the new insets from the border. | 137 // Invalidate the layout to pickup the new insets from the border. |
| 136 InvalidateLayout(); | 138 InvalidateLayout(); |
| 137 ResetColorsFromNativeTheme(); | 139 ResetColorsFromNativeTheme(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 params->button.indeterminate = false; | 307 params->button.indeterminate = false; |
| 306 params->button.is_default = is_default_; | 308 params->button.is_default = is_default_; |
| 307 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); | 309 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); |
| 308 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; | 310 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; |
| 309 params->button.classic_state = 0; | 311 params->button.classic_state = 0; |
| 310 params->button.background_color = GetNativeTheme()->GetSystemColor( | 312 params->button.background_color = GetNativeTheme()->GetSystemColor( |
| 311 ui::NativeTheme::kColorId_TextButtonBackgroundColor); | 313 ui::NativeTheme::kColorId_TextButtonBackgroundColor); |
| 312 } | 314 } |
| 313 | 315 |
| 314 } // namespace views | 316 } // namespace views |
| OLD | NEW |