Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 636283004: To ensure that the location bar will not reach the minimum width. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make naming consistent. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/browser_actions_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 - (void)containerDragStart:(NSNotification*)notification; 112 - (void)containerDragStart:(NSNotification*)notification;
113 113
114 // Sends a notification for the toolbar to reposition surrounding UI elements. 114 // Sends a notification for the toolbar to reposition surrounding UI elements.
115 - (void)containerDragging:(NSNotification*)notification; 115 - (void)containerDragging:(NSNotification*)notification;
116 116
117 // Determines which buttons need to be hidden based on the new size, hides them 117 // Determines which buttons need to be hidden based on the new size, hides them
118 // and updates the chevron overflow menu. Also fires a notification to let the 118 // and updates the chevron overflow menu. Also fires a notification to let the
119 // toolbar know that the drag has finished. 119 // toolbar know that the drag has finished.
120 - (void)containerDragFinished:(NSNotification*)notification; 120 - (void)containerDragFinished:(NSNotification*)notification;
121 121
122 // Sends a notification for the toolbar to determine whether the container can
123 // translate with a delta on x-axis.
124 - (void)containerWillTranslateOnX:(NSNotification*)notification;
125
122 // Adjusts the position of the surrounding action buttons depending on where the 126 // Adjusts the position of the surrounding action buttons depending on where the
123 // button is within the container. 127 // button is within the container.
124 - (void)actionButtonDragging:(NSNotification*)notification; 128 - (void)actionButtonDragging:(NSNotification*)notification;
125 129
126 // Updates the position of the Browser Actions within the container. This fires 130 // Updates the position of the Browser Actions within the container. This fires
127 // when _any_ Browser Action button is done dragging to keep all open windows in 131 // when _any_ Browser Action button is done dragging to keep all open windows in
128 // sync visually. 132 // sync visually.
129 - (void)actionButtonDragFinished:(NSNotification*)notification; 133 - (void)actionButtonDragFinished:(NSNotification*)notification;
130 134
131 // Moves the given button both visually and within the toolbar model to the 135 // Moves the given button both visually and within the toolbar model to the
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 [[NSNotificationCenter defaultCenter] 302 [[NSNotificationCenter defaultCenter]
299 addObserver:self 303 addObserver:self
300 selector:@selector(containerDragging:) 304 selector:@selector(containerDragging:)
301 name:kBrowserActionGrippyDraggingNotification 305 name:kBrowserActionGrippyDraggingNotification
302 object:containerView_]; 306 object:containerView_];
303 [[NSNotificationCenter defaultCenter] 307 [[NSNotificationCenter defaultCenter]
304 addObserver:self 308 addObserver:self
305 selector:@selector(containerDragFinished:) 309 selector:@selector(containerDragFinished:)
306 name:kBrowserActionGrippyDragFinishedNotification 310 name:kBrowserActionGrippyDragFinishedNotification
307 object:containerView_]; 311 object:containerView_];
312 [[NSNotificationCenter defaultCenter]
313 addObserver:self
314 selector:@selector(containerWillTranslateOnX:)
315 name:kBrowserActionGrippyWillDragNotification
316 object:containerView_];
308 // Listen for a finished drag from any button to make sure each open window 317 // Listen for a finished drag from any button to make sure each open window
309 // stays in sync. 318 // stays in sync.
310 [[NSNotificationCenter defaultCenter] 319 [[NSNotificationCenter defaultCenter]
311 addObserver:self 320 addObserver:self
312 selector:@selector(actionButtonDragFinished:) 321 selector:@selector(actionButtonDragFinished:)
313 name:kBrowserActionButtonDragEndNotification 322 name:kBrowserActionButtonDragEndNotification
314 object:nil]; 323 object:nil];
315 324
316 chevronAnimation_.reset([[NSViewAnimation alloc] init]); 325 chevronAnimation_.reset([[NSViewAnimation alloc] init]);
317 [chevronAnimation_ gtm_setDuration:kAnimationDuration 326 [chevronAnimation_ gtm_setDuration:kAnimationDuration
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 672 }
664 [self updateGrippyCursors]; 673 [self updateGrippyCursors];
665 674
666 toolbarModel_->SetVisibleIconCount([self visibleButtonCount]); 675 toolbarModel_->SetVisibleIconCount([self visibleButtonCount]);
667 676
668 [[NSNotificationCenter defaultCenter] 677 [[NSNotificationCenter defaultCenter]
669 postNotificationName:kBrowserActionGrippyDragFinishedNotification 678 postNotificationName:kBrowserActionGrippyDragFinishedNotification
670 object:self]; 679 object:self];
671 } 680 }
672 681
682 - (void)containerWillTranslateOnX:(NSNotification*)notification {
683 [[NSNotificationCenter defaultCenter]
684 postNotificationName:kBrowserActionGrippyWillDragNotification
685 object:self
686 userInfo:notification.userInfo];
687 }
688
673 - (void)actionButtonDragging:(NSNotification*)notification { 689 - (void)actionButtonDragging:(NSNotification*)notification {
674 if (![self chevronIsHidden]) 690 if (![self chevronIsHidden])
675 [self setChevronHidden:YES inFrame:[containerView_ frame] animate:YES]; 691 [self setChevronHidden:YES inFrame:[containerView_ frame] animate:YES];
676 692
677 // Determine what index the dragged button should lie in, alter the model and 693 // Determine what index the dragged button should lie in, alter the model and
678 // reposition the buttons. 694 // reposition the buttons.
679 CGFloat dragThreshold = std::floor(kBrowserActionWidth / 2); 695 CGFloat dragThreshold = std::floor(kBrowserActionWidth / 2);
680 BrowserActionButton* draggedButton = [notification object]; 696 BrowserActionButton* draggedButton = [notification object];
681 NSRect draggedButtonFrame = [draggedButton frame]; 697 NSRect draggedButtonFrame = [draggedButton frame];
682 698
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 const extensions::ExtensionList& toolbar_items = 865 const extensions::ExtensionList& toolbar_items =
850 toolbarModel_->toolbar_items(); 866 toolbarModel_->toolbar_items();
851 if (index < toolbar_items.size()) { 867 if (index < toolbar_items.size()) {
852 const Extension* extension = toolbar_items[index].get(); 868 const Extension* extension = toolbar_items[index].get();
853 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; 869 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())];
854 } 870 }
855 return nil; 871 return nil;
856 } 872 }
857 873
858 @end 874 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698