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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // change from the default style. | 209 // change from the default style. |
210 DCHECK_EQ(style, STYLE_BUTTON); | 210 DCHECK_EQ(style, STYLE_BUTTON); |
211 DCHECK_EQ(style_, STYLE_TEXTBUTTON); | 211 DCHECK_EQ(style_, STYLE_TEXTBUTTON); |
212 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget."; | 212 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget."; |
213 | 213 |
214 style_ = style; | 214 style_ = style; |
215 | 215 |
216 SetFocusPainter(nullptr); | 216 SetFocusPainter(nullptr); |
217 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 217 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
218 Button::ConfigureDefaultFocus(this); | 218 Button::ConfigureDefaultFocus(this); |
| 219 set_request_focus_on_press(true); |
219 SetMinSize(gfx::Size(PlatformStyle::kMinLabelButtonWidth, | 220 SetMinSize(gfx::Size(PlatformStyle::kMinLabelButtonWidth, |
220 PlatformStyle::kMinLabelButtonHeight)); | 221 PlatformStyle::kMinLabelButtonHeight)); |
221 | 222 |
222 // Themed borders will be set once the button is added to a Widget, since that | 223 // Themed borders will be set once the button is added to a Widget, since that |
223 // provides the value of GetNativeTheme(). | 224 // provides the value of GetNativeTheme(). |
224 } | 225 } |
225 | 226 |
226 void LabelButton::SetImageLabelSpacing(int spacing) { | 227 void LabelButton::SetImageLabelSpacing(int spacing) { |
227 if (spacing == image_label_spacing_) | 228 if (spacing == image_label_spacing_) |
228 return; | 229 return; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 void LabelButton::ResetLabelEnabledColor() { | 568 void LabelButton::ResetLabelEnabledColor() { |
568 const SkColor color = | 569 const SkColor color = |
569 explicitly_set_colors_[state()] | 570 explicitly_set_colors_[state()] |
570 ? button_state_colors_[state()] | 571 ? button_state_colors_[state()] |
571 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 572 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
572 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 573 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
573 label_->SetEnabledColor(color); | 574 label_->SetEnabledColor(color); |
574 } | 575 } |
575 | 576 |
576 } // namespace views | 577 } // namespace views |
OLD | NEW |