blob: 96783e70473de761c602f5d34fc1de4caadbf52c [file] [log] [blame]
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/overlay/overlay_controls_fade_animation.h"
#include "ui/compositor/layer.h"
#include "ui/views/view.h"
namespace {
constexpr base::TimeDelta kDuration = base::Milliseconds(250);
} // namespace
OverlayControlsFadeAnimation::OverlayControlsFadeAnimation(
views::View& controls,
Type type)
: gfx::LinearAnimation(kDuration, kDefaultFrameRate, nullptr),
controls_(controls),
type_(type) {}
OverlayControlsFadeAnimation::~OverlayControlsFadeAnimation() = default;
void OverlayControlsFadeAnimation::AnimateToState(double state) {
const double opacity = (type_ == Type::kToShown) ? state : (1.0 - state);
controls_->SetVisible(opacity != 0);
controls_->layer()->SetOpacity(opacity);
}