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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 27 matching lines...) Expand all
38 38
39 const gfx::FontList& GetDefaultNormalFontList() { 39 const gfx::FontList& GetDefaultNormalFontList() {
40 static base::LazyInstance<gfx::FontList>::Leaky font_list = 40 static base::LazyInstance<gfx::FontList>::Leaky font_list =
41 LAZY_INSTANCE_INITIALIZER; 41 LAZY_INSTANCE_INITIALIZER;
42 return font_list.Get(); 42 return font_list.Get();
43 } 43 }
44 44
45 const gfx::FontList& GetDefaultBoldFontList() { 45 const gfx::FontList& GetDefaultBoldFontList() {
46 static base::LazyInstance<gfx::FontList>::Leaky font_list = 46 static base::LazyInstance<gfx::FontList>::Leaky font_list =
47 LAZY_INSTANCE_INITIALIZER; 47 LAZY_INSTANCE_INITIALIZER;
48 if ((font_list.Get().GetFontStyle() & gfx::Font::BOLD) == 0) { 48 if (font_list.Get().GetFontWeight() != gfx::Font::WEIGHT_BOLD) {
msw 2016/03/22 01:53:44 Hmm, I wonder if this should be < (or something sm
Mikus 2016/03/22 14:19:51 Done.
49 font_list.Get() = font_list.Get(). 49 font_list.Get() = font_list.Get().DeriveWithWeight(gfx::Font::WEIGHT_BOLD);
50 DeriveWithStyle(font_list.Get().GetFontStyle() | gfx::Font::BOLD); 50 DCHECK_EQ(font_list.Get().GetFontWeight(), gfx::Font::WEIGHT_BOLD);
51 DCHECK_NE(font_list.Get().GetFontStyle() & gfx::Font::BOLD, 0);
52 } 51 }
53 return font_list.Get(); 52 return font_list.Get();
54 } 53 }
55 54
56 // Ink drop container view that does not capture any events. 55 // Ink drop container view that does not capture any events.
57 class InkDropContainerView : public views::View { 56 class InkDropContainerView : public views::View {
58 public: 57 public:
59 InkDropContainerView() {} 58 InkDropContainerView() {}
60 59
61 // View: 60 // View:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void LabelButton::SetTextSubpixelRenderingEnabled(bool enabled) { 156 void LabelButton::SetTextSubpixelRenderingEnabled(bool enabled) {
158 label_->SetSubpixelRenderingEnabled(enabled); 157 label_->SetSubpixelRenderingEnabled(enabled);
159 } 158 }
160 159
161 const gfx::FontList& LabelButton::GetFontList() const { 160 const gfx::FontList& LabelButton::GetFontList() const {
162 return label_->font_list(); 161 return label_->font_list();
163 } 162 }
164 163
165 void LabelButton::SetFontList(const gfx::FontList& font_list) { 164 void LabelButton::SetFontList(const gfx::FontList& font_list) {
166 cached_normal_font_list_ = font_list; 165 cached_normal_font_list_ = font_list;
167 cached_bold_font_list_ = font_list.DeriveWithStyle( 166 cached_bold_font_list_ = font_list.DeriveWithWeight(gfx::Font::WEIGHT_BOLD);
168 font_list.GetFontStyle() | gfx::Font::BOLD);
169 167
170 // STYLE_BUTTON uses bold text to indicate default buttons. 168 // STYLE_BUTTON uses bold text to indicate default buttons.
171 label_->SetFontList( 169 label_->SetFontList(
172 style_ == STYLE_BUTTON && is_default_ ? 170 style_ == STYLE_BUTTON && is_default_ ?
173 cached_bold_font_list_ : cached_normal_font_list_); 171 cached_bold_font_list_ : cached_normal_font_list_);
174 } 172 }
175 173
176 void LabelButton::SetElideBehavior(gfx::ElideBehavior elide_behavior) { 174 void LabelButton::SetElideBehavior(gfx::ElideBehavior elide_behavior) {
177 label_->SetElideBehavior(elide_behavior); 175 label_->SetElideBehavior(elide_behavior);
178 } 176 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 GetExtraParams(params); 560 GetExtraParams(params);
563 return ui::NativeTheme::kHovered; 561 return ui::NativeTheme::kHovered;
564 } 562 }
565 563
566 void LabelButton::ResetCachedPreferredSize() { 564 void LabelButton::ResetCachedPreferredSize() {
567 cached_preferred_size_valid_ = false; 565 cached_preferred_size_valid_ = false;
568 cached_preferred_size_ = gfx::Size(); 566 cached_preferred_size_ = gfx::Size();
569 } 567 }
570 568
571 } // namespace views 569 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698