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

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

Issue 1547010: Set bookmark bar menu windows to the correct level.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/bookmark_bar_folder_controller.h" 5 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h"
6 #include "base/mac_util.h" 6 #include "base/mac_util.h"
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #import "chrome/browser/browser_theme_provider.h" 9 #import "chrome/browser/browser_theme_provider.h"
10 #import "chrome/browser/cocoa/bookmark_bar_constants.h" // namespace bookmarks 10 #import "chrome/browser/cocoa/bookmark_bar_constants.h" // namespace bookmarks
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bookmarks::kBookmarkVerticalPadding)); 206 bookmarks::kBookmarkVerticalPadding));
207 NSPoint topOfWindow = 207 NSPoint topOfWindow =
208 [[parentButton_ window] 208 [[parentButton_ window]
209 convertBaseToScreen:[[parentButton_ superview] 209 convertBaseToScreen:[[parentButton_ superview]
210 convertPoint:top toView:nil]]; 210 convertPoint:top toView:nil]];
211 newWindowTopLeft.y = topOfWindow.y; 211 newWindowTopLeft.y = topOfWindow.y;
212 } 212 }
213 return newWindowTopLeft; 213 return newWindowTopLeft;
214 } 214 }
215 215
216 // Set our window level to the right spot so we're above the menubar, dock, etc.
217 // Factored out so we can override/noop in a unit test.
218 - (void)configureWindowLevel {
219 [[self window] setLevel:NSPopUpMenuWindowLevel];
220 }
221
216 // Determine window size and position. 222 // Determine window size and position.
217 // Create buttons for all our nodes. 223 // Create buttons for all our nodes.
218 // TODO(jrg): break up into more and smaller routines for easier unit testing. 224 // TODO(jrg): break up into more and smaller routines for easier unit testing.
219 - (void)configureWindow { 225 - (void)configureWindow {
220 NSPoint newWindowTopLeft = [self windowTopLeft]; 226 NSPoint newWindowTopLeft = [self windowTopLeft];
221 const BookmarkNode* node = [parentButton_ bookmarkNode]; 227 const BookmarkNode* node = [parentButton_ bookmarkNode];
222 DCHECK(node); 228 DCHECK(node);
223 int startingIndex = [[parentButton_ cell] startingChildIndex]; 229 int startingIndex = [[parentButton_ cell] startingChildIndex];
224 DCHECK_LE(startingIndex, node->GetChildCount()); 230 DCHECK_LE(startingIndex, node->GetChildCount());
225 // Must have at least 1 button (for "empty") 231 // Must have at least 1 button (for "empty")
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if ([[self window] screen]) { // nil in unit tests 303 if ([[self window] screen]) { // nil in unit tests
298 const CGFloat padding = 8; 304 const CGFloat padding = 8;
299 NSRect screen = [[[self window] screen] frame]; 305 NSRect screen = [[[self window] screen] frame];
300 if (NSMaxX(windowFrame) + padding > NSMaxX(screen)) 306 if (NSMaxX(windowFrame) + padding > NSMaxX(screen))
301 windowFrame.origin.x -= NSMaxX(windowFrame) + padding - NSMaxX(screen); 307 windowFrame.origin.x -= NSMaxX(windowFrame) + padding - NSMaxX(screen);
302 else if (NSMinX(windowFrame) - padding < NSMinX(screen)) 308 else if (NSMinX(windowFrame) - padding < NSMinX(screen))
303 windowFrame.origin.x += NSMinX(screen) - NSMinX(windowFrame) + padding; 309 windowFrame.origin.x += NSMinX(screen) - NSMinX(windowFrame) + padding;
304 } 310 }
305 311
306 [[self window] setFrame:windowFrame display:YES]; 312 [[self window] setFrame:windowFrame display:YES];
307 313 [self configureWindowLevel];
308 // This is what we want, but it won't work so long as we're a child
309 // window of something at a different level. To fix (make not a
310 // child) would break other things (e.g. Expose'). I really need a
311 // modal loop for the bookmark menus. TODO(jrg)
312 // [[self window] setLevel:NSPopUpMenuWindowLevel];
313
314 [[parentController_ parentWindow] addChildWindow:[self window]
315 ordered:NSWindowAbove];
316 } 314 }
317 315
318 // Start a "scroll up" timer. 316 // Start a "scroll up" timer.
319 - (void)beginScrollWindowUp { 317 - (void)beginScrollWindowUp {
320 [self addScrollTimerWithDelta:kBookmarkBarFolderScrollAmount]; 318 [self addScrollTimerWithDelta:kBookmarkBarFolderScrollAmount];
321 } 319 }
322 320
323 // Start a "scroll down" timer. 321 // Start a "scroll down" timer.
324 - (void)beginScrollWindowDown { 322 - (void)beginScrollWindowDown {
325 [self addScrollTimerWithDelta:-kBookmarkBarFolderScrollAmount]; 323 [self addScrollTimerWithDelta:-kBookmarkBarFolderScrollAmount];
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } else { 452 } else {
455 // If there is no hoverOpen but we've exited our window, we may be 453 // If there is no hoverOpen but we've exited our window, we may be
456 // in a subfolder. Restore our state so it's cleaned up later. 454 // in a subfolder. Restore our state so it's cleaned up later.
457 hoverButton_.reset([button retain]); 455 hoverButton_.reset([button retain]);
458 } 456 }
459 } 457 }
460 458
461 // Delegate callback. 459 // Delegate callback.
462 - (void)windowWillClose:(NSNotification*)notification { 460 - (void)windowWillClose:(NSNotification*)notification {
463 [parentController_ childFolderWillClose:self]; 461 [parentController_ childFolderWillClose:self];
464 [[self parentWindow] removeChildWindow:[self window]];
465 [self closeBookmarkFolder:self]; 462 [self closeBookmarkFolder:self];
466 [self autorelease]; 463 [self autorelease];
467 } 464 }
468 465
469 - (BookmarkButton*)parentButton { 466 - (BookmarkButton*)parentButton {
470 return parentButton_.get(); 467 return parentButton_.get();
471 } 468 }
472 469
473 // Ugh... copied from bookmark_bar_controller.mm 470 // Ugh... copied from bookmark_bar_controller.mm
474 // Is it worth it to factor out for, essentially, 2 lines? 471 // Is it worth it to factor out for, essentially, 2 lines?
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 initWithParentButton:parentButton 819 initWithParentButton:parentButton
823 parentController:self]; 820 parentController:self];
824 [folderController_ showWindow:self]; 821 [folderController_ showWindow:self];
825 } 822 }
826 823
827 - (NSArray*)buttons { 824 - (NSArray*)buttons {
828 return buttons_.get(); 825 return buttons_.get();
829 } 826 }
830 827
831 @end // BookmarkBarFolderController 828 @end // BookmarkBarFolderController
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_folder_controller.h ('k') | chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698