Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/menu_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698