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

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

Issue 2765883004: Implement Harmony typography spec. (Closed)
Patch Set: respond to comments Created 3 years, 8 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
« no previous file with comments | « ui/gfx/platform_font.h ('k') | ui/views/controls/label.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void LabelButton::SetFocusPainter(std::unique_ptr<Painter> focus_painter) { 227 void LabelButton::SetFocusPainter(std::unique_ptr<Painter> focus_painter) {
228 focus_painter_ = std::move(focus_painter); 228 focus_painter_ = std::move(focus_painter);
229 } 229 }
230 230
231 gfx::Size LabelButton::GetPreferredSize() const { 231 gfx::Size LabelButton::GetPreferredSize() const {
232 if (cached_preferred_size_valid_) 232 if (cached_preferred_size_valid_)
233 return cached_preferred_size_; 233 return cached_preferred_size_;
234 234
235 // Use a temporary label copy for sizing to avoid calculation side-effects. 235 // Use a temporary label copy for sizing to avoid calculation side-effects.
236 Label label(GetText(), {label_->font_list()}); 236 Label label(GetText(), {label_->font_list()});
237 label.SetLineHeight(label_->line_height());
237 label.SetShadows(label_->shadows()); 238 label.SetShadows(label_->shadows());
238 239
239 if (style_ == STYLE_BUTTON && PlatformStyle::kDefaultLabelButtonHasBoldFont) { 240 if (style_ == STYLE_BUTTON && PlatformStyle::kDefaultLabelButtonHasBoldFont) {
240 // Some text appears wider when rendered normally than when rendered bold. 241 // Some text appears wider when rendered normally than when rendered bold.
241 // Accommodate the widest, as buttons may show bold and shouldn't resize. 242 // Accommodate the widest, as buttons may show bold and shouldn't resize.
242 const int current_width = label.GetPreferredSize().width(); 243 const int current_width = label.GetPreferredSize().width();
243 label.SetFontList(cached_bold_font_list_); 244 label.SetFontList(cached_bold_font_list_);
244 if (label.GetPreferredSize().width() < current_width) 245 if (label.GetPreferredSize().width() < current_width)
245 label.SetFontList(label_->font_list()); 246 label.SetFontList(label_->font_list());
246 } 247 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 : PlatformStyle::TextColorForButton(button_state_colors_, *this); 601 : PlatformStyle::TextColorForButton(button_state_colors_, *this);
601 if (state() != STATE_DISABLED && label_->enabled_color() != color) 602 if (state() != STATE_DISABLED && label_->enabled_color() != color)
602 label_->SetEnabledColor(color); 603 label_->SetEnabledColor(color);
603 } 604 }
604 605
605 bool LabelButton::UseFloodFillInkDrop() const { 606 bool LabelButton::UseFloodFillInkDrop() const {
606 return !GetText().empty(); 607 return !GetText().empty();
607 } 608 }
608 609
609 } // namespace views 610 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/platform_font.h ('k') | ui/views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698