Add back reference to the InkDropHost from the ripples.
This will allow disabling of the ink-drop on a per instance basis.
Bug: 1400017
Change-Id: I4ff44b03cc015f9a2394e306dc80832e8b6ab19a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4200954
Reviewed-by: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098908}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0819121c52
commit
13727d5f4e
ash
lock_screen_action
login
shelf
style
ui
message_center
views
views
@ -48,8 +48,8 @@ class LockScreenActionBackgroundView::NoteBackground : public views::View {
|
||||
: host->GetLocalBounds().top_right();
|
||||
auto ink_drop_ripple =
|
||||
std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(), gfx::Insets(), center,
|
||||
views::InkDrop::Get(host)->GetBaseColor(), 1);
|
||||
views::InkDrop::Get(host), host->size(), gfx::Insets(),
|
||||
center, views::InkDrop::Get(host)->GetBaseColor(), 1);
|
||||
ink_drop_ripple->set_use_hide_transform_duration_for_hide_fade_out(
|
||||
true);
|
||||
ink_drop_ripple->set_duration_factor(1.5);
|
||||
|
@ -47,7 +47,8 @@ LoginButton::LoginButton(PressedCallback callback)
|
||||
radius * 2);
|
||||
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(), host->GetLocalBounds().InsetsFrom(bounds),
|
||||
views::InkDrop::Get(host), host->size(),
|
||||
host->GetLocalBounds().InsetsFrom(bounds),
|
||||
views::InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
kInkDropRippleColor, 1.f /*visible_opacity*/);
|
||||
},
|
||||
|
@ -127,7 +127,8 @@ class BasePinButton : public views::View {
|
||||
kInkDropCornerRadiusDp * 2);
|
||||
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(), host->GetLocalBounds().InsetsFrom(bounds),
|
||||
views::InkDrop::Get(host), host->size(),
|
||||
host->GetLocalBounds().InsetsFrom(bounds),
|
||||
views::InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
host->GetColorProvider()->GetColor(kColorAshInkDrop),
|
||||
/*visible_opacity=*/1.f);
|
||||
|
@ -342,7 +342,7 @@ ShelfAppButton::ShelfAppButton(ShelfView* shelf_view,
|
||||
const int ripple_size = host->shelf_view_->GetShelfItemRippleSize();
|
||||
|
||||
return std::make_unique<views::SquareInkDropRipple>(
|
||||
gfx::Size(ripple_size, ripple_size),
|
||||
views::InkDrop::Get(host), gfx::Size(ripple_size, ripple_size),
|
||||
views::InkDrop::Get(host)->GetLargeCornerRadius(),
|
||||
small_ripple_area.size(),
|
||||
views::InkDrop::Get(host)->GetSmallCornerRadius(),
|
||||
|
@ -89,8 +89,8 @@ std::unique_ptr<views::InkDropRipple> StyleUtil::CreateInkDropRipple(
|
||||
const std::pair<SkColor, float> base_color_and_opacity =
|
||||
AshColorProvider::Get()->GetInkDropBaseColorAndOpacity(background_color);
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(), insets,
|
||||
views::InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
const_cast<views::InkDropHost*>(views::InkDrop::Get(host)), host->size(),
|
||||
insets, views::InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
base_color_and_opacity.first, base_color_and_opacity.second);
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ NotificationView::NotificationView(
|
||||
views::InkDrop::Get(this)->SetCreateRippleCallback(base::BindRepeating(
|
||||
[](NotificationViewBase* host) -> std::unique_ptr<views::InkDropRipple> {
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->GetPreferredSize(),
|
||||
views::InkDrop::Get(host), host->GetPreferredSize(),
|
||||
views::InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
views::InkDrop::Get(host)->GetBaseColor(),
|
||||
views::InkDrop::Get(host)->GetVisibleOpacity());
|
||||
|
@ -115,12 +115,14 @@ float CalculateCircleLayerRadius(const gfx::Rect& clip_bounds) {
|
||||
|
||||
namespace views {
|
||||
|
||||
FloodFillInkDropRipple::FloodFillInkDropRipple(const gfx::Size& host_size,
|
||||
FloodFillInkDropRipple::FloodFillInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& host_size,
|
||||
const gfx::Insets& clip_insets,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity)
|
||||
: clip_insets_(clip_insets),
|
||||
: InkDropRipple(ink_drop_host),
|
||||
clip_insets_(clip_insets),
|
||||
center_point_(center_point),
|
||||
visible_opacity_(visible_opacity),
|
||||
use_hide_transform_duration_for_hide_fade_out_(false),
|
||||
@ -160,11 +162,13 @@ FloodFillInkDropRipple::FloodFillInkDropRipple(const gfx::Size& host_size,
|
||||
SetStateToHidden();
|
||||
}
|
||||
|
||||
FloodFillInkDropRipple::FloodFillInkDropRipple(const gfx::Size& host_size,
|
||||
FloodFillInkDropRipple::FloodFillInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& host_size,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity)
|
||||
: FloodFillInkDropRipple(host_size,
|
||||
: FloodFillInkDropRipple(ink_drop_host,
|
||||
host_size,
|
||||
gfx::Insets(),
|
||||
center_point,
|
||||
color,
|
||||
@ -353,7 +357,9 @@ float FloodFillInkDropRipple::MaxDistanceToCorners(
|
||||
// Returns the InkDropState sub animation duration for the given |state|.
|
||||
base::TimeDelta FloodFillInkDropRipple::GetAnimationDuration(int state) {
|
||||
if (!PlatformStyle::kUseRipples ||
|
||||
!gfx::Animation::ShouldRenderRichAnimation()) {
|
||||
!gfx::Animation::ShouldRenderRichAnimation() ||
|
||||
(GetInkDropHost() && GetInkDropHost()->GetMode() ==
|
||||
InkDropHost::InkDropMode::ON_NO_ANIMATE)) {
|
||||
return base::TimeDelta();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class Layer;
|
||||
|
||||
namespace views {
|
||||
class CircleLayerDelegate;
|
||||
class InkDropHost;
|
||||
|
||||
namespace test {
|
||||
class FloodFillInkDropRippleTestApi;
|
||||
@ -51,12 +52,14 @@ class FloodFillInkDropRippleTestApi;
|
||||
//
|
||||
class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple {
|
||||
public:
|
||||
FloodFillInkDropRipple(const gfx::Size& host_size,
|
||||
FloodFillInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& host_size,
|
||||
const gfx::Insets& clip_insets,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity);
|
||||
FloodFillInkDropRipple(const gfx::Size& host_size,
|
||||
FloodFillInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& host_size,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity);
|
||||
|
@ -27,8 +27,8 @@ TEST(FloodFillInkDropRippleTest, TransformedCenterPointForIrregularClipBounds) {
|
||||
requested_center_point.x() - clip_insets.left(),
|
||||
requested_center_point.y() - clip_insets.top());
|
||||
|
||||
FloodFillInkDropRipple ripple(host_size, clip_insets, requested_center_point,
|
||||
SK_ColorWHITE, 0.175f);
|
||||
FloodFillInkDropRipple ripple(nullptr, host_size, clip_insets,
|
||||
requested_center_point, SK_ColorWHITE, 0.175f);
|
||||
FloodFillInkDropRippleTestApi test_api(&ripple);
|
||||
|
||||
gfx::Point3F actual_center = test_api.MapPoint(
|
||||
@ -45,7 +45,7 @@ TEST(FloodFillInkDropRippleTest, MaxDistanceToCorners) {
|
||||
// (10, 30), (60, 30), (10, 100), (60, 100)
|
||||
const auto clip_insets = gfx::Insets::VH(30, 10);
|
||||
|
||||
FloodFillInkDropRipple ripple(host_size, clip_insets, gfx::Point(),
|
||||
FloodFillInkDropRipple ripple(nullptr, host_size, clip_insets, gfx::Point(),
|
||||
SK_ColorWHITE, 0.175f);
|
||||
FloodFillInkDropRippleTestApi test_api(&ripple);
|
||||
|
||||
@ -81,7 +81,7 @@ TEST(FloodFillInkDropRippleTest, ActivatedFinalState) {
|
||||
const SkColor color = SK_ColorWHITE;
|
||||
const float visible_opacity = 0.7f;
|
||||
|
||||
FloodFillInkDropRipple ripple(host_size, center_point, color,
|
||||
FloodFillInkDropRipple ripple(nullptr, host_size, center_point, color,
|
||||
visible_opacity);
|
||||
FloodFillInkDropRippleTestApi test_api(&ripple);
|
||||
|
||||
@ -120,7 +120,7 @@ TEST(FloodFillInkDropRippleTest, TransformIsPixelAligned) {
|
||||
const SkColor color = SK_ColorYELLOW;
|
||||
const float visible_opacity = 0.3f;
|
||||
|
||||
FloodFillInkDropRipple ripple(host_size, center_point, color,
|
||||
FloodFillInkDropRipple ripple(nullptr, host_size, center_point, color,
|
||||
visible_opacity);
|
||||
FloodFillInkDropRippleTestApi test_api(&ripple);
|
||||
|
||||
|
@ -90,8 +90,8 @@ std::unique_ptr<InkDropRipple> InkDropHost::CreateInkDropRipple() const {
|
||||
return create_ink_drop_ripple_callback_.Run();
|
||||
}
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host_view_->size(), gfx::Insets(), GetInkDropCenterBasedOnLastEvent(),
|
||||
GetBaseColor(), GetVisibleOpacity());
|
||||
InkDrop::Get(host_view_), host_view_->size(), gfx::Insets(),
|
||||
GetInkDropCenterBasedOnLastEvent(), GetBaseColor(), GetVisibleOpacity());
|
||||
}
|
||||
|
||||
void InkDropHost::SetCreateRippleCallback(
|
||||
@ -175,6 +175,10 @@ void InkDropHost::SetMode(InkDropMode ink_drop_mode) {
|
||||
ink_drop_.reset();
|
||||
}
|
||||
|
||||
InkDropHost::InkDropMode InkDropHost::GetMode() const {
|
||||
return ink_drop_mode_;
|
||||
}
|
||||
|
||||
void InkDropHost::SetVisibleOpacity(float visible_opacity) {
|
||||
if (visible_opacity == ink_drop_visible_opacity_) {
|
||||
return;
|
||||
@ -273,7 +277,7 @@ std::unique_ptr<InkDropRipple> InkDropHost::CreateSquareRipple(
|
||||
constexpr float kLargeInkDropScale = 1.333f;
|
||||
const gfx::Size large_size = gfx::ScaleToCeiledSize(size, kLargeInkDropScale);
|
||||
auto ripple = std::make_unique<SquareInkDropRipple>(
|
||||
large_size, ink_drop_large_corner_radius_, size,
|
||||
InkDrop::Get(host_view_), large_size, ink_drop_large_corner_radius_, size,
|
||||
ink_drop_small_corner_radius_, center_point, GetBaseColor(),
|
||||
GetVisibleOpacity());
|
||||
return ripple;
|
||||
|
@ -57,6 +57,7 @@ class VIEWS_EXPORT InkDropHost {
|
||||
OFF,
|
||||
ON,
|
||||
ON_NO_GESTURE_HANDLER,
|
||||
ON_NO_ANIMATE,
|
||||
};
|
||||
|
||||
explicit InkDropHost(View* host);
|
||||
@ -122,6 +123,7 @@ class VIEWS_EXPORT InkDropHost {
|
||||
// TODO(bruthig): Add an easier mechanism than overriding functions to allow
|
||||
// subclasses/clients to specify the flavor of ink drop.
|
||||
void SetMode(InkDropMode ink_drop_mode);
|
||||
InkDropMode GetMode() const;
|
||||
|
||||
void SetVisibleOpacity(float visible_opacity);
|
||||
float GetVisibleOpacity() const;
|
||||
|
@ -15,7 +15,8 @@ namespace views {
|
||||
|
||||
const float InkDropRipple::kHiddenOpacity = 0.f;
|
||||
|
||||
InkDropRipple::InkDropRipple() = default;
|
||||
InkDropRipple::InkDropRipple(InkDropHost* ink_drop_host)
|
||||
: ink_drop_host_(ink_drop_host) {}
|
||||
|
||||
InkDropRipple::~InkDropRipple() = default;
|
||||
|
||||
@ -81,6 +82,10 @@ ui::LayerAnimationObserver* InkDropRipple::GetLayerAnimationObserver() {
|
||||
return animation_observer_.get();
|
||||
}
|
||||
|
||||
InkDropHost* InkDropRipple::GetInkDropHost() const {
|
||||
return ink_drop_host_.get();
|
||||
}
|
||||
|
||||
void InkDropRipple::AnimationStartedCallback(
|
||||
InkDropState ink_drop_state,
|
||||
const ui::CallbackLayerAnimationObserver& observer) {
|
||||
|
@ -22,6 +22,8 @@ class LayerAnimationObserver;
|
||||
|
||||
namespace views {
|
||||
|
||||
class InkDropHost;
|
||||
|
||||
namespace test {
|
||||
class InkDropRippleTestApi;
|
||||
} // namespace test
|
||||
@ -36,7 +38,7 @@ class VIEWS_EXPORT InkDropRipple {
|
||||
// The opacity of the ink drop when it is not visible.
|
||||
static const float kHiddenOpacity;
|
||||
|
||||
InkDropRipple();
|
||||
explicit InkDropRipple(InkDropHost* ink_drop_host);
|
||||
InkDropRipple(const InkDropRipple&) = delete;
|
||||
InkDropRipple& operator=(const InkDropRipple&) = delete;
|
||||
virtual ~InkDropRipple();
|
||||
@ -98,6 +100,9 @@ class VIEWS_EXPORT InkDropRipple {
|
||||
// called.
|
||||
ui::LayerAnimationObserver* GetLayerAnimationObserver();
|
||||
|
||||
// Get the InkDropHost associated this ripple.
|
||||
InkDropHost* GetInkDropHost() const;
|
||||
|
||||
private:
|
||||
// The Callback invoked when all of the animation sequences for the specific
|
||||
// |ink_drop_state| animation have started. |observer| is the
|
||||
@ -124,6 +129,9 @@ class VIEWS_EXPORT InkDropRipple {
|
||||
raw_ptr<InkDropRippleObserver> observer_ = nullptr;
|
||||
|
||||
std::unique_ptr<ui::CallbackLayerAnimationObserver> animation_observer_;
|
||||
|
||||
// Reference to the host on which this ripple resides.
|
||||
raw_ptr<InkDropHost> ink_drop_host_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace views
|
||||
|
@ -65,9 +65,9 @@ InkDropRippleTest::InkDropRippleTest()
|
||||
gfx::Animation::RichAnimationRenderMode::FORCE_DISABLED)) {
|
||||
switch (GetParam()) {
|
||||
case SQUARE_INK_DROP_RIPPLE: {
|
||||
SquareInkDropRipple* square_ink_drop_ripple =
|
||||
new SquareInkDropRipple(gfx::Size(10, 10), 2, gfx::Size(8, 8), 1,
|
||||
gfx::Point(), SK_ColorBLACK, kVisibleOpacity);
|
||||
SquareInkDropRipple* square_ink_drop_ripple = new SquareInkDropRipple(
|
||||
nullptr, gfx::Size(10, 10), 2, gfx::Size(8, 8), 1, gfx::Point(),
|
||||
SK_ColorBLACK, kVisibleOpacity);
|
||||
ink_drop_ripple_.reset(square_ink_drop_ripple);
|
||||
test_api_ =
|
||||
std::make_unique<SquareInkDropRippleTestApi>(square_ink_drop_ripple);
|
||||
@ -75,7 +75,7 @@ InkDropRippleTest::InkDropRippleTest()
|
||||
}
|
||||
case FLOOD_FILL_INK_DROP_RIPPLE: {
|
||||
FloodFillInkDropRipple* flood_fill_ink_drop_ripple =
|
||||
new FloodFillInkDropRipple(gfx::Size(10, 10), gfx::Point(),
|
||||
new FloodFillInkDropRipple(nullptr, gfx::Size(10, 10), gfx::Point(),
|
||||
SK_ColorBLACK, kVisibleOpacity);
|
||||
ink_drop_ripple_.reset(flood_fill_ink_drop_ripple);
|
||||
test_api_ = std::make_unique<FloodFillInkDropRippleTestApi>(
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ui/gfx/geometry/vector3d_f.h"
|
||||
#include "ui/views/animation/animation_builder.h"
|
||||
#include "ui/views/animation/animation_sequence_block.h"
|
||||
#include "ui/views/animation/ink_drop_host.h"
|
||||
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
|
||||
#include "ui/views/style/platform_style.h"
|
||||
#include "ui/views/view.h"
|
||||
@ -116,9 +117,12 @@ enum InkDropSubAnimations {
|
||||
constexpr float kQuickActionBurstScale = 1.3f;
|
||||
|
||||
// Returns the InkDropState sub animation duration for the given |state|.
|
||||
base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) {
|
||||
base::TimeDelta GetAnimationDuration(InkDropHost* ink_drop_host,
|
||||
InkDropSubAnimations state) {
|
||||
if (!PlatformStyle::kUseRipples ||
|
||||
!gfx::Animation::ShouldRenderRichAnimation()) {
|
||||
!gfx::Animation::ShouldRenderRichAnimation() ||
|
||||
(ink_drop_host &&
|
||||
ink_drop_host->GetMode() == InkDropHost::InkDropMode::ON_NO_ANIMATE)) {
|
||||
return base::TimeDelta();
|
||||
}
|
||||
|
||||
@ -144,14 +148,16 @@ base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) {
|
||||
|
||||
} // namespace
|
||||
|
||||
SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size,
|
||||
SquareInkDropRipple::SquareInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& large_size,
|
||||
int large_corner_radius,
|
||||
const gfx::Size& small_size,
|
||||
int small_corner_radius,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity)
|
||||
: visible_opacity_(visible_opacity),
|
||||
: InkDropRipple(ink_drop_host),
|
||||
visible_opacity_(visible_opacity),
|
||||
large_size_(large_size),
|
||||
large_corner_radius_(large_corner_radius),
|
||||
small_size_(small_size),
|
||||
@ -226,6 +232,7 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
InkDropState new_ink_drop_state) {
|
||||
InkDropTransforms transforms;
|
||||
AnimationBuilder builder;
|
||||
InkDropHost* host = GetInkDropHost();
|
||||
builder
|
||||
.SetPreemptionStrategy(
|
||||
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET)
|
||||
@ -241,14 +248,14 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
};
|
||||
|
||||
auto pending_animation =
|
||||
[this, &animate_to_transforms](
|
||||
[this, &animate_to_transforms, host](
|
||||
AnimationSequenceBlock& sequence,
|
||||
const InkDropTransforms& transforms) -> AnimationSequenceBlock& {
|
||||
auto& new_sequence =
|
||||
sequence.SetDuration(GetAnimationDuration(ACTION_PENDING_FADE_IN))
|
||||
sequence.SetDuration(GetAnimationDuration(host, ACTION_PENDING_FADE_IN))
|
||||
.SetOpacity(&root_layer_, visible_opacity_, gfx::Tween::EASE_IN)
|
||||
.Then()
|
||||
.SetDuration(GetAnimationDuration(ACTION_PENDING_TRANSFORM))
|
||||
.SetDuration(GetAnimationDuration(host, ACTION_PENDING_TRANSFORM))
|
||||
.SetOpacity(&root_layer_, visible_opacity_, gfx::Tween::EASE_IN);
|
||||
animate_to_transforms(new_sequence, transforms, gfx::Tween::EASE_IN_OUT);
|
||||
return new_sequence;
|
||||
@ -263,11 +270,11 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
CalculateCircleTransforms(small_size_, &transforms);
|
||||
auto& sequence =
|
||||
builder.GetCurrentSequence()
|
||||
.SetDuration(GetAnimationDuration(HIDDEN_FADE_OUT))
|
||||
.SetDuration(GetAnimationDuration(host, HIDDEN_FADE_OUT))
|
||||
.SetOpacity(&root_layer_, kHiddenOpacity,
|
||||
gfx::Tween::EASE_IN_OUT)
|
||||
.At(base::TimeDelta())
|
||||
.SetDuration(GetAnimationDuration(HIDDEN_TRANSFORM));
|
||||
.SetDuration(GetAnimationDuration(host, HIDDEN_TRANSFORM));
|
||||
animate_to_transforms(sequence, transforms, gfx::Tween::EASE_IN_OUT);
|
||||
}
|
||||
break;
|
||||
@ -298,10 +305,10 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
builder.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
|
||||
}
|
||||
builder.GetCurrentSequence()
|
||||
.SetDuration(GetAnimationDuration(ACTION_TRIGGERED_FADE_OUT))
|
||||
.SetDuration(GetAnimationDuration(host, ACTION_TRIGGERED_FADE_OUT))
|
||||
.SetOpacity(&root_layer_, kHiddenOpacity, gfx::Tween::EASE_IN_OUT)
|
||||
.Offset(base::TimeDelta())
|
||||
.SetDuration(GetAnimationDuration(ACTION_TRIGGERED_TRANSFORM));
|
||||
.SetDuration(GetAnimationDuration(host, ACTION_TRIGGERED_TRANSFORM));
|
||||
animate_to_transforms(builder.GetCurrentSequence(), transforms,
|
||||
gfx::Tween::EASE_IN_OUT);
|
||||
break;
|
||||
@ -315,7 +322,7 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
CalculateRectTransforms(small_size_, small_corner_radius_, &transforms);
|
||||
animate_to_transforms(
|
||||
builder.GetCurrentSequence()
|
||||
.SetDuration(GetAnimationDuration(ALTERNATE_ACTION_PENDING))
|
||||
.SetDuration(GetAnimationDuration(host, ALTERNATE_ACTION_PENDING))
|
||||
.SetOpacity(&root_layer_, visible_opacity_, gfx::Tween::EASE_IN),
|
||||
transforms, gfx::Tween::EASE_IN_OUT);
|
||||
break;
|
||||
@ -328,19 +335,19 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
<< " new_ink_drop_state=" << ToString(new_ink_drop_state);
|
||||
|
||||
base::TimeDelta visible_duration =
|
||||
GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM) -
|
||||
GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_FADE_OUT);
|
||||
GetAnimationDuration(host, ALTERNATE_ACTION_TRIGGERED_TRANSFORM) -
|
||||
GetAnimationDuration(host, ALTERNATE_ACTION_TRIGGERED_FADE_OUT);
|
||||
CalculateRectTransforms(large_size_, large_corner_radius_, &transforms);
|
||||
builder.GetCurrentSequence()
|
||||
.SetDuration(visible_duration)
|
||||
.SetOpacity(&root_layer_, visible_opacity_, gfx::Tween::EASE_IN_OUT)
|
||||
.Then()
|
||||
.SetDuration(
|
||||
GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_FADE_OUT))
|
||||
GetAnimationDuration(host, ALTERNATE_ACTION_TRIGGERED_FADE_OUT))
|
||||
.SetOpacity(&root_layer_, kHiddenOpacity, gfx::Tween::EASE_IN_OUT)
|
||||
.At(base::TimeDelta())
|
||||
.SetDuration(
|
||||
GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM));
|
||||
GetAnimationDuration(host, ALTERNATE_ACTION_TRIGGERED_TRANSFORM));
|
||||
animate_to_transforms(builder.GetCurrentSequence(), transforms,
|
||||
gfx::Tween::EASE_IN_OUT);
|
||||
break;
|
||||
@ -357,7 +364,7 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
CalculateCircleTransforms(large_size_, &transforms);
|
||||
animate_to_transforms(
|
||||
builder.GetCurrentSequence().SetDuration(
|
||||
GetAnimationDuration(ACTIVATED_CIRCLE_TRANSFORM)),
|
||||
GetAnimationDuration(host, ACTIVATED_CIRCLE_TRANSFORM)),
|
||||
transforms, gfx::Tween::EASE_IN_OUT)
|
||||
.Then();
|
||||
} else if (old_ink_drop_state == InkDropState::ACTION_PENDING) {
|
||||
@ -365,26 +372,28 @@ void SquareInkDropRipple::AnimateStateChange(InkDropState old_ink_drop_state,
|
||||
}
|
||||
|
||||
GetActivatedTargetTransforms(&transforms);
|
||||
animate_to_transforms(builder.GetCurrentSequence().SetDuration(
|
||||
GetAnimationDuration(ACTIVATED_RECT_TRANSFORM)),
|
||||
transforms, gfx::Tween::EASE_IN_OUT);
|
||||
animate_to_transforms(
|
||||
builder.GetCurrentSequence().SetDuration(
|
||||
GetAnimationDuration(host, ACTIVATED_RECT_TRANSFORM)),
|
||||
transforms, gfx::Tween::EASE_IN_OUT);
|
||||
break;
|
||||
}
|
||||
case InkDropState::DEACTIVATED: {
|
||||
base::TimeDelta visible_duration =
|
||||
GetAnimationDuration(DEACTIVATED_TRANSFORM) -
|
||||
GetAnimationDuration(DEACTIVATED_FADE_OUT);
|
||||
GetAnimationDuration(host, DEACTIVATED_TRANSFORM) -
|
||||
GetAnimationDuration(host, DEACTIVATED_FADE_OUT);
|
||||
GetDeactivatedTargetTransforms(&transforms);
|
||||
builder.GetCurrentSequence()
|
||||
.SetDuration(visible_duration)
|
||||
.SetOpacity(&root_layer_, visible_opacity_, gfx::Tween::EASE_IN_OUT)
|
||||
.Then()
|
||||
.SetDuration(GetAnimationDuration(DEACTIVATED_FADE_OUT))
|
||||
.SetDuration(GetAnimationDuration(host, DEACTIVATED_FADE_OUT))
|
||||
.SetOpacity(&root_layer_, kHiddenOpacity, gfx::Tween::EASE_IN_OUT)
|
||||
.At(base::TimeDelta());
|
||||
animate_to_transforms(builder.GetCurrentSequence().SetDuration(
|
||||
GetAnimationDuration(DEACTIVATED_TRANSFORM)),
|
||||
transforms, gfx::Tween::EASE_IN_OUT);
|
||||
animate_to_transforms(
|
||||
builder.GetCurrentSequence().SetDuration(
|
||||
GetAnimationDuration(host, DEACTIVATED_TRANSFORM)),
|
||||
transforms, gfx::Tween::EASE_IN_OUT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class Layer;
|
||||
|
||||
namespace views {
|
||||
class CircleLayerDelegate;
|
||||
class InkDropHost;
|
||||
class RectangleLayerDelegate;
|
||||
|
||||
namespace test {
|
||||
@ -53,7 +54,8 @@ class VIEWS_EXPORT SquareInkDropRipple : public InkDropRipple {
|
||||
// The shape to use for the ACTIVATED/DEACTIVATED states.
|
||||
enum class ActivatedShape { kCircle, kRoundedRect };
|
||||
|
||||
SquareInkDropRipple(const gfx::Size& large_size,
|
||||
SquareInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& large_size,
|
||||
int large_corner_radius,
|
||||
const gfx::Size& small_size,
|
||||
int small_corner_radius,
|
||||
|
@ -66,6 +66,7 @@ class SquareInkDropRippleCalculateTransformsTest : public WidgetTest {
|
||||
|
||||
// The test target.
|
||||
SquareInkDropRipple ink_drop_ripple_{
|
||||
nullptr,
|
||||
gfx::Size(kDrawnSize, kDrawnSize),
|
||||
2,
|
||||
gfx::Size(kHalfDrawnSize, kHalfDrawnSize),
|
||||
@ -221,7 +222,7 @@ TEST_F(SquareInkDropRippleCalculateTransformsTest, RippleIsPixelAligned) {
|
||||
// scale factor.
|
||||
constexpr gfx::Point kCenter(14, 14);
|
||||
constexpr gfx::Rect kDrawnRectBounds(0, 0, 10, 10);
|
||||
SquareInkDropRipple ink_drop_ripple(kDrawnRectBounds.size(), 2,
|
||||
SquareInkDropRipple ink_drop_ripple(nullptr, kDrawnRectBounds.size(), 2,
|
||||
gfx::Size(1, 1), // unimportant
|
||||
1, kCenter, SK_ColorBLACK, 0.175f);
|
||||
SquareInkDropRippleTestApi test_api(&ink_drop_ripple);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ui/views/animation/test/square_ink_drop_ripple_test_api.h"
|
||||
|
||||
namespace views {
|
||||
class InkDropHost;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -23,14 +24,16 @@ namespace {
|
||||
// GetTestApi().
|
||||
class TestInkDropRipple : public SquareInkDropRipple {
|
||||
public:
|
||||
TestInkDropRipple(const gfx::Size& large_size,
|
||||
TestInkDropRipple(InkDropHost* ink_drop_host,
|
||||
const gfx::Size& large_size,
|
||||
int large_corner_radius,
|
||||
const gfx::Size& small_size,
|
||||
int small_corner_radius,
|
||||
const gfx::Point& center_point,
|
||||
SkColor color,
|
||||
float visible_opacity)
|
||||
: SquareInkDropRipple(large_size,
|
||||
: SquareInkDropRipple(ink_drop_host,
|
||||
large_size,
|
||||
large_corner_radius,
|
||||
small_size,
|
||||
small_corner_radius,
|
||||
@ -106,8 +109,8 @@ TestInkDropHost::TestInkDropHost(
|
||||
InkDrop::Get(this)->SetCreateRippleCallback(base::BindRepeating(
|
||||
[](TestInkDropHost* host) -> std::unique_ptr<views::InkDropRipple> {
|
||||
auto ripple = std::make_unique<TestInkDropRipple>(
|
||||
host->size(), 0, host->size(), 0, gfx::Point(), SK_ColorBLACK,
|
||||
0.175f);
|
||||
InkDrop::Get(host), host->size(), 0, host->size(), 0, gfx::Point(),
|
||||
SK_ColorBLACK, 0.175f);
|
||||
if (host->disable_timers_for_test_)
|
||||
ripple->GetTestApi()->SetDisableAnimationTimers(true);
|
||||
host->num_ink_drop_ripples_created_++;
|
||||
|
@ -87,7 +87,7 @@ class TransparentButton : public Button {
|
||||
InkDrop::Get(this)->SetCreateRippleCallback(base::BindRepeating(
|
||||
[](Button* host) -> std::unique_ptr<views::InkDropRipple> {
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(),
|
||||
InkDrop::Get(host), host->size(),
|
||||
InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
host->GetColorProvider()->GetColor(ui::kColorLabelForeground),
|
||||
InkDrop::Get(host)->GetVisibleOpacity());
|
||||
|
@ -89,7 +89,7 @@ class Arrow : public Button {
|
||||
InkDrop::Get(this)->SetCreateRippleCallback(base::BindRepeating(
|
||||
[](Button* host) -> std::unique_ptr<views::InkDropRipple> {
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(),
|
||||
InkDrop::Get(host), host->size(),
|
||||
InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
style::GetColor(*host, style::CONTEXT_TEXTFIELD,
|
||||
style::STYLE_PRIMARY),
|
||||
|
@ -87,7 +87,8 @@ FrameCaptionButton::FrameCaptionButton(PressedCallback callback,
|
||||
InkDrop::Get(this)->SetCreateRippleCallback(base::BindRepeating(
|
||||
[](FrameCaptionButton* host) -> std::unique_ptr<views::InkDropRipple> {
|
||||
return std::make_unique<views::FloodFillInkDropRipple>(
|
||||
host->size(), host->GetInkdropInsets(host->size()),
|
||||
InkDrop::Get(host), host->size(),
|
||||
host->GetInkdropInsets(host->size()),
|
||||
InkDrop::Get(host)->GetInkDropCenterBasedOnLastEvent(),
|
||||
InkDrop::Get(host)->GetBaseColor(),
|
||||
InkDrop::Get(host)->GetVisibleOpacity());
|
||||
|
Reference in New Issue
Block a user