| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if (is_default == is_default_) | 174 if (is_default == is_default_) |
| 175 return; | 175 return; |
| 176 is_default_ = is_default; | 176 is_default_ = is_default; |
| 177 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); | 177 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); |
| 178 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); | 178 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); |
| 179 | 179 |
| 180 // STYLE_BUTTON uses bold text to indicate default buttons. | 180 // STYLE_BUTTON uses bold text to indicate default buttons. |
| 181 if (style_ == STYLE_BUTTON) { | 181 if (style_ == STYLE_BUTTON) { |
| 182 label_->SetFontList( | 182 label_->SetFontList( |
| 183 is_default ? cached_bold_font_list_ : cached_normal_font_list_); | 183 is_default ? cached_bold_font_list_ : cached_normal_font_list_); |
| 184 // Usually this function is called before |this| is attached to a widget, | 184 InvalidateLayout(); |
| 185 // but in the cases where |this| is already shown, we need to re-layout | |
| 186 // because font boldness affects the label's size. | |
| 187 if (GetWidget()) | |
| 188 Layout(); | |
| 189 } | 185 } |
| 190 } | 186 } |
| 191 | 187 |
| 192 void LabelButton::SetStyle(ButtonStyle style) { | 188 void LabelButton::SetStyle(ButtonStyle style) { |
| 193 // All callers currently pass STYLE_BUTTON, and should only call this once, to | 189 // All callers currently pass STYLE_BUTTON, and should only call this once, to |
| 194 // change from the default style. | 190 // change from the default style. |
| 195 DCHECK_EQ(style, STYLE_BUTTON); | 191 DCHECK_EQ(style, STYLE_BUTTON); |
| 196 DCHECK_EQ(style_, STYLE_TEXTBUTTON); | 192 DCHECK_EQ(style_, STYLE_TEXTBUTTON); |
| 197 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget."; | 193 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget."; |
| 198 | 194 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 GetExtraParams(params); | 505 GetExtraParams(params); |
| 510 return ui::NativeTheme::kHovered; | 506 return ui::NativeTheme::kHovered; |
| 511 } | 507 } |
| 512 | 508 |
| 513 void LabelButton::ResetCachedPreferredSize() { | 509 void LabelButton::ResetCachedPreferredSize() { |
| 514 cached_preferred_size_valid_ = false; | 510 cached_preferred_size_valid_ = false; |
| 515 cached_preferred_size_ = gfx::Size(); | 511 cached_preferred_size_ = gfx::Size(); |
| 516 } | 512 } |
| 517 | 513 |
| 518 } // namespace views | 514 } // namespace views |
| OLD | NEW |