| 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/memory/scoped_nsobject.h" | 10 #import "base/memory/scoped_nsobject.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 buttonHeight)]; | 345 buttonHeight)]; |
| 346 | 346 |
| 347 // Actually place the badge *above* |maxY|, by +2 to miss the divider. | 347 // Actually place the badge *above* |maxY|, by +2 to miss the divider. |
| 348 CGFloat badgeXOffset = -kAvatarRightOffset; | 348 CGFloat badgeXOffset = -kAvatarRightOffset; |
| 349 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; | 349 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; |
| 350 NSPoint origin = | 350 NSPoint origin = |
| 351 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, | 351 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, |
| 352 maxY + badgeYOffset); | 352 maxY + badgeYOffset); |
| 353 [avatarButton setFrameOrigin:origin]; | 353 [avatarButton setFrameOrigin:origin]; |
| 354 [avatarButton setHidden:NO]; // Make sure it's shown. | 354 [avatarButton setHidden:NO]; // Make sure it's shown. |
| 355 |
| 356 NSTextField* avatarLabel = [avatarButtonController_ labelView]; |
| 357 if (avatarLabel) { |
| 358 CGFloat labelHeight = NSHeight([avatarLabel frame]); |
| 359 origin = NSMakePoint(badgeXOffset - NSWidth([avatarLabel frame]), |
| 360 (buttonHeight - labelHeight) / 2); |
| 361 [avatarLabel setFrameOrigin:origin]; |
| 362 [avatarLabel setHidden:NO]; |
| 363 } |
| 355 } | 364 } |
| 356 | 365 |
| 357 // Calculate the right indentation. The default indentation built into the | 366 // Calculate the right indentation. The default indentation built into the |
| 358 // tabstrip leaves enough room for the fullscreen button or presentation mode | 367 // tabstrip leaves enough room for the fullscreen button or presentation mode |
| 359 // toggle button on Lion. On non-Lion systems, the right indent needs to be | 368 // toggle button on Lion. On non-Lion systems, the right indent needs to be |
| 360 // adjusted to make room for the new tab button when an avatar is present. | 369 // adjusted to make room for the new tab button when an avatar is present. |
| 361 CGFloat rightIndent = 0; | 370 CGFloat rightIndent = 0; |
| 362 if (base::mac::IsOSLionOrLater()) { | 371 if (base::mac::IsOSLionOrLater()) { |
| 363 FramedBrowserWindow* window = | 372 FramedBrowserWindow* window = |
| 364 static_cast<FramedBrowserWindow*>([self window]); | 373 static_cast<FramedBrowserWindow*>([self window]); |
| 365 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]); | 374 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]); |
| 366 rightIndent += -[window fullScreenButtonOriginAdjustment].x; | 375 rightIndent += -[window fullScreenButtonOriginAdjustment].x; |
| 367 } else if ([self shouldShowAvatar]) { | 376 } else if ([self shouldShowAvatar]) { |
| 368 rightIndent += kAvatarTabStripShrink; | 377 rightIndent += kAvatarTabStripShrink; |
| 378 if ([avatarButtonController_ labelView]) { |
| 379 rightIndent += NSWidth([[avatarButtonController_ labelView] frame]) + |
| 380 kAvatarRightOffset; |
| 381 } |
| 369 } | 382 } |
| 370 [tabStripController_ setRightIndentForControls:rightIndent]; | 383 [tabStripController_ setRightIndentForControls:rightIndent]; |
| 371 | 384 |
| 372 // Go ahead and layout the tabs. | 385 // Go ahead and layout the tabs. |
| 373 [tabStripController_ layoutTabsWithoutAnimation]; | 386 [tabStripController_ layoutTabsWithoutAnimation]; |
| 374 | 387 |
| 375 return maxY; | 388 return maxY; |
| 376 } | 389 } |
| 377 | 390 |
| 378 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX | 391 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. | 593 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. |
| 581 [contentView setAutoresizesSubviews:YES]; | 594 [contentView setAutoresizesSubviews:YES]; |
| 582 [destWindow setContentView:contentView]; | 595 [destWindow setContentView:contentView]; |
| 583 | 596 |
| 584 // Move the incognito badge if present. | 597 // Move the incognito badge if present. |
| 585 if ([self shouldShowAvatar]) { | 598 if ([self shouldShowAvatar]) { |
| 586 [[avatarButtonController_ view] removeFromSuperview]; | 599 [[avatarButtonController_ view] removeFromSuperview]; |
| 587 [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout. | 600 [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout. |
| 588 [[[destWindow contentView] superview] addSubview: | 601 [[[destWindow contentView] superview] addSubview: |
| 589 [avatarButtonController_ view]]; | 602 [avatarButtonController_ view]]; |
| 603 if ([avatarButtonController_ labelView]) { |
| 604 [[avatarButtonController_ labelView] removeFromSuperview]; |
| 605 [[avatarButtonController_ labelView] setHidden:YES]; |
| 606 [[[destWindow contentView] superview] |
| 607 addSubview:[avatarButtonController_ labelView]]; |
| 608 } |
| 590 } | 609 } |
| 591 | 610 |
| 592 // Add the tab strip after setting the content view and moving the incognito | 611 // Add the tab strip after setting the content view and moving the incognito |
| 593 // badge (if any), so that the tab strip will be on top (in the z-order). | 612 // badge (if any), so that the tab strip will be on top (in the z-order). |
| 594 if ([self hasTabStrip]) | 613 if ([self hasTabStrip]) |
| 595 [[[destWindow contentView] superview] addSubview:tabStripView]; | 614 [[[destWindow contentView] superview] addSubview:tabStripView]; |
| 596 | 615 |
| 597 [sourceWindow setWindowController:nil]; | 616 [sourceWindow setWindowController:nil]; |
| 598 [self setWindow:destWindow]; | 617 [self setWindow:destWindow]; |
| 599 [destWindow setWindowController:self]; | 618 [destWindow setWindowController:self]; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 relativeTo:[bookmarkBarController_ view]]; | 1026 relativeTo:[bookmarkBarController_ view]]; |
| 1008 } else { | 1027 } else { |
| 1009 [contentView cr_ensureSubview:floatingBarBackingView_ | 1028 [contentView cr_ensureSubview:floatingBarBackingView_ |
| 1010 isPositioned:NSWindowBelow | 1029 isPositioned:NSWindowBelow |
| 1011 relativeTo:[bookmarkBarController_ view]]; | 1030 relativeTo:[bookmarkBarController_ view]]; |
| 1012 } | 1031 } |
| 1013 } | 1032 } |
| 1014 } | 1033 } |
| 1015 | 1034 |
| 1016 @end // @implementation BrowserWindowController(Private) | 1035 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |