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

Unified Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 8773030: Implement 3-stage minimize animation for Panels on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lowered close button 1 px Created 9 years, 1 month 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_window_controller_cocoa.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_window_controller_cocoa.mm
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index 06e69df40e587410dc730d05bad69c18ca377ad3..797573a46a34f9cc8023a7cdb040b4d0e08104e6 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -428,20 +428,19 @@ enum {
// Will be enabled back in animationDidEnd callback.
[self disableTabContentsViewAutosizing];
+ // Terminate previous animation, if it is still playing.
+ [self terminateBoundsAnimation];
+
NSDictionary *windowResize = [NSDictionary dictionaryWithObjectsAndKeys:
[self window], NSViewAnimationTargetKey,
[NSValue valueWithRect:frame], NSViewAnimationEndFrameKey, nil];
NSArray *animations = [NSArray arrayWithObjects:windowResize, nil];
- // Terminate previous animation, if it is still playing.
- [self terminateBoundsAnimation];
boundsAnimation_ =
[[NSViewAnimation alloc] initWithViewAnimations:animations];
[boundsAnimation_ setDelegate:self];
- [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking];
-
NSRect currentFrame = [[self window] frame];
// Compute duration. We use constant speed of animation, however if the change
// is too large, we clip the duration (effectively increasing speed) to
@@ -454,11 +453,55 @@ enum {
double distance = std::max(distanceX, distanceY);
double duration = std::min(distance / kBoundsAnimationSpeedPixelsPerSecond,
kBoundsAnimationMaxDurationSeconds);
+ // 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.
+ if (windowShim_->panel()->expansion_state() == Panel::MINIMIZED) {
+ float titlebarToFrameProportion =
+ (windowShim_->TitleOnlyHeight() - NSHeight(frame)) / distanceY;
jianli 2011/12/02 06:18:32 Is NSHeight(frame) for the height of the expanded
Dmitry Titov 2011/12/02 06:47:10 The |frame| here is a new frame, since we are mini
+ if (titlebarToFrameProportion < 0.3) { // Relatively big movement.
+ playingMinimizeAnimation_ = YES;
+ animationSpeedThreshold_ = 1.0 - titlebarToFrameProportion;
+ duration = 1.5;
+ }
+ }
[boundsAnimation_ setDuration: duration];
+ [boundsAnimation_ setFrameRate:0.0];
+ [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking];
[boundsAnimation_ startAnimation];
}
+- (float)animation:(NSAnimation*)animation
+ valueForProgress:(NSAnimationProgress)progress {
+ if (!playingMinimizeAnimation_) {
+ // 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 float kAnimationStopAfterQuickDecrease = 0.15;
+ const float kAnimationStopAfterShowingTitlebar = 0.6;
+ float value;
+ if (progress <= kAnimationStopAfterQuickDecrease)
jianli 2011/12/02 06:18:32 nit: better to add brackets.
Dmitry Titov 2011/12/02 06:47:10 Done.
+ value =
+ progress * animationSpeedThreshold_ / kAnimationStopAfterQuickDecrease;
+ else if (progress <= kAnimationStopAfterShowingTitlebar)
+ value = animationSpeedThreshold_;
+ else
+ value = animationSpeedThreshold_ +
+ (progress - kAnimationStopAfterShowingTitlebar) *
+ (1.0 - animationSpeedThreshold_) /
+ (1.0 - kAnimationStopAfterShowingTitlebar);
+ return value;
+}
+
- (void)animationDidEnd:(NSAnimation*)animation {
+ playingMinimizeAnimation_ = NO;
if (windowShim_->panel()->expansion_state() == Panel::EXPANDED)
[self enableTabContentsViewAutosizing];
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698