| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 [[parentButton_ window] | 519 [[parentButton_ window] |
| 520 convertBaseToScreen:[parentButton_ | 520 convertBaseToScreen:[parentButton_ |
| 521 convertPoint:NSZeroPoint toView:nil]]; | 521 convertPoint:NSZeroPoint toView:nil]]; |
| 522 NSPoint bookmarkBarBottomLeftInScreen = | 522 NSPoint bookmarkBarBottomLeftInScreen = |
| 523 [[parentButton_ window] | 523 [[parentButton_ window] |
| 524 convertBaseToScreen:[[parentButton_ superview] | 524 convertBaseToScreen:[[parentButton_ superview] |
| 525 convertPoint:NSZeroPoint toView:nil]]; | 525 convertPoint:NSZeroPoint toView:nil]]; |
| 526 newWindowTopLeft = NSMakePoint( | 526 newWindowTopLeft = NSMakePoint( |
| 527 buttonBottomLeftInScreen.x + bookmarks::kBookmarkBarButtonOffset, | 527 buttonBottomLeftInScreen.x + bookmarks::kBookmarkBarButtonOffset, |
| 528 bookmarkBarBottomLeftInScreen.y + bookmarks::kBookmarkBarMenuOffset); | 528 bookmarkBarBottomLeftInScreen.y + bookmarks::kBookmarkBarMenuOffset); |
| 529 // Make sure the window is on-screen; if not, push left. It is | 529 // Make sure the window is on-screen; if not, push left or right. It is |
| 530 // intentional that top level folders "push left" slightly | 530 // intentional that top level folders "push left" or "push right" slightly |
| 531 // different than subfolders. | 531 // different than subfolders. |
| 532 NSRect screenFrame = [screen_ visibleFrame]; | 532 NSRect screenFrame = [screen_ visibleFrame]; |
| 533 // Test if window goes off-screen on the right side. |
| 533 CGFloat spillOff = (newWindowTopLeft.x + windowWidth) - NSMaxX(screenFrame); | 534 CGFloat spillOff = (newWindowTopLeft.x + windowWidth) - NSMaxX(screenFrame); |
| 534 if (spillOff > 0.0) { | 535 if (spillOff > 0.0) { |
| 535 newWindowTopLeft.x = std::max(newWindowTopLeft.x - spillOff, | 536 newWindowTopLeft.x = std::max(newWindowTopLeft.x - spillOff, |
| 536 NSMinX(screenFrame)); | 537 NSMinX(screenFrame)); |
| 538 } else if (newWindowTopLeft.x < NSMinX(screenFrame)) { |
| 539 // For left side. |
| 540 newWindowTopLeft.x = NSMinX(screenFrame); |
| 537 } | 541 } |
| 538 // The menu looks bad when it is squeezed up against the bottom of the | 542 // The menu looks bad when it is squeezed up against the bottom of the |
| 539 // screen and ends up being only a few pixels tall. If it meets the | 543 // screen and ends up being only a few pixels tall. If it meets the |
| 540 // threshold for this case, instead show the menu above the button. | 544 // threshold for this case, instead show the menu above the button. |
| 541 CGFloat availableVerticalSpace = newWindowTopLeft.y - | 545 CGFloat availableVerticalSpace = newWindowTopLeft.y - |
| 542 (NSMinY(screenFrame) + bookmarks::kScrollWindowVerticalMargin); | 546 (NSMinY(screenFrame) + bookmarks::kScrollWindowVerticalMargin); |
| 543 if ((availableVerticalSpace < kMinSqueezedMenuHeight) && | 547 if ((availableVerticalSpace < kMinSqueezedMenuHeight) && |
| 544 (windowHeight > availableVerticalSpace)) { | 548 (windowHeight > availableVerticalSpace)) { |
| 545 newWindowTopLeft.y = std::min( | 549 newWindowTopLeft.y = std::min( |
| 546 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]), | 550 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]), |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2003 | 2007 |
| 2004 - (void)setIgnoreAnimations:(BOOL)ignore { | 2008 - (void)setIgnoreAnimations:(BOOL)ignore { |
| 2005 ignoreAnimations_ = ignore; | 2009 ignoreAnimations_ = ignore; |
| 2006 } | 2010 } |
| 2007 | 2011 |
| 2008 - (BookmarkButton*)buttonThatMouseIsIn { | 2012 - (BookmarkButton*)buttonThatMouseIsIn { |
| 2009 return buttonThatMouseIsIn_; | 2013 return buttonThatMouseIsIn_; |
| 2010 } | 2014 } |
| 2011 | 2015 |
| 2012 @end // BookmarkBarFolderController | 2016 @end // BookmarkBarFolderController |
| OLD | NEW |