This source file includes following definitions.
- animation_stop_to_show_titlebar_
- GetCurrentValue
- ComputeAnimationValue
#include "chrome/browser/ui/panels/panel_bounds_animation.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
namespace {
const int kDefaultFramerateHz = 50;
const int kSetBoundsAnimationMs = 180;
const int kSetBoundsAnimationBigMinimizeMs = 1500;
}
PanelBoundsAnimation::PanelBoundsAnimation(gfx::AnimationDelegate* target,
Panel* panel,
const gfx::Rect& initial_bounds,
const gfx::Rect& final_bounds)
: gfx::LinearAnimation(kDefaultFramerateHz, target),
panel_(panel),
for_big_minimize_(false),
animation_stop_to_show_titlebar_(0) {
int duration = kSetBoundsAnimationMs;
if (initial_bounds.height() > final_bounds.height() &&
panel_->expansion_state() == Panel::MINIMIZED) {
double hidden_title_height =
panel_->TitleOnlyHeight() - final_bounds.height();
double distance_y = initial_bounds.height() - final_bounds.height();
animation_stop_to_show_titlebar_ = 1.0 - hidden_title_height / distance_y;
if (animation_stop_to_show_titlebar_ > 0.7) {
for_big_minimize_ = true;
duration = kSetBoundsAnimationBigMinimizeMs;
}
}
SetDuration(PanelManager::AdjustTimeInterval(duration));
}
PanelBoundsAnimation::~PanelBoundsAnimation() {
}
double PanelBoundsAnimation::GetCurrentValue() const {
return ComputeAnimationValue(gfx::LinearAnimation::GetCurrentValue(),
for_big_minimize_,
animation_stop_to_show_titlebar_);
}
double PanelBoundsAnimation::ComputeAnimationValue(double progress,
bool for_big_minimize, double animation_stop_to_show_titlebar) {
if (!for_big_minimize) {
double value = 1.0 - progress;
return 1.0 - value * value * value;
}
const double kProgressAtFreezeStart = 0.15;
const double kProgressAtFreezeEnd = 0.6;
double value;
if (progress <= kProgressAtFreezeStart) {
value = animation_stop_to_show_titlebar *
(progress / kProgressAtFreezeStart);
} else if (progress <= kProgressAtFreezeEnd) {
value = animation_stop_to_show_titlebar;
} else {
value = animation_stop_to_show_titlebar +
(1.0 - animation_stop_to_show_titlebar) *
((progress - kProgressAtFreezeEnd) / (1.0 - kProgressAtFreezeEnd));
}
return value;
}