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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 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/views/controls/button/label_button.h ('k') | ui/views/controls/button/label_button_border.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "ui/gfx/animation/throb_animation.h" 15 #include "ui/gfx/animation/throb_animation.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/font_list.h" 18 #include "ui/gfx/font_list.h"
18 #include "ui/gfx/geometry/vector2d.h" 19 #include "ui/gfx/geometry/vector2d.h"
19 #include "ui/native_theme/native_theme.h" 20 #include "ui/native_theme/native_theme.h"
20 #include "ui/views/animation/flood_fill_ink_drop_animation.h" 21 #include "ui/views/animation/flood_fill_ink_drop_animation.h"
21 #include "ui/views/animation/ink_drop_hover.h" 22 #include "ui/views/animation/ink_drop_hover.h"
22 #include "ui/views/background.h" 23 #include "ui/views/background.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 227 }
227 228
228 void LabelButton::SetImageLabelSpacing(int spacing) { 229 void LabelButton::SetImageLabelSpacing(int spacing) {
229 if (spacing == image_label_spacing_) 230 if (spacing == image_label_spacing_)
230 return; 231 return;
231 image_label_spacing_ = spacing; 232 image_label_spacing_ = spacing;
232 ResetCachedPreferredSize(); 233 ResetCachedPreferredSize();
233 InvalidateLayout(); 234 InvalidateLayout();
234 } 235 }
235 236
236 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { 237 void LabelButton::SetFocusPainter(std::unique_ptr<Painter> focus_painter) {
237 focus_painter_ = std::move(focus_painter); 238 focus_painter_ = std::move(focus_painter);
238 } 239 }
239 240
240 gfx::Size LabelButton::GetPreferredSize() const { 241 gfx::Size LabelButton::GetPreferredSize() const {
241 if (cached_preferred_size_valid_) 242 if (cached_preferred_size_valid_)
242 return cached_preferred_size_; 243 return cached_preferred_size_;
243 244
244 // Use a temporary label copy for sizing to avoid calculation side-effects. 245 // Use a temporary label copy for sizing to avoid calculation side-effects.
245 Label label(GetText(), cached_normal_font_list_); 246 Label label(GetText(), cached_normal_font_list_);
246 label.SetShadows(label_->shadows()); 247 label.SetShadows(label_->shadows());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 const char* LabelButton::GetClassName() const { 361 const char* LabelButton::GetClassName() const {
361 return kViewClassName; 362 return kViewClassName;
362 } 363 }
363 364
364 void LabelButton::EnableCanvasFlippingForRTLUI(bool flip) { 365 void LabelButton::EnableCanvasFlippingForRTLUI(bool flip) {
365 CustomButton::EnableCanvasFlippingForRTLUI(flip); 366 CustomButton::EnableCanvasFlippingForRTLUI(flip);
366 image_->EnableCanvasFlippingForRTLUI(flip); 367 image_->EnableCanvasFlippingForRTLUI(flip);
367 } 368 }
368 369
369 scoped_ptr<LabelButtonBorder> LabelButton::CreateDefaultBorder() const { 370 std::unique_ptr<LabelButtonBorder> LabelButton::CreateDefaultBorder() const {
370 return PlatformStyle::CreateLabelButtonBorder(style()); 371 return PlatformStyle::CreateLabelButtonBorder(style());
371 } 372 }
372 373
373 void LabelButton::SetBorder(scoped_ptr<Border> border) { 374 void LabelButton::SetBorder(std::unique_ptr<Border> border) {
374 border_is_themed_border_ = false; 375 border_is_themed_border_ = false;
375 View::SetBorder(std::move(border)); 376 View::SetBorder(std::move(border));
376 ResetCachedPreferredSize(); 377 ResetCachedPreferredSize();
377 } 378 }
378 379
379 gfx::Rect LabelButton::GetChildAreaBounds() { 380 gfx::Rect LabelButton::GetChildAreaBounds() {
380 return GetLocalBounds(); 381 return GetLocalBounds();
381 } 382 }
382 383
383 void LabelButton::OnPaint(gfx::Canvas* canvas) { 384 void LabelButton::OnPaint(gfx::Canvas* canvas) {
(...skipping 27 matching lines...) Expand all
411 ink_drop_container_->SetVisible(true); 412 ink_drop_container_->SetVisible(true);
412 ink_drop_container_->layer()->Add(ink_drop_layer); 413 ink_drop_container_->layer()->Add(ink_drop_layer);
413 } 414 }
414 415
415 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 416 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
416 image()->SetPaintToLayer(false); 417 image()->SetPaintToLayer(false);
417 ink_drop_container_->layer()->Remove(ink_drop_layer); 418 ink_drop_container_->layer()->Remove(ink_drop_layer);
418 ink_drop_container_->SetVisible(false); 419 ink_drop_container_->SetVisible(false);
419 } 420 }
420 421
421 scoped_ptr<views::InkDropAnimation> LabelButton::CreateInkDropAnimation() 422 std::unique_ptr<views::InkDropAnimation> LabelButton::CreateInkDropAnimation()
422 const { 423 const {
423 return GetText().empty() 424 return GetText().empty()
424 ? CustomButton::CreateInkDropAnimation() 425 ? CustomButton::CreateInkDropAnimation()
425 : make_scoped_ptr(new views::FloodFillInkDropAnimation( 426 : base::WrapUnique(new views::FloodFillInkDropAnimation(
426 size(), GetInkDropCenter(), GetInkDropBaseColor())); 427 size(), GetInkDropCenter(), GetInkDropBaseColor()));
427 } 428 }
428 429
429 scoped_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const { 430 std::unique_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const {
430 if (!ShouldShowInkDropHover()) 431 if (!ShouldShowInkDropHover())
431 return nullptr; 432 return nullptr;
432 return GetText().empty() ? CustomButton::CreateInkDropHover() 433 return GetText().empty() ? CustomButton::CreateInkDropHover()
433 : make_scoped_ptr(new views::InkDropHover( 434 : base::WrapUnique(new views::InkDropHover(
434 size(), kInkDropSmallCornerRadius, 435 size(), kInkDropSmallCornerRadius,
435 GetInkDropCenter(), GetInkDropBaseColor())); 436 GetInkDropCenter(), GetInkDropBaseColor()));
436 } 437 }
437 438
438 gfx::Point LabelButton::GetInkDropCenter() const { 439 gfx::Point LabelButton::GetInkDropCenter() const {
439 // TODO(bruthig): Make the flood fill ink drops centered on the LocatedEvent 440 // TODO(bruthig): Make the flood fill ink drops centered on the LocatedEvent
440 // that triggered them. 441 // that triggered them.
441 return GetText().empty() ? image()->GetMirroredBounds().CenterPoint() 442 return GetText().empty() ? image()->GetMirroredBounds().CenterPoint()
442 : CustomButton::GetInkDropCenter(); 443 : CustomButton::GetInkDropCenter();
443 } 444 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 void LabelButton::ResetLabelEnabledColor() { 563 void LabelButton::ResetLabelEnabledColor() {
563 const SkColor color = 564 const SkColor color =
564 explicitly_set_colors_[state()] 565 explicitly_set_colors_[state()]
565 ? button_state_colors_[state()] 566 ? button_state_colors_[state()]
566 : PlatformStyle::TextColorForButton(button_state_colors_, *this); 567 : PlatformStyle::TextColorForButton(button_state_colors_, *this);
567 if (state() != STATE_DISABLED && label_->enabled_color() != color) 568 if (state() != STATE_DISABLED && label_->enabled_color() != color)
568 label_->SetEnabledColor(color); 569 label_->SetEnabledColor(color);
569 } 570 }
570 571
571 } // namespace views 572 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/label_button_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698