| 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/browser_window_controller_private.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 CGFloat tabStripHeight = NSHeight([tabStripView frame]); | 312 CGFloat tabStripHeight = NSHeight([tabStripView frame]); |
| 313 maxY -= tabStripHeight; | 313 maxY -= tabStripHeight; |
| 314 [tabStripView setFrame:NSMakeRect(0, maxY, width, tabStripHeight)]; | 314 [tabStripView setFrame:NSMakeRect(0, maxY, width, tabStripHeight)]; |
| 315 | 315 |
| 316 // Set left indentation based on fullscreen mode status. | 316 // Set left indentation based on fullscreen mode status. |
| 317 [tabStripController_ setLeftIndentForControls:(fullscreen ? 0 : | 317 [tabStripController_ setLeftIndentForControls:(fullscreen ? 0 : |
| 318 [[tabStripController_ class] defaultLeftIndentForControls])]; | 318 [[tabStripController_ class] defaultLeftIndentForControls])]; |
| 319 | 319 |
| 320 // Lay out the icognito/avatar badge because calculating the indentation on | 320 // Lay out the icognito/avatar badge because calculating the indentation on |
| 321 // the right depends on it. | 321 // the right depends on it. |
| 322 NSView* avatarButton = [avatarButtonController_ view]; |
| 322 if ([self shouldShowAvatar]) { | 323 if ([self shouldShowAvatar]) { |
| 323 NSView* avatarButton = [avatarButtonController_ view]; | |
| 324 CGFloat badgeXOffset = -kAvatarRightOffset; | 324 CGFloat badgeXOffset = -kAvatarRightOffset; |
| 325 CGFloat badgeYOffset = 0; | 325 CGFloat badgeYOffset = 0; |
| 326 CGFloat buttonHeight; | 326 CGFloat buttonHeight = NSHeight([avatarButton frame]); |
| 327 | 327 |
| 328 if ([self shouldUseNewAvatarButton]) { | 328 if ([self shouldUseNewAvatarButton]) { |
| 329 // The fullscreen icon is displayed to the right of the avatar button. | 329 // The fullscreen icon is displayed to the right of the avatar button. |
| 330 if (![self isFullscreen]) | 330 if (![self isFullscreen]) |
| 331 badgeXOffset -= kFullscreenIconWidth; | 331 badgeXOffset -= kFullscreenIconWidth; |
| 332 | |
| 333 // Center the button vertically on the tabstrip. | 332 // Center the button vertically on the tabstrip. |
| 334 buttonHeight = NSHeight([avatarButton frame]); | |
| 335 badgeYOffset = (tabStripHeight - buttonHeight) / 2; | 333 badgeYOffset = (tabStripHeight - buttonHeight) / 2; |
| 336 } else { | 334 } else { |
| 337 buttonHeight = static_cast<CGFloat>(profiles::kAvatarIconHeight); | |
| 338 // Actually place the badge *above* |maxY|, by +2 to miss the divider. | 335 // Actually place the badge *above* |maxY|, by +2 to miss the divider. |
| 339 badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; | 336 badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; |
| 337 } |
| 340 | 338 |
| 341 } | |
| 342 [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]), | 339 [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]), |
| 343 std::min(buttonHeight, tabStripHeight))]; | 340 std::min(buttonHeight, tabStripHeight))]; |
| 344 NSPoint origin = | 341 NSPoint origin = |
| 345 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, | 342 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, |
| 346 maxY + badgeYOffset); | 343 maxY + badgeYOffset); |
| 347 [avatarButton setFrameOrigin:origin]; | 344 [avatarButton setFrameOrigin:origin]; |
| 348 [avatarButton setHidden:NO]; // Make sure it's shown. | 345 [avatarButton setHidden:NO]; // Make sure it's shown. |
| 349 } | 346 } |
| 350 | 347 |
| 351 // Calculate the right indentation. The default indentation built into the | 348 // Calculate the right indentation. The default indentation built into the |
| 352 // tabstrip leaves enough room for the fullscreen button or presentation mode | 349 // tabstrip leaves enough room for the fullscreen button or presentation mode |
| 353 // toggle button on Lion. On non-Lion systems, the right indent needs to be | 350 // toggle button on Lion. On non-Lion systems, the right indent needs to be |
| 354 // adjusted to make room for the new tab button when an avatar is present. | 351 // adjusted to make room for the new tab button when an avatar is present. |
| 355 CGFloat rightIndent = 0; | 352 CGFloat rightIndent = 0; |
| 356 if (base::mac::IsOSLionOrLater() && | 353 if (base::mac::IsOSLionOrLater() && |
| 357 [[self window] isKindOfClass:[FramedBrowserWindow class]]) { | 354 [[self window] isKindOfClass:[FramedBrowserWindow class]]) { |
| 358 FramedBrowserWindow* window = | 355 FramedBrowserWindow* window = |
| 359 static_cast<FramedBrowserWindow*>([self window]); | 356 static_cast<FramedBrowserWindow*>([self window]); |
| 360 rightIndent += -[window fullScreenButtonOriginAdjustment].x; | 357 rightIndent += -[window fullScreenButtonOriginAdjustment].x; |
| 358 |
| 359 // The new avatar is wider than the default indentation, so we need to |
| 360 // account for its width. |
| 361 if ([self shouldUseNewAvatarButton]) |
| 362 rightIndent += NSWidth([avatarButton frame]) + kAvatarTabStripShrink; |
| 361 } else if ([self shouldShowAvatar]) { | 363 } else if ([self shouldShowAvatar]) { |
| 362 rightIndent += kAvatarTabStripShrink; | 364 rightIndent += kAvatarTabStripShrink + |
| 363 if ([self shouldUseNewAvatarButton]) { | 365 NSWidth([avatarButton frame]) + kAvatarRightOffset; |
| 364 rightIndent += NSWidth([[avatarButtonController_ view] frame]) | |
| 365 + kAvatarTabStripShrink; | |
| 366 } else { | |
| 367 NSButton* labelButton = | |
| 368 [static_cast<AvatarIconController*>(avatarButtonController_) | |
| 369 labelButtonView]; | |
| 370 if (labelButton) | |
| 371 rightIndent += NSWidth([labelButton frame]) + kAvatarRightOffset; | |
| 372 } | |
| 373 } | 366 } |
| 374 [tabStripController_ setRightIndentForControls:rightIndent]; | 367 [tabStripController_ setRightIndentForControls:rightIndent]; |
| 375 | 368 |
| 376 // Go ahead and layout the tabs. | 369 // Go ahead and layout the tabs. |
| 377 [tabStripController_ layoutTabsWithoutAnimation]; | 370 [tabStripController_ layoutTabsWithoutAnimation]; |
| 378 | 371 |
| 379 return maxY; | 372 return maxY; |
| 380 } | 373 } |
| 381 | 374 |
| 382 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX | 375 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 } | 1004 } |
| 1012 } | 1005 } |
| 1013 | 1006 |
| 1014 - (void)updateInfoBarTipVisibility { | 1007 - (void)updateInfoBarTipVisibility { |
| 1015 // If there's no toolbar then hide the infobar tip. | 1008 // If there's no toolbar then hide the infobar tip. |
| 1016 [infoBarContainerController_ | 1009 [infoBarContainerController_ |
| 1017 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; | 1010 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; |
| 1018 } | 1011 } |
| 1019 | 1012 |
| 1020 @end // @implementation BrowserWindowController(Private) | 1013 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |