Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2953)

Unified Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 8787009: Add 3-stage animation for minimization of Panels on Win. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3b217ef9b99670bb1adc9567bb1b64dec5e4bad9..7964a117dd105112179d71cec36426edeae8195a 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -23,6 +23,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;
@@ -33,6 +34,51 @@ const int kSuspendMinimizeOnClickIntervalMs = 500;
}
+class CustomSlideAnimation : public ui::SlideAnimation {
+ public:
+ CustomSlideAnimation(ui::AnimationDelegate* target,
+ bool do_minimize,
+ double animation_stop_to_show_titlebar)
+ : ui::SlideAnimation(target),
+ do_minimize_(do_minimize),
+ animation_stop_to_show_titlebar_(animation_stop_to_show_titlebar) { }
+
+ virtual ~CustomSlideAnimation() {}
+ virtual double GetCurrentValue() const OVERRIDE;
+ private:
jianli 2011/12/03 01:08:06 nit: empty line
Dmitry Titov 2011/12/03 01:27:52 Done.
+ bool do_minimize_;
jianli 2011/12/03 01:08:06 nit: probably for_minimize_ sounds better?
Dmitry Titov 2011/12/03 01:27:52 Done.
+ double animation_stop_to_show_titlebar_;
+};
+
+double CustomSlideAnimation::GetCurrentValue() const {
+ double progress = ui::SlideAnimation::GetCurrentValue();
+ if (!do_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_ /
jianli 2011/12/03 01:08:06 nit: indenting
Dmitry Titov 2011/12/03 01:27:52 Done.
+ 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);
@@ -128,13 +174,26 @@ void PanelBrowserView::SetBoundsInternal(const gfx::Rect& 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 do_minimize = false;
+ int duration = kSetBoundsAnimationMs;
+ if (panel_->expansion_state() == Panel::MINIMIZED) {
+ animation_stop_to_show_titlebar =
+ 1.0 - static_cast<double>((TitleOnlyHeight() - bounds.height())) /
+ (GetBounds().height() - bounds.height());
+ if (animation_stop_to_show_titlebar > 0.7) { // Relatively big movement.
+ do_minimize = true;
+ duration = kSetBoundsAnimationMinimizeMs;
+ }
}
- if (bounds_animator_->IsShowing())
- bounds_animator_->Reset();
+ bounds_animator_.reset(new CustomSlideAnimation(
+ this, do_minimize, animation_stop_to_show_titlebar));
+ bounds_animator_->SetSlideDuration(duration);
bounds_animator_->Show();
}
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698