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

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

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed InkDropHostView::GetInkDrop() to use CreateInkDrop(). Created 4 years, 1 month 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/md_text_button.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 "base/memory/ptr_util.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/gfx/animation/throb_animation.h" 15 #include "ui/gfx/animation/throb_animation.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
18 #include "ui/gfx/font_list.h" 18 #include "ui/gfx/font_list.h"
19 #include "ui/gfx/geometry/vector2d.h" 19 #include "ui/gfx/geometry/vector2d.h"
20 #include "ui/native_theme/native_theme.h" 20 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
22 #include "ui/views/animation/ink_drop_highlight.h" 22 #include "ui/views/animation/ink_drop_highlight.h"
23 #include "ui/views/animation/ink_drop_impl.h"
23 #include "ui/views/animation/square_ink_drop_ripple.h" 24 #include "ui/views/animation/square_ink_drop_ripple.h"
24 #include "ui/views/background.h" 25 #include "ui/views/background.h"
25 #include "ui/views/controls/button/label_button_border.h" 26 #include "ui/views/controls/button/label_button_border.h"
26 #include "ui/views/painter.h" 27 #include "ui/views/painter.h"
27 #include "ui/views/style/platform_style.h" 28 #include "ui/views/style/platform_style.h"
28 #include "ui/views/window/dialog_delegate.h" 29 #include "ui/views/window/dialog_delegate.h"
29 30
30 namespace { 31 namespace {
31 32
32 // The default spacing between the icon and text. 33 // The default spacing between the icon and text.
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ink_drop_container_->SetVisible(true); 441 ink_drop_container_->SetVisible(true);
441 ink_drop_container_->layer()->Add(ink_drop_layer); 442 ink_drop_container_->layer()->Add(ink_drop_layer);
442 } 443 }
443 444
444 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 445 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
445 image()->SetPaintToLayer(false); 446 image()->SetPaintToLayer(false);
446 ink_drop_container_->layer()->Remove(ink_drop_layer); 447 ink_drop_container_->layer()->Remove(ink_drop_layer);
447 ink_drop_container_->SetVisible(false); 448 ink_drop_container_->SetVisible(false);
448 } 449 }
449 450
451 std::unique_ptr<InkDrop> LabelButton::CreateInkDrop() {
452 return UseFloodFillInkDrop() ? CreateDefaultFloodFillInkDropImpl()
453 : CustomButton::CreateInkDrop();
454 }
455
450 std::unique_ptr<views::InkDropRipple> LabelButton::CreateInkDropRipple() const { 456 std::unique_ptr<views::InkDropRipple> LabelButton::CreateInkDropRipple() const {
451 return GetText().empty() 457 return UseFloodFillInkDrop()
452 ? CreateDefaultInkDropRipple( 458 ? base::MakeUnique<views::FloodFillInkDropRipple>(
453 image()->GetMirroredBounds().CenterPoint())
454 : base::MakeUnique<views::FloodFillInkDropRipple>(
455 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(), 459 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
456 GetInkDropBaseColor(), ink_drop_visible_opacity()); 460 GetInkDropBaseColor(), ink_drop_visible_opacity())
461 : CreateDefaultInkDropRipple(
462 image()->GetMirroredBounds().CenterPoint());
457 } 463 }
458 464
459 std::unique_ptr<views::InkDropHighlight> LabelButton::CreateInkDropHighlight() 465 std::unique_ptr<views::InkDropHighlight> LabelButton::CreateInkDropHighlight()
460 const { 466 const {
461 if (!ShouldShowInkDropHighlight()) 467 return UseFloodFillInkDrop()
462 return nullptr; 468 ? base::MakeUnique<views::InkDropHighlight>(
463 return GetText().empty()
464 ? CreateDefaultInkDropHighlight(
465 gfx::RectF(image()->GetMirroredBounds()).CenterPoint())
466 : base::MakeUnique<views::InkDropHighlight>(
467 size(), kInkDropSmallCornerRadius, 469 size(), kInkDropSmallCornerRadius,
468 gfx::RectF(GetLocalBounds()).CenterPoint(), 470 gfx::RectF(GetLocalBounds()).CenterPoint(),
469 GetInkDropBaseColor()); 471 GetInkDropBaseColor())
472 : CreateDefaultInkDropHighlight(
473 gfx::RectF(image()->GetMirroredBounds()).CenterPoint());
470 } 474 }
471 475
472 void LabelButton::StateChanged() { 476 void LabelButton::StateChanged() {
473 const gfx::Size previous_image_size(image_->GetPreferredSize()); 477 const gfx::Size previous_image_size(image_->GetPreferredSize());
474 UpdateImage(); 478 UpdateImage();
475 ResetLabelEnabledColor(); 479 ResetLabelEnabledColor();
476 label_->SetEnabled(state() != STATE_DISABLED); 480 label_->SetEnabled(state() != STATE_DISABLED);
477 if (image_->GetPreferredSize() != previous_image_size) 481 if (image_->GetPreferredSize() != previous_image_size)
478 Layout(); 482 Layout();
479 } 483 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 614
611 void LabelButton::ResetLabelEnabledColor() { 615 void LabelButton::ResetLabelEnabledColor() {
612 const SkColor color = 616 const SkColor color =
613 explicitly_set_colors_[state()] 617 explicitly_set_colors_[state()]
614 ? button_state_colors_[state()] 618 ? button_state_colors_[state()]
615 : PlatformStyle::TextColorForButton(button_state_colors_, *this); 619 : PlatformStyle::TextColorForButton(button_state_colors_, *this);
616 if (state() != STATE_DISABLED && label_->enabled_color() != color) 620 if (state() != STATE_DISABLED && label_->enabled_color() != color)
617 label_->SetEnabledColor(color); 621 label_->SetEnabledColor(color);
618 } 622 }
619 623
624 bool LabelButton::UseFloodFillInkDrop() const {
625 return !GetText().empty();
626 }
627
620 } // namespace views 628 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698