summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm2
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h8
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm32
3 files changed, 36 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 962b96b..bd89e6a 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -764,7 +764,7 @@
// to "grow up" or "grow down." The below call to |-layoutSubviews| will
// position each view correctly.
NSRect frame = [view frame];
- if (frame.size.height == height)
+ if (NSHeight(frame) == height)
return;
// Grow or shrink the window by the amount of the height change. We adjust
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index 92411e8..5895cfc 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -44,7 +44,13 @@ class DownloadShelf;
BOOL barIsVisible_;
scoped_ptr<DownloadShelf> bridge_;
- float shelfHeight_;
+
+ // Height of the shelf when it's fully visible.
+ CGFloat maxShelfHeight_;
+
+ // Current height of the shelf. Changes while the shelf is animating in or
+ // out.
+ CGFloat currentShelfHeight_;
// The download items we have added to our shelf.
scoped_nsobject<NSMutableArray> downloadItemControllers_;
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.