Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1175)

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 629973002: Adjust bookmark folder menu window if its parent button is partly off-screen to the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Considering reviewer's comments, applying same logic as on the right side. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 is 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 { // For left side.
Alexei Svitkine (slow) 2014/10/07 18:26:13 Nit: Two spaces before start of // comment.
Gaja 2014/10/08 03:08:03 Moved to else if block.
539 spillOff = NSMinX(screenFrame) - newWindowTopLeft.x;
540 if (spillOff > 0.0)
Alexei Svitkine (slow) 2014/10/07 18:26:13 Just check "if (newWindowTopLeft.x < NSMinX(screen
Gaja 2014/10/08 03:08:03 Done.
541 newWindowTopLeft.x = NSMinX(screenFrame);
537 } 542 }
538 // The menu looks bad when it is squeezed up against the bottom of the 543 // 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 544 // 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. 545 // threshold for this case, instead show the menu above the button.
541 CGFloat availableVerticalSpace = newWindowTopLeft.y - 546 CGFloat availableVerticalSpace = newWindowTopLeft.y -
542 (NSMinY(screenFrame) + bookmarks::kScrollWindowVerticalMargin); 547 (NSMinY(screenFrame) + bookmarks::kScrollWindowVerticalMargin);
543 if ((availableVerticalSpace < kMinSqueezedMenuHeight) && 548 if ((availableVerticalSpace < kMinSqueezedMenuHeight) &&
544 (windowHeight > availableVerticalSpace)) { 549 (windowHeight > availableVerticalSpace)) {
545 newWindowTopLeft.y = std::min( 550 newWindowTopLeft.y = std::min(
546 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]), 551 newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]),
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 2008
2004 - (void)setIgnoreAnimations:(BOOL)ignore { 2009 - (void)setIgnoreAnimations:(BOOL)ignore {
2005 ignoreAnimations_ = ignore; 2010 ignoreAnimations_ = ignore;
2006 } 2011 }
2007 2012
2008 - (BookmarkButton*)buttonThatMouseIsIn { 2013 - (BookmarkButton*)buttonThatMouseIsIn {
2009 return buttonThatMouseIsIn_; 2014 return buttonThatMouseIsIn_;
2010 } 2015 }
2011 2016
2012 @end // BookmarkBarFolderController 2017 @end // BookmarkBarFolderController
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698