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/toolbar_controller.h" | 5 #import "chrome/browser/cocoa/toolbar_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 addObserver:self | 632 addObserver:self |
633 selector:@selector(browserActionsVisibilityChanged:) | 633 selector:@selector(browserActionsVisibilityChanged:) |
634 name:kBrowserActionVisibilityChangedNotification | 634 name:kBrowserActionVisibilityChangedNotification |
635 object:browserActionsController_]; | 635 object:browserActionsController_]; |
636 [[NSNotificationCenter defaultCenter] | 636 [[NSNotificationCenter defaultCenter] |
637 addObserver:self | 637 addObserver:self |
638 selector:@selector(adjustBrowserActionsContainerForNewWindow:) | 638 selector:@selector(adjustBrowserActionsContainerForNewWindow:) |
639 name:NSWindowDidBecomeKeyNotification | 639 name:NSWindowDidBecomeKeyNotification |
640 object:[[self view] window]]; | 640 object:[[self view] window]]; |
641 } | 641 } |
642 | 642 CGFloat containerWidth = [browserActionsContainerView_ isHidden] ? 0.0 : |
643 CGFloat dX = NSWidth([browserActionsContainerView_ frame]) * -1; | 643 NSWidth([browserActionsContainerView_ frame]); |
644 [self adjustLocationAndGoPositionsBy:dX animate:NO]; | 644 if (containerWidth > 0.0) |
| 645 [self adjustLocationAndGoPositionsBy:(containerWidth * -1) animate:NO]; |
645 BOOL rightBorderShown = !([pageButton_ isHidden] && [wrenchButton_ isHidden]); | 646 BOOL rightBorderShown = !([pageButton_ isHidden] && [wrenchButton_ isHidden]); |
646 [browserActionsContainerView_ setRightBorderShown:rightBorderShown]; | 647 [browserActionsContainerView_ setRightBorderShown:rightBorderShown]; |
647 } | 648 } |
648 | 649 |
649 - (void)adjustBrowserActionsContainerForNewWindow: | 650 - (void)adjustBrowserActionsContainerForNewWindow: |
650 (NSNotification*)notification { | 651 (NSNotification*)notification { |
651 [self toolbarFrameChanged]; | 652 [self toolbarFrameChanged]; |
652 [[NSNotificationCenter defaultCenter] | 653 [[NSNotificationCenter defaultCenter] |
653 removeObserver:self | 654 removeObserver:self |
654 name:NSWindowDidBecomeKeyNotification | 655 name:NSWindowDidBecomeKeyNotification |
(...skipping 12 matching lines...) Expand all Loading... |
667 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { | 668 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { |
668 [browserActionsController_ resizeContainerAndAnimate:YES]; | 669 [browserActionsController_ resizeContainerAndAnimate:YES]; |
669 [self pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:YES]; | 670 [self pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:YES]; |
670 } | 671 } |
671 | 672 |
672 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { | 673 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { |
673 [self pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:NO]; | 674 [self pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:NO]; |
674 } | 675 } |
675 | 676 |
676 - (void)pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { | 677 - (void)pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { |
677 NSRect goFrame = [goButton_ frame]; | 678 CGFloat goXPos = [goButton_ frame].origin.x + NSWidth([goButton_ frame]); |
678 NSRect containerFrame = animate ? | 679 CGFloat leftPadding; |
679 [browserActionsContainerView_ animationEndFrame] : | |
680 [browserActionsContainerView_ frame]; | |
681 | 680 |
682 CGFloat leftPadding = containerFrame.origin.x - | 681 if ([browserActionsContainerView_ isHidden]) { |
683 (goFrame.origin.x + NSWidth(goFrame)); | 682 leftPadding = NSWidth([[goButton_ window] frame]) - goXPos; |
| 683 } else { |
| 684 NSRect containerFrame = animate ? |
| 685 [browserActionsContainerView_ animationEndFrame] : |
| 686 [browserActionsContainerView_ frame]; |
| 687 |
| 688 leftPadding = containerFrame.origin.x - goXPos; |
| 689 } |
684 if (leftPadding != kBrowserActionsContainerLeftPadding) { | 690 if (leftPadding != kBrowserActionsContainerLeftPadding) { |
685 CGFloat dX = leftPadding - kBrowserActionsContainerLeftPadding; | 691 CGFloat dX = leftPadding - kBrowserActionsContainerLeftPadding; |
686 [self adjustLocationAndGoPositionsBy:dX animate:animate]; | 692 [self adjustLocationAndGoPositionsBy:dX animate:animate]; |
687 } | 693 } |
688 } | 694 } |
689 | 695 |
690 - (void)maintainMinimumLocationBarWidth { | 696 - (void)maintainMinimumLocationBarWidth { |
691 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); | 697 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); |
692 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth; | 698 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth; |
693 if (locationBarAtMinSize_) { | 699 if (locationBarAtMinSize_) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 895 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
890 // Do nothing. | 896 // Do nothing. |
891 } | 897 } |
892 | 898 |
893 // (URLDropTargetController protocol) | 899 // (URLDropTargetController protocol) |
894 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 900 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
895 // Do nothing. | 901 // Do nothing. |
896 } | 902 } |
897 | 903 |
898 @end | 904 @end |
OLD | NEW |