summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 23:24:23 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 23:24:23 +0000
commit8c8d9a30879460088e60797c98537fd90a23d998 (patch)
tree20d2ed1168c2d72302d4c531568bafb9d501b82b /chrome
parent0ac5ce097edbbc2f7f0f362c30f51e79c513f493 (diff)
downloadchromium_src-8c8d9a30879460088e60797c98537fd90a23d998.zip
chromium_src-8c8d9a30879460088e60797c98537fd90a23d998.tar.gz
chromium_src-8c8d9a30879460088e60797c98537fd90a23d998.tar.bz2
[Mac] Adds animations for the download shelf.
Nib file changes: - Connected DownloadShelfView's delegate_ to DownloadShelfController. BUG=http://crbug.com/25602 TEST=Download shelf should animate open/closed. Review URL: http://codereview.chromium.org/342083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/DownloadShelf.xib37
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h4
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm31
-rw-r--r--chrome/browser/cocoa/download_shelf_view.h4
-rw-r--r--chrome/browser/cocoa/download_started_animation_mac.mm5
5 files changed, 70 insertions, 11 deletions
diff --git a/chrome/app/nibs/DownloadShelf.xib b/chrome/app/nibs/DownloadShelf.xib
index 1e062d13..1b7afe1 100644
--- a/chrome/app/nibs/DownloadShelf.xib
+++ b/chrome/app/nibs/DownloadShelf.xib
@@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10B504</string>
- <string key="IBDocument.InterfaceBuilderVersion">732</string>
+ <string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.2</string>
<string key="IBDocument.HIToolboxVersion">437.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">732</string>
+ <string key="NS.object.0">740</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -421,6 +421,14 @@
</object>
<int key="connectionID">22</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate_</string>
+ <reference key="source" ref="1005"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">23</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -579,12 +587,33 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">22</int>
+ <int key="maxID">23</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
+ <string key="className">AnimatableView</string>
+ <string key="superclassName">NSView</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>delegate_</string>
+ <string>resizeDelegate_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/animatable_view.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">DownloadShelfController</string>
<string key="superclassName">NSViewController</string>
<object class="NSMutableDictionary" key="actions">
@@ -626,7 +655,7 @@
</object>
<object class="IBPartialClassDescription">
<string key="className">DownloadShelfView</string>
- <string key="superclassName">NSView</string>
+ <string key="superclassName">AnimatableView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">browser/cocoa/download_shelf_view.h</string>
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index d310f7f..cc6413c 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -9,6 +9,7 @@
#include "base/scoped_ptr.h"
#import "chrome/browser/cocoa/view_resizer.h"
+@class AnimatableView;
class BaseDownloadItemModel;
class Browser;
@class BrowserWindowController;
@@ -58,6 +59,9 @@ class DownloadShelf;
- (id)initWithBrowser:(Browser*)browser
resizeDelegate:(id<ViewResizer>)resizeDelegate;
+// Returns our view cast as an AnimatableView.
+- (AnimatableView*)animatableView;
+
- (DownloadShelf*)bridge;
- (BOOL)isVisible;
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 122a132..81af11e 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -9,6 +9,7 @@
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser.h"
+#import "chrome/browser/cocoa/animatable_view.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/download_item_controller.h"
@@ -30,6 +31,9 @@ const int kDownloadItemPadding = 0;
// Duration for the open-new-leftmost-item animation, in seconds.
const NSTimeInterval kDownloadItemOpenDuration = 0.8;
+// Duration for download shelf closing animation, in seconds.
+const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
+
} // namespace
@interface DownloadShelfController(Private)
@@ -67,6 +71,8 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8;
}
- (void)awakeFromNib {
+ [[self animatableView] setResizeDelegate:resizeDelegate_];
+
// Initialize "Show all downloads" link.
scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
@@ -103,6 +109,10 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8;
[super dealloc];
}
+- (AnimatableView*)animatableView {
+ return static_cast<AnimatableView*>([self view]);
+}
+
- (void)resizeDownloadLinkToFit {
// Get width required by localized download link text.
// http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html
@@ -163,6 +173,7 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8;
// We need to explicitly release our download controllers here since they need
// to remove themselves as observers before the remaining shutdown happens.
- (void)exiting {
+ [[self animatableView] stopAnimation];
downloadItemControllers_.reset();
}
@@ -172,8 +183,17 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8;
if ([self isVisible] == enable)
return;
- [resizeDelegate_ resizeView:[self view]
- newHeight:(enable ? shelfHeight_ : 0)];
+ // Animate the shelf out, but not in.
+ // TODO(rohitrao): We do not animate on the way in because Cocoa is already
+ // doing a lot of work to set up the download arrow animation. I've chosen to
+ // do no animation over janky animation. Find a way to make animating in
+ // smoother.
+ AnimatableView* view = [self animatableView];
+ if (enable)
+ [view setHeight:shelfHeight_];
+ else
+ [view animateToNewHeight:0 duration:kDownloadShelfCloseDuration];
+
barIsVisible_ = enable;
}
@@ -197,10 +217,11 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8;
bridge_->Close();
else
[self showDownloadShelf:NO];
+}
- // TODO(port): When closing the shelf is animated, call this only after the
- // animation has ended:
- [self closed];
+- (void)animationDidEnd:(NSAnimation*)animation {
+ if (![self isVisible])
+ [self closed];
}
- (float)height {
diff --git a/chrome/browser/cocoa/download_shelf_view.h b/chrome/browser/cocoa/download_shelf_view.h
index d69b139..5b05dd6 100644
--- a/chrome/browser/cocoa/download_shelf_view.h
+++ b/chrome/browser/cocoa/download_shelf_view.h
@@ -7,10 +7,12 @@
#import <Cocoa/Cocoa.h>
+#import "chrome/browser/cocoa/animatable_view.h"
+
// A view that handles any special rendering for the download shelf, painting
// a gradient and managing a set of DownloadItemViews.
-@interface DownloadShelfView : NSView {
+@interface DownloadShelfView : AnimatableView {
}
@end
diff --git a/chrome/browser/cocoa/download_started_animation_mac.mm b/chrome/browser/cocoa/download_started_animation_mac.mm
index c2536f0..dde9101 100644
--- a/chrome/browser/cocoa/download_started_animation_mac.mm
+++ b/chrome/browser/cocoa/download_started_animation_mac.mm
@@ -145,8 +145,11 @@ private:
NSPoint stop = NSMakePoint(0, 0); // Bottom of the tab.
// Set for the duration of the animation, or we won't see our layer. We reset
- // this in the completion callback.
+ // this in the completion callback. Layers by default scale their content to
+ // fit, but we need them to clip their content instead, or else renderer
+ // resizes will look janky.
[view_ setWantsLayer:YES];
+ [[view_ layer] setContentsGravity:kCAGravityTopLeft];
// CALayer initalization.
layer_.reset([[CALayer layer] retain]);