| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 void LabelButton::SetTextShadows(const gfx::ShadowValues& shadows) { | 154 void LabelButton::SetTextShadows(const gfx::ShadowValues& shadows) { |
| 155 label_->SetShadows(shadows); | 155 label_->SetShadows(shadows); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void LabelButton::SetTextSubpixelRenderingEnabled(bool enabled) { | 158 void LabelButton::SetTextSubpixelRenderingEnabled(bool enabled) { |
| 159 label_->SetSubpixelRenderingEnabled(enabled); | 159 label_->SetSubpixelRenderingEnabled(enabled); |
| 160 } | 160 } |
| 161 | 161 |
| 162 const gfx::FontList& LabelButton::GetFontList() const { | 162 void LabelButton::SetFontListDeprecated(const gfx::FontList& font_list) { |
| 163 return label_->font_list(); | 163 SetFontList(font_list); |
| 164 } | |
| 165 | |
| 166 void LabelButton::SetFontList(const gfx::FontList& font_list) { | |
| 167 cached_normal_font_list_ = font_list; | |
| 168 if (PlatformStyle::kDefaultLabelButtonHasBoldFont) { | |
| 169 cached_bold_font_list_ = font_list.DeriveWithWeight( | |
| 170 GetValueBolderThan(font_list.GetFontWeight())); | |
| 171 if (is_default_) { | |
| 172 label_->SetFontList(cached_bold_font_list_); | |
| 173 return; | |
| 174 } | |
| 175 } | |
| 176 label_->SetFontList(cached_normal_font_list_); | |
| 177 } | 164 } |
| 178 | 165 |
| 179 void LabelButton::AdjustFontSize(int font_size_delta) { | 166 void LabelButton::AdjustFontSize(int font_size_delta) { |
| 180 LabelButton::SetFontList(GetFontList().DeriveWithSizeDelta(font_size_delta)); | 167 LabelButton::SetFontList( |
| 168 label()->font_list().DeriveWithSizeDelta(font_size_delta)); |
| 181 } | 169 } |
| 182 | 170 |
| 183 void LabelButton::SetElideBehavior(gfx::ElideBehavior elide_behavior) { | 171 void LabelButton::SetElideBehavior(gfx::ElideBehavior elide_behavior) { |
| 184 label_->SetElideBehavior(elide_behavior); | 172 label_->SetElideBehavior(elide_behavior); |
| 185 } | 173 } |
| 186 | 174 |
| 187 void LabelButton::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { | 175 void LabelButton::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { |
| 188 DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment); | 176 DCHECK_NE(gfx::ALIGN_TO_HEAD, alignment); |
| 189 horizontal_alignment_ = alignment; | 177 horizontal_alignment_ = alignment; |
| 190 InvalidateLayout(); | 178 InvalidateLayout(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 void LabelButton::SetBorder(std::unique_ptr<Border> border) { | 374 void LabelButton::SetBorder(std::unique_ptr<Border> border) { |
| 387 border_is_themed_border_ = false; | 375 border_is_themed_border_ = false; |
| 388 View::SetBorder(std::move(border)); | 376 View::SetBorder(std::move(border)); |
| 389 ResetCachedPreferredSize(); | 377 ResetCachedPreferredSize(); |
| 390 } | 378 } |
| 391 | 379 |
| 392 gfx::Rect LabelButton::GetChildAreaBounds() { | 380 gfx::Rect LabelButton::GetChildAreaBounds() { |
| 393 return GetLocalBounds(); | 381 return GetLocalBounds(); |
| 394 } | 382 } |
| 395 | 383 |
| 384 void LabelButton::SetFontList(const gfx::FontList& font_list) { |
| 385 cached_normal_font_list_ = font_list; |
| 386 if (PlatformStyle::kDefaultLabelButtonHasBoldFont) { |
| 387 cached_bold_font_list_ = font_list.DeriveWithWeight( |
| 388 GetValueBolderThan(font_list.GetFontWeight())); |
| 389 if (is_default_) { |
| 390 label_->SetFontList(cached_bold_font_list_); |
| 391 return; |
| 392 } |
| 393 } |
| 394 label_->SetFontList(cached_normal_font_list_); |
| 395 } |
| 396 |
| 396 void LabelButton::OnPaint(gfx::Canvas* canvas) { | 397 void LabelButton::OnPaint(gfx::Canvas* canvas) { |
| 397 View::OnPaint(canvas); | 398 View::OnPaint(canvas); |
| 398 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); | 399 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); |
| 399 } | 400 } |
| 400 | 401 |
| 401 void LabelButton::OnFocus() { | 402 void LabelButton::OnFocus() { |
| 402 CustomButton::OnFocus(); | 403 CustomButton::OnFocus(); |
| 403 // Typically the border renders differently when focused. | 404 // Typically the border renders differently when focused. |
| 404 SchedulePaint(); | 405 SchedulePaint(); |
| 405 } | 406 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 604 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 604 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 605 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 605 label_->SetEnabledColor(color); | 606 label_->SetEnabledColor(color); |
| 606 } | 607 } |
| 607 | 608 |
| 608 bool LabelButton::UseFloodFillInkDrop() const { | 609 bool LabelButton::UseFloodFillInkDrop() const { |
| 609 return !GetText().empty(); | 610 return !GetText().empty(); |
| 610 } | 611 } |
| 611 | 612 |
| 612 } // namespace views | 613 } // namespace views |
| OLD | NEW |