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/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/animation/throb_animation.h" | 10 #include "ui/gfx/animation/throb_animation.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (style == STYLE_BUTTON) | 166 if (style == STYLE_BUTTON) |
167 set_min_size(gfx::Size(70, 33)); | 167 set_min_size(gfx::Size(70, 33)); |
168 | 168 |
169 OnNativeThemeChanged(GetNativeTheme()); | 169 OnNativeThemeChanged(GetNativeTheme()); |
170 } | 170 } |
171 | 171 |
172 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 172 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
173 focus_painter_ = focus_painter.Pass(); | 173 focus_painter_ = focus_painter.Pass(); |
174 } | 174 } |
175 | 175 |
176 gfx::Size LabelButton::GetPreferredSize() { | 176 gfx::Size LabelButton::GetPreferredSize() const { |
177 // Use a temporary label copy for sizing to avoid calculation side-effects. | 177 // Use a temporary label copy for sizing to avoid calculation side-effects. |
178 Label label(GetText(), cached_normal_font_list_); | 178 Label label(GetText(), cached_normal_font_list_); |
179 label.SetMultiLine(GetTextMultiLine()); | 179 label.SetMultiLine(GetTextMultiLine()); |
180 | 180 |
181 if (style() == STYLE_BUTTON) { | 181 if (style() == STYLE_BUTTON) { |
182 // Some text appears wider when rendered normally than when rendered bold. | 182 // Some text appears wider when rendered normally than when rendered bold. |
183 // Accommodate the widest, as buttons may show bold and shouldn't resize. | 183 // Accommodate the widest, as buttons may show bold and shouldn't resize. |
184 const int current_width = label.GetPreferredSize().width(); | 184 const int current_width = label.GetPreferredSize().width(); |
185 label.SetFontList(cached_bold_font_list_); | 185 label.SetFontList(cached_bold_font_list_); |
186 if (label.GetPreferredSize().width() < current_width) | 186 if (label.GetPreferredSize().width() < current_width) |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 return ui::NativeTheme::kNormal; | 428 return ui::NativeTheme::kNormal; |
429 } | 429 } |
430 | 430 |
431 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 431 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
432 ui::NativeTheme::ExtraParams* params) const { | 432 ui::NativeTheme::ExtraParams* params) const { |
433 GetExtraParams(params); | 433 GetExtraParams(params); |
434 return ui::NativeTheme::kHovered; | 434 return ui::NativeTheme::kHovered; |
435 } | 435 } |
436 | 436 |
437 } // namespace views | 437 } // namespace views |
OLD | NEW |