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

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: Created 6 years, 2 months 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 [[NSNotificationCenter defaultCenter] 311 [[NSNotificationCenter defaultCenter]
308 addObserver:self 312 addObserver:self
309 selector:@selector(containerDragging:) 313 selector:@selector(containerDragging:)
310 name:kBrowserActionGrippyDraggingNotification 314 name:kBrowserActionGrippyDraggingNotification
311 object:containerView_]; 315 object:containerView_];
312 [[NSNotificationCenter defaultCenter] 316 [[NSNotificationCenter defaultCenter]
313 addObserver:self 317 addObserver:self
314 selector:@selector(containerDragFinished:) 318 selector:@selector(containerDragFinished:)
315 name:kBrowserActionGrippyDragFinishedNotification 319 name:kBrowserActionGrippyDragFinishedNotification
316 object:containerView_]; 320 object:containerView_];
321 [[NSNotificationCenter defaultCenter]
322 addObserver:self
323 selector:@selector(containerWillTranslateOnX:)
324 name:kBrowseActionContainerWillTranslateOnXNotification
325 object:containerView_];
317 // Listen for a finished drag from any button to make sure each open window 326 // Listen for a finished drag from any button to make sure each open window
318 // stays in sync. 327 // stays in sync.
319 [[NSNotificationCenter defaultCenter] 328 [[NSNotificationCenter defaultCenter]
320 addObserver:self 329 addObserver:self
321 selector:@selector(actionButtonDragFinished:) 330 selector:@selector(actionButtonDragFinished:)
322 name:kBrowserActionButtonDragEndNotification 331 name:kBrowserActionButtonDragEndNotification
323 object:nil]; 332 object:nil];
324 333
325 chevronAnimation_.reset([[NSViewAnimation alloc] init]); 334 chevronAnimation_.reset([[NSViewAnimation alloc] init]);
326 [chevronAnimation_ gtm_setDuration:kAnimationDuration 335 [chevronAnimation_ gtm_setDuration:kAnimationDuration
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 679 }
671 [self updateGrippyCursors]; 680 [self updateGrippyCursors];
672 681
673 toolbarModel_->SetVisibleIconCount([self visibleButtonCount]); 682 toolbarModel_->SetVisibleIconCount([self visibleButtonCount]);
674 683
675 [[NSNotificationCenter defaultCenter] 684 [[NSNotificationCenter defaultCenter]
676 postNotificationName:kBrowserActionGrippyDragFinishedNotification 685 postNotificationName:kBrowserActionGrippyDragFinishedNotification
677 object:self]; 686 object:self];
678 } 687 }
679 688
689 - (void)containerWillTranslateOnX:(NSNotification*)notification {
690 [[NSNotificationCenter defaultCenter]
691 postNotificationName:kBrowseActionContainerWillTranslateOnXNotification
692 object:self
693 userInfo:notification.userInfo];
694 }
695
680 - (void)actionButtonDragging:(NSNotification*)notification { 696 - (void)actionButtonDragging:(NSNotification*)notification {
681 if (![self chevronIsHidden]) 697 if (![self chevronIsHidden])
682 [self setChevronHidden:YES inFrame:[containerView_ frame] animate:YES]; 698 [self setChevronHidden:YES inFrame:[containerView_ frame] animate:YES];
683 699
684 // Determine what index the dragged button should lie in, alter the model and 700 // Determine what index the dragged button should lie in, alter the model and
685 // reposition the buttons. 701 // reposition the buttons.
686 CGFloat dragThreshold = std::floor(kBrowserActionWidth / 2); 702 CGFloat dragThreshold = std::floor(kBrowserActionWidth / 2);
687 BrowserActionButton* draggedButton = [notification object]; 703 BrowserActionButton* draggedButton = [notification object];
688 NSRect draggedButtonFrame = [draggedButton frame]; 704 NSRect draggedButtonFrame = [draggedButton frame];
689 705
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 const extensions::ExtensionList& toolbar_items = 872 const extensions::ExtensionList& toolbar_items =
857 toolbarModel_->toolbar_items(); 873 toolbarModel_->toolbar_items();
858 if (index < toolbar_items.size()) { 874 if (index < toolbar_items.size()) {
859 const Extension* extension = toolbar_items[index].get(); 875 const Extension* extension = toolbar_items[index].get();
860 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; 876 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())];
861 } 877 }
862 return nil; 878 return nil;
863 } 879 }
864 880
865 @end 881 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698