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/extensions/browser_actions_container_view.h" | 5 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/scoped_nsobject.h" | 10 #import "base/scoped_nsobject.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 #pragma mark - | 159 #pragma mark - |
160 #pragma mark Public Methods | 160 #pragma mark Public Methods |
161 | 161 |
162 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate { | 162 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate { |
163 width = std::max(width, kMinimumContainerWidth); | 163 width = std::max(width, kMinimumContainerWidth); |
164 NSRect frame = [self frame]; | 164 NSRect frame = [self frame]; |
165 lastXPos_ = frame.origin.x; | 165 lastXPos_ = frame.origin.x; |
166 CGFloat dX = frame.size.width - width; | 166 CGFloat dX = frame.size.width - width; |
167 frame.size.width = width; | 167 frame.size.width = width; |
168 NSRect newFrame = NSOffsetRect(frame, dX, 0); | 168 animationEndFrame_ = NSOffsetRect(frame, dX, 0); |
169 if (animate) { | 169 if (animate) { |
170 [NSAnimationContext beginGrouping]; | 170 [NSAnimationContext beginGrouping]; |
171 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; | 171 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; |
172 [[self animator] setFrame:newFrame]; | 172 [[self animator] setFrame:animationEndFrame_]; |
173 [NSAnimationContext endGrouping]; | 173 [NSAnimationContext endGrouping]; |
174 animationEndFrame_ = newFrame; | |
175 } else { | 174 } else { |
176 [self setFrame:newFrame]; | 175 [self setFrame:animationEndFrame_]; |
177 [self setNeedsDisplay:YES]; | 176 [self setNeedsDisplay:YES]; |
178 } | 177 } |
179 } | 178 } |
180 | 179 |
181 - (CGFloat)resizeDeltaX { | 180 - (CGFloat)resizeDeltaX { |
182 return [self frame].origin.x - lastXPos_; | 181 return [self frame].origin.x - lastXPos_; |
183 } | 182 } |
184 | 183 |
185 #pragma mark - | 184 #pragma mark - |
186 #pragma mark Private Methods | 185 #pragma mark Private Methods |
(...skipping 29 matching lines...) Expand all Loading... |
216 [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; | 215 [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; |
217 grippyRect.origin.x += 1.0; | 216 grippyRect.origin.x += 1.0; |
218 NSRectFill(grippyRect); | 217 NSRectFill(grippyRect); |
219 | 218 |
220 [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; | 219 [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; |
221 grippyRect.origin.x += 1.0; | 220 grippyRect.origin.x += 1.0; |
222 NSRectFill(grippyRect); | 221 NSRectFill(grippyRect); |
223 } | 222 } |
224 | 223 |
225 @end | 224 @end |
OLD | NEW |