OLD | NEW |
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/nsimage_cache_mac.h" | 7 #include "base/nsimage_cache_mac.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 NSRect mainViewFrame = NSMakeRect(0, 0, | 385 NSRect mainViewFrame = NSMakeRect(0, 0, |
386 NSWidth(windowFrame) - | 386 NSWidth(windowFrame) - |
387 bookmarks::kScrollViewContentWidthMargin, | 387 bookmarks::kScrollViewContentWidthMargin, |
388 NSHeight(windowFrame)); | 388 NSHeight(windowFrame)); |
389 [mainView_ setFrame:mainViewFrame]; | 389 [mainView_ setFrame:mainViewFrame]; |
390 | 390 |
391 // Make sure the window fits on the screen. If not, constrain. | 391 // Make sure the window fits on the screen. If not, constrain. |
392 // We'll scroll to allow the user to see all the content. | 392 // We'll scroll to allow the user to see all the content. |
393 NSRect screenFrame = [[[self window] screen] frame]; | 393 NSRect screenFrame = [[[self window] screen] frame]; |
394 screenFrame = NSInsetRect(screenFrame, 0, kScrollWindowVerticalMargin); | 394 screenFrame = NSInsetRect(screenFrame, 0, kScrollWindowVerticalMargin); |
| 395 BOOL wasScrollable = scrollable_; |
395 if (!NSContainsRect(screenFrame, windowFrame)) { | 396 if (!NSContainsRect(screenFrame, windowFrame)) { |
396 scrollable_ = YES; | 397 scrollable_ = YES; |
397 windowFrame = NSIntersectionRect(screenFrame, windowFrame); | 398 windowFrame = NSIntersectionRect(screenFrame, windowFrame); |
398 } else { | 399 } else { |
399 scrollable_ = NO; | 400 scrollable_ = NO; |
400 } | 401 } |
401 [[self window] setFrame:windowFrame display:YES]; | 402 NSWindow* window = [self window]; |
| 403 [window setFrame:windowFrame display:YES]; |
402 // If scrollable then offset the view and show the arrows. | 404 // If scrollable then offset the view and show the arrows. |
403 if (scrollable_) { | 405 if (wasScrollable != scrollable_) { |
404 [mainView_ scrollPoint:NSMakePoint(0, (NSHeight(mainViewFrame) - | 406 [mainView_ scrollPoint:NSMakePoint(0, (NSHeight(mainViewFrame) - |
405 NSHeight(windowFrame)))]; | 407 NSHeight(windowFrame)))]; |
406 [self showOrHideScrollArrows]; | 408 [self showOrHideScrollArrows]; |
407 [self addOrUpdateScrollTracking]; | 409 [self addOrUpdateScrollTracking]; |
408 } | 410 } |
409 } | 411 } |
410 | 412 |
411 // Determine window size and position. | 413 // Determine window size and position. |
412 // Create buttons for all our nodes. | 414 // Create buttons for all our nodes. |
413 // TODO(jrg): break up into more and smaller routines for easier unit testing. | 415 // TODO(jrg): break up into more and smaller routines for easier unit testing. |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 return [folderController_ controllerForNode:node]; | 1376 return [folderController_ controllerForNode:node]; |
1375 } | 1377 } |
1376 | 1378 |
1377 #pragma mark TestingAPI Only | 1379 #pragma mark TestingAPI Only |
1378 | 1380 |
1379 - (void)setIgnoreAnimations:(BOOL)ignore { | 1381 - (void)setIgnoreAnimations:(BOOL)ignore { |
1380 ignoreAnimations_ = ignore; | 1382 ignoreAnimations_ = ignore; |
1381 } | 1383 } |
1382 | 1384 |
1383 @end // BookmarkBarFolderController | 1385 @end // BookmarkBarFolderController |
OLD | NEW |