summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/download_shelf_controller.mm
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 22:18:43 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 22:18:43 +0000
commitfdb244d98291c7f801bb0a36c06de4a71b4895ae (patch)
tree39e8ace1cd1e68b98a9c45ba1f7a9f659e3ef005 /chrome/browser/cocoa/download_shelf_controller.mm
parentcec6f9b08dd24625cd40df548810561b5a55e7d6 (diff)
downloadchromium_src-fdb244d98291c7f801bb0a36c06de4a71b4895ae.zip
chromium_src-fdb244d98291c7f801bb0a36c06de4a71b4895ae.tar.gz
chromium_src-fdb244d98291c7f801bb0a36c06de4a71b4895ae.tar.bz2
Mac: Let download shelf slide out to bottom instead of just clamping its height.
Review URL: http://codereview.chromium.org/2303002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/download_shelf_controller.mm')
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm32
1 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 0d7f884..53501c3 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -47,6 +47,7 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
- (void)updateTheme;
- (void)themeDidChangeNotification:(NSNotification*)notification;
+- (void)viewFrameDidChange:(NSNotification*)notification;
@end
@@ -57,7 +58,8 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
if ((self = [super initWithNibName:@"DownloadShelf"
bundle:mac_util::MainAppBundle()])) {
resizeDelegate_ = resizeDelegate;
- shelfHeight_ = [[self view] bounds].size.height;
+ maxShelfHeight_ = NSHeight([[self view] bounds]);
+ currentShelfHeight_ = maxShelfHeight_;
// Reset the download shelf's frame height to zero. It will be properly
// positioned and sized the first time we try to set its height. (Just
@@ -83,7 +85,12 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
object:nil];
[[self animatableView] setResizeDelegate:resizeDelegate_];
-
+ [[self view] setPostsFrameChangedNotifications:YES];
+ [defaultCenter addObserver:self
+ selector:@selector(viewFrameDidChange:)
+ name:NSViewFrameDidChangeNotification
+ object:[self view]];
+
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
NSImage* favicon = rb.GetNSImageNamed(IDR_DOWNLOADS_FAVICON);
DCHECK(favicon);
@@ -103,6 +110,23 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
[self updateTheme];
}
+// Called after the frame's rect has changed; usually when the height is
+// animated.
+- (void)viewFrameDidChange:(NSNotification*)notification {
+ // Anchor subviews at the top of |view|, so that it looks like the shelf
+ // is sliding out.
+ CGFloat newShelfHeight = NSHeight([[self view] frame]);
+ if (newShelfHeight == currentShelfHeight_)
+ return;
+
+ for (NSView* view in [[self view] subviews]) {
+ NSRect frame = [view frame];
+ frame.origin.y -= currentShelfHeight_ - newShelfHeight;
+ [view setFrame:frame];
+ }
+ currentShelfHeight_ = newShelfHeight;
+}
+
// Adapt appearance to the current theme. Called after theme changes and before
// this is shown for the first time.
- (void)updateTheme {
@@ -171,7 +195,7 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
// smoother.
AnimatableView* view = [self animatableView];
if (enable)
- [view setHeight:shelfHeight_];
+ [view setHeight:maxShelfHeight_];
else
[view animateToNewHeight:0 duration:kDownloadShelfCloseDuration];
@@ -206,7 +230,7 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
}
- (float)height {
- return shelfHeight_;
+ return maxShelfHeight_;
}
// If |skipFirst| is true, the frame of the leftmost item is not set.