chromium/ui/views/animation/ink_drop_impl.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/animation/ink_drop_impl.h"

#include <utility>

#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/timer/timer.h"
#include "ui/compositor/layer.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_host.h"
#include "ui/views/animation/ink_drop_util.h"
#include "ui/views/animation/square_ink_drop_ripple.h"
#include "ui/views/style/platform_style.h"

namespace views {

namespace {

// The duration for the highlight state fade in/out animations when they are
// triggered by a hover changed event.
constexpr auto kHighlightFadeInOnHoverChangeDuration =;
constexpr auto kHighlightFadeOutOnHoverChangeDuration =;

// The duration for the highlight state fade in/out animations when they are
// triggered by a focus changed event.
constexpr auto kHighlightFadeInOnFocusChangeDuration =;
constexpr auto kHighlightFadeOutOnFocusChangeDuration =;

// The duration for showing/hiding the highlight when triggered by ripple
// visibility changes for the HIDE_ON_RIPPLE AutoHighlightMode.
constexpr auto kHighlightFadeInOnRippleHidingDuration =;
constexpr auto kHighlightFadeOutOnRippleShowingDuration =;

// The duration for showing/hiding the highlight when triggered by ripple
// visibility changes for the SHOW_ON_RIPPLE AutoHighlightMode.
constexpr auto kHighlightFadeInOnRippleShowingDuration =;
constexpr auto kHighlightFadeOutOnRippleHidingDuration =;

// The amount of time that |highlight_| should delay after a ripple animation
// before fading in, for highlight due to mouse hover.
constexpr auto kHoverFadeInAfterRippleDelay =;

// Returns true if an ink drop with the given |ink_drop_state| should
// automatically transition to the InkDropState::HIDDEN state.
bool ShouldAnimateToHidden(InkDropState ink_drop_state) {}

}  // namespace

// HighlightState definition

InkDropImpl* InkDropImpl::HighlightState::GetInkDrop() {}

// A HighlightState to be used during InkDropImpl destruction. All event
// handlers are no-ops so as to avoid triggering animations during tear down.
class InkDropImpl::DestroyingHighlightState
    : public InkDropImpl::HighlightState {};

//
// AutoHighlightMode::NONE states
//

// Animates the highlight to hidden upon entering this state. Transitions to a
// visible state based on hover/focus changes.
class InkDropImpl::NoAutoHighlightHiddenState
    : public InkDropImpl::HighlightState {};

// Animates the highlight to visible upon entering this state. Transitions to a
// hidden state based on hover/focus changes.
class InkDropImpl::NoAutoHighlightVisibleState
    : public InkDropImpl::HighlightState {};

// NoAutoHighlightHiddenState definition

InkDropImpl::NoAutoHighlightHiddenState::NoAutoHighlightHiddenState(
    HighlightStateFactory* state_factory,
    base::TimeDelta animation_duration)
    :{}

void InkDropImpl::NoAutoHighlightHiddenState::Enter() {}

void InkDropImpl::NoAutoHighlightHiddenState::ShowOnHoverChanged() {}

void InkDropImpl::NoAutoHighlightHiddenState::OnHoverChanged() {}

void InkDropImpl::NoAutoHighlightHiddenState::ShowOnFocusChanged() {}

void InkDropImpl::NoAutoHighlightHiddenState::OnFocusChanged() {}

void InkDropImpl::NoAutoHighlightHiddenState::HandleHoverAndFocusChangeChanges(
    base::TimeDelta animation_duration) {}

void InkDropImpl::NoAutoHighlightHiddenState::AnimationStarted(
    InkDropState ink_drop_state) {}

void InkDropImpl::NoAutoHighlightHiddenState::AnimationEnded(
    InkDropState ink_drop_state,
    InkDropAnimationEndedReason reason) {}

// NoAutoHighlightVisibleState definition

InkDropImpl::NoAutoHighlightVisibleState::NoAutoHighlightVisibleState(
    HighlightStateFactory* state_factory,
    base::TimeDelta animation_duration)
    :{}

void InkDropImpl::NoAutoHighlightVisibleState::Enter() {}

void InkDropImpl::NoAutoHighlightVisibleState::ShowOnHoverChanged() {}

void InkDropImpl::NoAutoHighlightVisibleState::OnHoverChanged() {}

void InkDropImpl::NoAutoHighlightVisibleState::ShowOnFocusChanged() {}

void InkDropImpl::NoAutoHighlightVisibleState::OnFocusChanged() {}

void InkDropImpl::NoAutoHighlightVisibleState::HandleHoverAndFocusChangeChanges(
    base::TimeDelta animation_duration) {}

void InkDropImpl::NoAutoHighlightVisibleState::AnimationStarted(
    InkDropState ink_drop_state) {}

void InkDropImpl::NoAutoHighlightVisibleState::AnimationEnded(
    InkDropState ink_drop_state,
    InkDropAnimationEndedReason reason) {}

//
// AutoHighlightMode::HIDE_ON_RIPPLE states
//

// Extends the base hidden state to re-show the highlight after the ripple
// becomes hidden.
class InkDropImpl::HideHighlightOnRippleHiddenState
    : public InkDropImpl::NoAutoHighlightHiddenState {};

// Extends the base visible state to hide the highlight when the ripple becomes
// visible.
class InkDropImpl::HideHighlightOnRippleVisibleState
    : public InkDropImpl::NoAutoHighlightVisibleState {};

// HideHighlightOnRippleHiddenState definition

InkDropImpl::HideHighlightOnRippleHiddenState::HideHighlightOnRippleHiddenState(
    HighlightStateFactory* state_factory,
    base::TimeDelta animation_duration)
    :{}

void InkDropImpl::HideHighlightOnRippleHiddenState::ShowOnHoverChanged() {}

void InkDropImpl::HideHighlightOnRippleHiddenState::OnHoverChanged() {}

void InkDropImpl::HideHighlightOnRippleHiddenState::ShowOnFocusChanged() {}

void InkDropImpl::HideHighlightOnRippleHiddenState::OnFocusChanged() {}

void InkDropImpl::HideHighlightOnRippleHiddenState::AnimationStarted(
    InkDropState ink_drop_state) {}

void InkDropImpl::HideHighlightOnRippleHiddenState::AnimationEnded(
    InkDropState ink_drop_state,
    InkDropAnimationEndedReason reason) {}

void InkDropImpl::HideHighlightOnRippleHiddenState::
    StartHighlightAfterRippleTimer() {}

void InkDropImpl::HideHighlightOnRippleHiddenState::
    HighlightAfterRippleTimerFired() {}

// HideHighlightOnRippleVisibleState definition

InkDropImpl::HideHighlightOnRippleVisibleState::
    HideHighlightOnRippleVisibleState(HighlightStateFactory* state_factory,
                                      base::TimeDelta animation_duration)
    :{}

void InkDropImpl::HideHighlightOnRippleVisibleState::AnimationStarted(
    InkDropState ink_drop_state) {}

//
// AutoHighlightMode::SHOW_ON_RIPPLE states
//

// Extends the base hidden state to show the highlight when the ripple becomes
// visible.
class InkDropImpl::ShowHighlightOnRippleHiddenState
    : public InkDropImpl::NoAutoHighlightHiddenState {};

// Extends the base visible state to hide the highlight when the ripple becomes
// hidden.
class InkDropImpl::ShowHighlightOnRippleVisibleState
    : public InkDropImpl::NoAutoHighlightVisibleState {};

// ShowHighlightOnRippleHiddenState definition

InkDropImpl::ShowHighlightOnRippleHiddenState::ShowHighlightOnRippleHiddenState(
    HighlightStateFactory* state_factory,
    base::TimeDelta animation_duration)
    :{}

void InkDropImpl::ShowHighlightOnRippleHiddenState::AnimationStarted(
    InkDropState ink_drop_state) {}

// ShowHighlightOnRippleVisibleState definition

InkDropImpl::ShowHighlightOnRippleVisibleState::
    ShowHighlightOnRippleVisibleState(HighlightStateFactory* state_factory,
                                      base::TimeDelta animation_duration)
    :{}

void InkDropImpl::ShowHighlightOnRippleVisibleState::ShowOnHoverChanged() {}

void InkDropImpl::ShowHighlightOnRippleVisibleState::OnHoverChanged() {}

void InkDropImpl::ShowHighlightOnRippleVisibleState::ShowOnFocusChanged() {}

void InkDropImpl::ShowHighlightOnRippleVisibleState::OnFocusChanged() {}

void InkDropImpl::ShowHighlightOnRippleVisibleState::AnimationStarted(
    InkDropState ink_drop_state) {}

InkDropImpl::HighlightStateFactory::HighlightStateFactory(
    InkDropImpl::AutoHighlightMode highlight_mode,
    InkDropImpl* ink_drop)
    :{}

std::unique_ptr<InkDropImpl::HighlightState>
InkDropImpl::HighlightStateFactory::CreateStartState() {}

std::unique_ptr<InkDropImpl::HighlightState>
InkDropImpl::HighlightStateFactory::CreateHiddenState(
    base::TimeDelta animation_duration) {}

std::unique_ptr<InkDropImpl::HighlightState>
InkDropImpl::HighlightStateFactory::CreateVisibleState(
    base::TimeDelta animation_duration) {}

InkDropImpl::InkDropImpl(InkDropHost* ink_drop_host,
                         const gfx::Size& host_size,
                         AutoHighlightMode auto_highlight_mode)
    :{}

InkDropImpl::~InkDropImpl() {}

void InkDropImpl::HostSizeChanged(const gfx::Size& new_size) {}

void InkDropImpl::HostViewThemeChanged() {}

void InkDropImpl::HostTransformChanged(const gfx::Transform& new_transform) {}

InkDropState InkDropImpl::GetTargetInkDropState() const {}

void InkDropImpl::AnimateToState(InkDropState ink_drop_state) {}

void InkDropImpl::SetHoverHighlightFadeDuration(base::TimeDelta duration) {}

void InkDropImpl::UseDefaultHoverHighlightFadeDuration() {}

void InkDropImpl::SnapToActivated() {}

void InkDropImpl::SnapToHidden() {}

void InkDropImpl::SetHovered(bool is_hovered) {}

void InkDropImpl::SetFocused(bool is_focused) {}

bool InkDropImpl::IsHighlightFadingInOrVisible() const {}

void InkDropImpl::SetShowHighlightOnHover(bool show_highlight_on_hover) {}

void InkDropImpl::SetShowHighlightOnFocus(bool show_highlight_on_focus) {}

void InkDropImpl::DestroyHiddenTargetedAnimations() {}

void InkDropImpl::CreateInkDropRipple() {}

void InkDropImpl::DestroyInkDropRipple() {}

void InkDropImpl::CreateInkDropHighlight() {}

void InkDropImpl::DestroyInkDropHighlight() {}

void InkDropImpl::AddRootLayerToHostIfNeeded() {}

void InkDropImpl::RemoveRootLayerFromHostIfNeeded() {}

// -----------------------------------------------------------------------------
// views::InkDropRippleObserver:

void InkDropImpl::AnimationStarted(InkDropState ink_drop_state) {}

void InkDropImpl::AnimationEnded(InkDropState ink_drop_state,
                                 InkDropAnimationEndedReason reason) {}

// -----------------------------------------------------------------------------
// views::InkDropHighlightObserver:

void InkDropImpl::AnimationStarted(
    InkDropHighlight::AnimationType animation_type) {}

void InkDropImpl::AnimationEnded(InkDropHighlight::AnimationType animation_type,
                                 InkDropAnimationEndedReason reason) {}

void InkDropImpl::SetHighlight(bool should_highlight,
                               base::TimeDelta animation_duration) {}

bool InkDropImpl::ShouldHighlight() const {}

bool InkDropImpl::ShouldHighlightBasedOnFocus() const {}

void InkDropImpl::SetHighlightState(
    std::unique_ptr<HighlightState> highlight_state) {}

void InkDropImpl::ExitHighlightState() {}

void InkDropImpl::RecreateRippleAndHighlight() {}

}  // namespace views