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 <utility> |
| 8 |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "ui/gfx/animation/throb_animation.h" | 11 #include "ui/gfx/animation/throb_animation.h" |
10 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
11 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
12 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
13 #include "ui/gfx/geometry/vector2d.h" | 15 #include "ui/gfx/geometry/vector2d.h" |
14 #include "ui/native_theme/native_theme.h" | 16 #include "ui/native_theme/native_theme.h" |
15 #include "ui/views/background.h" | 17 #include "ui/views/background.h" |
16 #include "ui/views/controls/button/label_button_border.h" | 18 #include "ui/views/controls/button/label_button_border.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 211 |
210 void LabelButton::SetImageLabelSpacing(int spacing) { | 212 void LabelButton::SetImageLabelSpacing(int spacing) { |
211 if (spacing == image_label_spacing_) | 213 if (spacing == image_label_spacing_) |
212 return; | 214 return; |
213 image_label_spacing_ = spacing; | 215 image_label_spacing_ = spacing; |
214 ResetCachedPreferredSize(); | 216 ResetCachedPreferredSize(); |
215 InvalidateLayout(); | 217 InvalidateLayout(); |
216 } | 218 } |
217 | 219 |
218 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 220 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
219 focus_painter_ = focus_painter.Pass(); | 221 focus_painter_ = std::move(focus_painter); |
220 } | 222 } |
221 | 223 |
222 gfx::Size LabelButton::GetPreferredSize() const { | 224 gfx::Size LabelButton::GetPreferredSize() const { |
223 if (cached_preferred_size_valid_) | 225 if (cached_preferred_size_valid_) |
224 return cached_preferred_size_; | 226 return cached_preferred_size_; |
225 | 227 |
226 // Use a temporary label copy for sizing to avoid calculation side-effects. | 228 // Use a temporary label copy for sizing to avoid calculation side-effects. |
227 Label label(GetText(), cached_normal_font_list_); | 229 Label label(GetText(), cached_normal_font_list_); |
228 label.SetShadows(label_->shadows()); | 230 label.SetShadows(label_->shadows()); |
229 label.SetMultiLine(GetTextMultiLine()); | 231 label.SetMultiLine(GetTextMultiLine()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 CustomButton::EnableCanvasFlippingForRTLUI(flip); | 348 CustomButton::EnableCanvasFlippingForRTLUI(flip); |
347 image_->EnableCanvasFlippingForRTLUI(flip); | 349 image_->EnableCanvasFlippingForRTLUI(flip); |
348 } | 350 } |
349 | 351 |
350 scoped_ptr<LabelButtonBorder> LabelButton::CreateDefaultBorder() const { | 352 scoped_ptr<LabelButtonBorder> LabelButton::CreateDefaultBorder() const { |
351 return PlatformStyle::CreateLabelButtonBorder(style()); | 353 return PlatformStyle::CreateLabelButtonBorder(style()); |
352 } | 354 } |
353 | 355 |
354 void LabelButton::SetBorder(scoped_ptr<Border> border) { | 356 void LabelButton::SetBorder(scoped_ptr<Border> border) { |
355 border_is_themed_border_ = false; | 357 border_is_themed_border_ = false; |
356 View::SetBorder(border.Pass()); | 358 View::SetBorder(std::move(border)); |
357 ResetCachedPreferredSize(); | 359 ResetCachedPreferredSize(); |
358 } | 360 } |
359 | 361 |
360 gfx::Rect LabelButton::GetChildAreaBounds() { | 362 gfx::Rect LabelButton::GetChildAreaBounds() { |
361 return GetLocalBounds(); | 363 return GetLocalBounds(); |
362 } | 364 } |
363 | 365 |
364 void LabelButton::OnPaint(gfx::Canvas* canvas) { | 366 void LabelButton::OnPaint(gfx::Canvas* canvas) { |
365 View::OnPaint(canvas); | 367 View::OnPaint(canvas); |
366 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); | 368 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 GetExtraParams(params); | 512 GetExtraParams(params); |
511 return ui::NativeTheme::kHovered; | 513 return ui::NativeTheme::kHovered; |
512 } | 514 } |
513 | 515 |
514 void LabelButton::ResetCachedPreferredSize() { | 516 void LabelButton::ResetCachedPreferredSize() { |
515 cached_preferred_size_valid_ = false; | 517 cached_preferred_size_valid_ = false; |
516 cached_preferred_size_ = gfx::Size(); | 518 cached_preferred_size_ = gfx::Size(); |
517 } | 519 } |
518 | 520 |
519 } // namespace views | 521 } // namespace views |
OLD | NEW |