Commit b00e20b0 authored by dimich@chromium.org's avatar dimich@chromium.org

Add 3-stage animation for minimization of Panels on Win.

BUG=104645

Review URL: http://codereview.chromium.org/8787009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112931 0039d316-1c4b-4281-b951-d872f2087c98
parent 8dc48c62
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -25,6 +24,7 @@ ...@@ -25,6 +24,7 @@
namespace { namespace {
// This value is experimental and subjective. // This value is experimental and subjective.
const int kSetBoundsAnimationMs = 180; const int kSetBoundsAnimationMs = 180;
const int kSetBoundsAnimationMinimizeMs = 1500;
// The threshold to differentiate the short click and long click. // The threshold to differentiate the short click and long click.
const int kShortClickThresholdMs = 200; const int kShortClickThresholdMs = 200;
...@@ -35,6 +35,35 @@ const int kSuspendMinimizeOnClickIntervalMs = 500; ...@@ -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, NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds);
...@@ -140,13 +169,26 @@ void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds, ...@@ -140,13 +169,26 @@ void PanelBrowserView::SetBoundsInternal(const gfx::Rect& new_bounds,
animation_start_bounds_ = GetBounds(); animation_start_bounds_ = GetBounds();
if (!bounds_animator_.get()) { // Detect animation that happens when expansion state is set to MINIMIZED
bounds_animator_.reset(new ui::SlideAnimation(this)); // and there is relatively big portion of the panel to hide from view.
bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); // 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(new PanelSlideAnimation(
bounds_animator_->Reset(); this, for_minimize, animation_stop_to_show_titlebar));
bounds_animator_->SetSlideDuration(duration);
bounds_animator_->Show(); bounds_animator_->Show();
} }
......
...@@ -12,14 +12,28 @@ ...@@ -12,14 +12,28 @@
#include "chrome/browser/ui/panels/native_panel.h" #include "chrome/browser/ui/panels/native_panel.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/animation_delegate.h"
#include "ui/base/animation/slide_animation.h"
class Browser; class Browser;
class Panel; class Panel;
class NativePanelTestingWin; class NativePanelTestingWin;
class PanelBrowserFrameView; class PanelBrowserFrameView;
namespace ui {
class SlideAnimation; class PanelSlideAnimation : public ui::SlideAnimation {
} public:
PanelSlideAnimation(ui::AnimationDelegate* target,
bool for_minimize,
double animation_stop_to_show_titlebar)
: ui::SlideAnimation(target),
for_minimize_(for_minimize),
animation_stop_to_show_titlebar_(animation_stop_to_show_titlebar) { }
virtual ~PanelSlideAnimation() { }
virtual double GetCurrentValue() const OVERRIDE;
private:
bool for_minimize_;
double animation_stop_to_show_titlebar_;
};
// A browser view that implements Panel specific behavior. // A browser view that implements Panel specific behavior.
class PanelBrowserView : public BrowserView, class PanelBrowserView : public BrowserView,
...@@ -148,7 +162,7 @@ class PanelBrowserView : public BrowserView, ...@@ -148,7 +162,7 @@ class PanelBrowserView : public BrowserView,
MouseDraggingState mouse_dragging_state_; MouseDraggingState mouse_dragging_state_;
// Used to animate the bounds change. // Used to animate the bounds change.
scoped_ptr<ui::SlideAnimation> bounds_animator_; scoped_ptr<PanelSlideAnimation> bounds_animator_;
gfx::Rect animation_start_bounds_; gfx::Rect animation_start_bounds_;
// Is the panel in highlighted state to draw people's attention? // Is the panel in highlighted state to draw people's attention?
......
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