| Index: chrome/browser/ui/panels/panel_browser_view.cc
|
| diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
|
| index 6bb2108a3708f11034744c4bdcf958eca1b87cb8..7e676c49ecb5bd3c736adfe88dfaeb0ab038cea1 100644
|
| --- a/chrome/browser/ui/panels/panel_browser_view.cc
|
| +++ b/chrome/browser/ui/panels/panel_browser_view.cc
|
| @@ -17,7 +17,6 @@
|
| #include "chrome/common/chrome_switches.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "grit/chromium_strings.h"
|
| -#include "ui/base/animation/slide_animation.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/views/controls/label.h"
|
| #include "ui/views/widget/widget.h"
|
| @@ -25,6 +24,7 @@
|
| namespace {
|
| // This value is experimental and subjective.
|
| const int kSetBoundsAnimationMs = 180;
|
| +const int kSetBoundsAnimationMinimizeMs = 1500;
|
|
|
| // The threshold to differentiate the short click and long click.
|
| const int kShortClickThresholdMs = 200;
|
| @@ -35,6 +35,35 @@ const int kSuspendMinimizeOnClickIntervalMs = 500;
|
|
|
| }
|
|
|
| +double PanelSlideAnimation::GetCurrentValue() const {
|
| + double progress = ui::SlideAnimation::GetCurrentValue();
|
| + if (!for_minimize_) {
|
| + // Cubic easing out.
|
| + float value = 1.0 - progress;
|
| + return 1.0 - value * value * value;
|
| + }
|
| +
|
| + // Minimize animation:
|
| + // 1. Quickly (0 -> 0.15) make only titlebar visible.
|
| + // 2. Stay a little bit (0.15->0.6) in place, just showing titlebar.
|
| + // 3. Slowly minimize to thin strip (0.6->1.0)
|
| + const double kAnimationStopAfterQuickDecrease = 0.15;
|
| + const double kAnimationStopAfterShowingTitlebar = 0.6;
|
| + double value;
|
| + if (progress <= kAnimationStopAfterQuickDecrease) {
|
| + value = progress * animation_stop_to_show_titlebar_ /
|
| + kAnimationStopAfterQuickDecrease;
|
| + } else if (progress <= kAnimationStopAfterShowingTitlebar) {
|
| + value = animation_stop_to_show_titlebar_;
|
| + } else {
|
| + value = animation_stop_to_show_titlebar_ +
|
| + (progress - kAnimationStopAfterShowingTitlebar) *
|
| + (1.0 - animation_stop_to_show_titlebar_) /
|
| + (1.0 - kAnimationStopAfterShowingTitlebar);
|
| + }
|
| + return value;
|
| +}
|
| +
|
| NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
|
| const gfx::Rect& bounds) {
|
| PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds);
|
| @@ -140,13 +169,26 @@ void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds,
|
|
|
| animation_start_bounds_ = GetBounds();
|
|
|
| - if (!bounds_animator_.get()) {
|
| - bounds_animator_.reset(new ui::SlideAnimation(this));
|
| - bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs);
|
| + // Detect animation that happens when expansion state is set to MINIMIZED
|
| + // and there is relatively big portion of the panel to hide from view.
|
| + // Initialize animation differently in this case, using fast-pause-slow
|
| + // method, see below for more details.
|
| + double animation_stop_to_show_titlebar = 0;
|
| + bool for_minimize = false;
|
| + int duration = kSetBoundsAnimationMs;
|
| + if (panel_->expansion_state() == Panel::MINIMIZED) {
|
| + animation_stop_to_show_titlebar =
|
| + 1.0 - static_cast<double>((TitleOnlyHeight() - new_bounds.height())) /
|
| + (GetBounds().height() - new_bounds.height());
|
| + if (animation_stop_to_show_titlebar > 0.7) { // Relatively big movement.
|
| + for_minimize = true;
|
| + duration = kSetBoundsAnimationMinimizeMs;
|
| + }
|
| }
|
|
|
| - if (bounds_animator_->IsShowing())
|
| - bounds_animator_->Reset();
|
| + bounds_animator_.reset(new PanelSlideAnimation(
|
| + this, for_minimize, animation_stop_to_show_titlebar));
|
| + bounds_animator_->SetSlideDuration(duration);
|
| bounds_animator_->Show();
|
| }
|
|
|
|
|