OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_container_view.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 CGFloat maxAllowedWidth = [self maxAllowedWidth]; | 161 CGFloat maxAllowedWidth = [self maxAllowedWidth]; |
162 containerFrame.size.width = | 162 containerFrame.size.width = |
163 std::max(NSWidth(containerFrame) - dX, kMinimumContainerWidth); | 163 std::max(NSWidth(containerFrame) - dX, kMinimumContainerWidth); |
164 canDragLeft_ = withDelta <= initialDragPoint_.x && | 164 canDragLeft_ = withDelta <= initialDragPoint_.x && |
165 NSWidth(containerFrame) < maxDesiredWidth_ && | 165 NSWidth(containerFrame) < maxDesiredWidth_ && |
166 NSWidth(containerFrame) < maxAllowedWidth; | 166 NSWidth(containerFrame) < maxAllowedWidth; |
167 | 167 |
168 if ((dX < 0.0 && !canDragLeft_) || (dX > 0.0 && !canDragRight_)) | 168 if ((dX < 0.0 && !canDragLeft_) || (dX > 0.0 && !canDragRight_)) |
169 return; | 169 return; |
170 | 170 |
171 if (NSWidth(containerFrame) == kMinimumContainerWidth) | 171 if (NSWidth(containerFrame) <= kMinimumContainerWidth) |
172 return; | 172 return; |
173 | 173 |
174 grippyPinned_ = NSWidth(containerFrame) == maxAllowedWidth; | 174 grippyPinned_ = NSWidth(containerFrame) >= maxAllowedWidth; |
175 containerFrame.origin.x += dX; | 175 containerFrame.origin.x += dX; |
176 | 176 |
177 [self setFrame:containerFrame]; | 177 [self setFrame:containerFrame]; |
178 [self setNeedsDisplay:YES]; | 178 [self setNeedsDisplay:YES]; |
179 | 179 |
180 [[NSNotificationCenter defaultCenter] | 180 [[NSNotificationCenter defaultCenter] |
181 postNotificationName:kBrowserActionGrippyDraggingNotification | 181 postNotificationName:kBrowserActionGrippyDraggingNotification |
182 object:self]; | 182 object:self]; |
183 | 183 |
184 lastXPos_ += dX; | 184 lastXPos_ += dX; |
(...skipping 11 matching lines...) Expand all Loading... | |
196 NSRect frame = [self frame]; | 196 NSRect frame = [self frame]; |
197 | 197 |
198 CGFloat maxAllowedWidth = [self maxAllowedWidth]; | 198 CGFloat maxAllowedWidth = [self maxAllowedWidth]; |
199 width = std::min(maxAllowedWidth, width); | 199 width = std::min(maxAllowedWidth, width); |
200 | 200 |
201 lastXPos_ = frame.origin.x; | 201 lastXPos_ = frame.origin.x; |
202 CGFloat dX = frame.size.width - width; | 202 CGFloat dX = frame.size.width - width; |
203 frame.size.width = width; | 203 frame.size.width = width; |
204 NSRect newFrame = NSOffsetRect(frame, dX, 0); | 204 NSRect newFrame = NSOffsetRect(frame, dX, 0); |
205 | 205 |
206 grippyPinned_ = width == maxAllowedWidth; | 206 grippyPinned_ = width == maxAllowedWidth; |
Devlin
2015/03/23 18:19:13
I think this one's okay, because we set width to b
| |
207 | 207 |
208 [self stopAnimation]; | 208 [self stopAnimation]; |
209 | 209 |
210 if (animate) { | 210 if (animate) { |
211 NSDictionary* animationDictionary = @{ | 211 NSDictionary* animationDictionary = @{ |
212 NSViewAnimationTargetKey : self, | 212 NSViewAnimationTargetKey : self, |
213 NSViewAnimationStartFrameKey : [NSValue valueWithRect:[self frame]], | 213 NSViewAnimationStartFrameKey : [NSValue valueWithRect:[self frame]], |
214 NSViewAnimationEndFrameKey : [NSValue valueWithRect:newFrame] | 214 NSViewAnimationEndFrameKey : [NSValue valueWithRect:newFrame] |
215 }; | 215 }; |
216 [resizeAnimation_ setViewAnimations:@[ animationDictionary ]]; | 216 [resizeAnimation_ setViewAnimations:@[ animationDictionary ]]; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 retVal = [NSCursor resizeLeftRightCursor]; | 265 retVal = [NSCursor resizeLeftRightCursor]; |
266 } | 266 } |
267 return retVal; | 267 return retVal; |
268 } | 268 } |
269 | 269 |
270 - (CGFloat)maxAllowedWidth { | 270 - (CGFloat)maxAllowedWidth { |
271 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; | 271 return delegate_ ? delegate_->GetMaxAllowedWidth() : CGFLOAT_MAX; |
272 } | 272 } |
273 | 273 |
274 @end | 274 @end |
OLD | NEW |