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/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 @interface ToolbarController() | 82 @interface ToolbarController() |
83 @property(assign, nonatomic) Browser* browser; | 83 @property(assign, nonatomic) Browser* browser; |
84 - (void)addAccessibilityDescriptions; | 84 - (void)addAccessibilityDescriptions; |
85 - (void)initCommandStatus:(CommandUpdater*)commands; | 85 - (void)initCommandStatus:(CommandUpdater*)commands; |
86 - (void)prefChanged:(const std::string&)prefName; | 86 - (void)prefChanged:(const std::string&)prefName; |
87 - (BackgroundGradientView*)backgroundGradientView; | 87 - (BackgroundGradientView*)backgroundGradientView; |
88 - (void)toolbarFrameChanged; | 88 - (void)toolbarFrameChanged; |
89 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; | 89 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; |
90 - (void)maintainMinimumLocationBarWidth; | 90 - (void)maintainMinimumLocationBarWidth; |
91 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; | 91 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; |
92 - (void)browserActionsContainerWillDrag:(NSNotification*)notification; | |
92 - (void)browserActionsContainerDragged:(NSNotification*)notification; | 93 - (void)browserActionsContainerDragged:(NSNotification*)notification; |
93 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; | 94 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; |
94 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; | 95 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; |
95 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; | 96 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; |
96 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity | 97 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity |
97 animate:(BOOL)animate; | 98 animate:(BOOL)animate; |
98 @end | 99 @end |
99 | 100 |
100 namespace ToolbarControllerInternal { | 101 namespace ToolbarControllerInternal { |
101 | 102 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 } | 581 } |
581 } | 582 } |
582 | 583 |
583 - (void)createBrowserActionButtons { | 584 - (void)createBrowserActionButtons { |
584 if (!browserActionsController_.get()) { | 585 if (!browserActionsController_.get()) { |
585 browserActionsController_.reset([[BrowserActionsController alloc] | 586 browserActionsController_.reset([[BrowserActionsController alloc] |
586 initWithBrowser:browser_ | 587 initWithBrowser:browser_ |
587 containerView:browserActionsContainerView_]); | 588 containerView:browserActionsContainerView_]); |
588 [[NSNotificationCenter defaultCenter] | 589 [[NSNotificationCenter defaultCenter] |
589 addObserver:self | 590 addObserver:self |
591 selector:@selector(browserActionsContainerWillDrag:) | |
592 name:kBrowseActionContainerWillTranslateOnXNotification | |
Yoyo Zhou
2014/10/27 23:45:26
typo: kBrowserAction...
Malcolm
2014/10/28 06:56:09
Oops, I lost the 'r'.
On 2014/10/27 23:45:26, Yoyo
| |
593 object:browserActionsController_]; | |
594 [[NSNotificationCenter defaultCenter] | |
595 addObserver:self | |
590 selector:@selector(browserActionsContainerDragged:) | 596 selector:@selector(browserActionsContainerDragged:) |
591 name:kBrowserActionGrippyDraggingNotification | 597 name:kBrowserActionGrippyDraggingNotification |
592 object:browserActionsController_]; | 598 object:browserActionsController_]; |
593 [[NSNotificationCenter defaultCenter] | 599 [[NSNotificationCenter defaultCenter] |
594 addObserver:self | 600 addObserver:self |
595 selector:@selector(browserActionsContainerDragFinished:) | 601 selector:@selector(browserActionsContainerDragFinished:) |
596 name:kBrowserActionGrippyDragFinishedNotification | 602 name:kBrowserActionGrippyDragFinishedNotification |
597 object:browserActionsController_]; | 603 object:browserActionsController_]; |
598 [[NSNotificationCenter defaultCenter] | 604 [[NSNotificationCenter defaultCenter] |
599 addObserver:self | 605 addObserver:self |
(...skipping 28 matching lines...) Expand all Loading... | |
628 [browserActionsContainerView_ setGrippyPinned:locationBarAtMinSize_]; | 634 [browserActionsContainerView_ setGrippyPinned:locationBarAtMinSize_]; |
629 [self adjustLocationSizeBy: | 635 [self adjustLocationSizeBy: |
630 [browserActionsContainerView_ resizeDeltaX] animate:NO]; | 636 [browserActionsContainerView_ resizeDeltaX] animate:NO]; |
631 } | 637 } |
632 | 638 |
633 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { | 639 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { |
634 [browserActionsController_ resizeContainerAndAnimate:YES]; | 640 [browserActionsController_ resizeContainerAndAnimate:YES]; |
635 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES]; | 641 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES]; |
636 } | 642 } |
637 | 643 |
644 - (void)browserActionsContainerWillDrag:(NSNotification*)notification { | |
645 CGFloat deltaX = [[notification.userInfo objectForKey:kTranslationWithDelta] | |
646 floatValue]; | |
647 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); | |
Yoyo Zhou
2014/10/27 23:45:26
I'm not very familiar with this code, so please be
Malcolm
2014/10/28 06:56:09
The -maintainMinimumLocationBarWidth only adjusts
| |
648 BOOL locationBarWillBeAtMinSize = | |
649 (locationBarWidth + deltaX) <= kMinimumLocationBarWidth; | |
650 | |
651 // Prevent the |browserActionsContainerView_| from dragging if the width of | |
652 // location bar will reach the minimum. | |
653 [browserActionsContainerView_ setCanDragLeft:!locationBarWillBeAtMinSize]; | |
654 } | |
655 | |
638 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { | 656 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { |
639 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; | 657 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; |
640 } | 658 } |
641 | 659 |
642 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { | 660 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { |
643 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); | 661 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); |
644 CGFloat leftDistance; | 662 CGFloat leftDistance; |
645 | 663 |
646 if ([browserActionsContainerView_ isHidden]) { | 664 if ([browserActionsContainerView_ isHidden]) { |
647 CGFloat edgeXPos = [wrenchButton_ frame].origin.x; | 665 CGFloat edgeXPos = [wrenchButton_ frame].origin.x; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 844 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
827 // Do nothing. | 845 // Do nothing. |
828 } | 846 } |
829 | 847 |
830 // (URLDropTargetController protocol) | 848 // (URLDropTargetController protocol) |
831 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 849 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
832 return drag_util::IsUnsupportedDropData(profile_, info); | 850 return drag_util::IsUnsupportedDropData(profile_, info); |
833 } | 851 } |
834 | 852 |
835 @end | 853 @end |
OLD | NEW |