summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 06:57:52 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 06:57:52 +0000
commited0e334ab55d847c3a53ef6def07fa8ddfd34b34 (patch)
treea18e7a7346f164015acaf1a82810721825906bb4 /chrome/browser/cocoa/bookmark_bar_folder_controller.mm
parentd0edf4e5adf877515ff49a59f63600fd88a25b36 (diff)
downloadchromium_src-ed0e334ab55d847c3a53ef6def07fa8ddfd34b34.zip
chromium_src-ed0e334ab55d847c3a53ef6def07fa8ddfd34b34.tar.gz
chromium_src-ed0e334ab55d847c3a53ef6def07fa8ddfd34b34.tar.bz2
Mac: Improve bookmark bar menus.
Make them a bit smaller, and make them stay on-screen horizontally (like normal menus) BUG=36487 TEST=open menu while its folder is close to the screen edge. Review URL: http://codereview.chromium.org/857007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_folder_controller.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_folder_controller.mm12
1 files changed, 11 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
index 88a5f21..b17b19c 100644
--- a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
@@ -255,9 +255,19 @@
[button setFrame:buttonFrame];
}
- // Finally, set our window size.
+ // Finally, set our window size (make sure it fits on screen).
width += (2 * bookmarks::kBookmarkVerticalPadding);
windowFrame.size.width = width;
+
+ // Make the window fit on screen, with a distance of at least |padding| to
+ // the sides.
+ const CGFloat padding = 8;
+ NSRect screenFrame = [[[self window] screen] frame];
+ if (NSMaxX(windowFrame) + padding > NSMaxX(screenFrame))
+ windowFrame.origin.x -= NSMaxX(windowFrame) + padding - NSMaxX(screenFrame);
+ else if (NSMinX(windowFrame) - padding < NSMinX(screenFrame))
+ windowFrame.origin.x += NSMinX(screenFrame) - NSMinX(windowFrame) + padding;
+
[[self window] setFrame:windowFrame display:YES];
[[parentController_ parentWindow] addChildWindow:[self window]