Commit 3a3a8cba authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Instantly animate ink-drop-ripple effects for Mac

Instead of using a fully transparent ripple on Mac, this uses the same
active-ripple effect as other platforms, but instantly animates to them.
This effectively makes use of the active color in the ripple effect but
without using the animation (flood-fill effect).

This fixes a recent regression where MacViews + Refresh got ink-drop
ripples on toolbar and bookmark buttons. It also effectively adds
active-state color that was missing on Mac both for toolbar buttons and
secondary UI MdTextButtons.

Bug: chromium:848767
Change-Id: Ia28d26c128dff12d2181c4dea41a0d4418a9d47c
Reviewed-on: https://chromium-review.googlesource.com/1087949Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564946}
parent dc923915
......@@ -297,7 +297,7 @@ std::unique_ptr<views::InkDropRipple> IconLabelBubbleView::CreateInkDropRipple()
return std::make_unique<views::FloodFillInkDropRipple>(
ink_drop_container_->size(), center_point, GetInkDropBaseColor(),
views::PlatformStyle::kUseRipples ? ink_drop_visible_opacity() : 0);
ink_drop_visible_opacity());
}
std::unique_ptr<views::InkDropHighlight>
......
......@@ -211,7 +211,7 @@ std::unique_ptr<views::InkDropRipple> PageActionIconView::CreateInkDropRipple()
const {
return std::make_unique<views::FloodFillInkDropRipple>(
size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
views::PlatformStyle::kUseRipples ? ink_drop_visible_opacity() : 0);
ink_drop_visible_opacity());
}
std::unique_ptr<views::InkDropHighlight>
......
......@@ -15,6 +15,7 @@
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/views/animation/ink_drop_util.h"
#include "ui/views/style/platform_style.h"
namespace {
......@@ -447,8 +448,10 @@ float FloodFillInkDropRipple::MaxDistanceToCorners(
// Returns the InkDropState sub animation duration for the given |state|.
base::TimeDelta FloodFillInkDropRipple::GetAnimationDuration(int state) {
if (!gfx::Animation::ShouldRenderRichAnimation())
if (!PlatformStyle::kUseRipples ||
!gfx::Animation::ShouldRenderRichAnimation()) {
return base::TimeDelta();
}
int state_override = state;
// Override the requested state if needed.
......
......@@ -118,8 +118,7 @@ gfx::Size InkDropHostView::CalculateLargeInkDropSize(
InkDropHostView::InkDropHostView()
: ink_drop_mode_(InkDropMode::OFF),
ink_drop_(nullptr),
ink_drop_visible_opacity_(
PlatformStyle::kUseRipples ? kInkDropVisibleOpacity : 0),
ink_drop_visible_opacity_(kInkDropVisibleOpacity),
ink_drop_small_corner_radius_(kInkDropSmallCornerRadius),
ink_drop_large_corner_radius_(kInkDropLargeCornerRadius),
old_paint_to_layer_(false),
......
......@@ -17,6 +17,7 @@
#include "ui/gfx/geometry/vector3d_f.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/view.h"
namespace views {
......@@ -129,8 +130,10 @@ int kAnimationDurationInMs[] = {
// Returns the InkDropState sub animation duration for the given |state|.
base::TimeDelta GetAnimationDuration(InkDropSubAnimations state) {
if (!gfx::Animation::ShouldRenderRichAnimation())
if (!PlatformStyle::kUseRipples ||
!gfx::Animation::ShouldRenderRichAnimation()) {
return base::TimeDelta();
}
return base::TimeDelta::FromMilliseconds(
(InkDropRipple::UseFastAnimations()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment