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

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

Issue 795663003: [Mac Extensions Toolbar] Make the container's animationEndFrame always valid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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) 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 18 matching lines...) Expand all
29 } // namespace 29 } // namespace
30 30
31 @interface BrowserActionsContainerView(Private) 31 @interface BrowserActionsContainerView(Private)
32 // Returns the cursor that should be shown when hovering over the grippy based 32 // Returns the cursor that should be shown when hovering over the grippy based
33 // on |canDragLeft_| and |canDragRight_|. 33 // on |canDragLeft_| and |canDragRight_|.
34 - (NSCursor*)appropriateCursorForGrippy; 34 - (NSCursor*)appropriateCursorForGrippy;
35 @end 35 @end
36 36
37 @implementation BrowserActionsContainerView 37 @implementation BrowserActionsContainerView
38 38
39 @synthesize animationEndFrame = animationEndFrame_;
40 @synthesize canDragLeft = canDragLeft_; 39 @synthesize canDragLeft = canDragLeft_;
41 @synthesize canDragRight = canDragRight_; 40 @synthesize canDragRight = canDragRight_;
42 @synthesize grippyPinned = grippyPinned_; 41 @synthesize grippyPinned = grippyPinned_;
43 @synthesize maxWidth = maxWidth_; 42 @synthesize maxWidth = maxWidth_;
44 @synthesize userIsResizing = userIsResizing_; 43 @synthesize userIsResizing = userIsResizing_;
45 44
46 #pragma mark - 45 #pragma mark -
47 #pragma mark Overridden Class Functions 46 #pragma mark Overridden Class Functions
48 47
49 - (id)initWithFrame:(NSRect)frameRect { 48 - (id)initWithFrame:(NSRect)frameRect {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 NSRect frame = [self frame]; 166 NSRect frame = [self frame];
168 lastXPos_ = frame.origin.x; 167 lastXPos_ = frame.origin.x;
169 CGFloat dX = frame.size.width - width; 168 CGFloat dX = frame.size.width - width;
170 frame.size.width = width; 169 frame.size.width = width;
171 NSRect newFrame = NSOffsetRect(frame, dX, 0); 170 NSRect newFrame = NSOffsetRect(frame, dX, 0);
172 if (animate) { 171 if (animate) {
173 [NSAnimationContext beginGrouping]; 172 [NSAnimationContext beginGrouping];
174 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; 173 [[NSAnimationContext currentContext] setDuration:kAnimationDuration];
175 [[self animator] setFrame:newFrame]; 174 [[self animator] setFrame:newFrame];
176 [NSAnimationContext endGrouping]; 175 [NSAnimationContext endGrouping];
177 animationEndFrame_ = newFrame;
178 176
179 [[NSNotificationCenter defaultCenter] 177 [[NSNotificationCenter defaultCenter]
180 postNotificationName:kBrowserActionsContainerWillAnimate 178 postNotificationName:kBrowserActionsContainerWillAnimate
181 object:self]; 179 object:self];
182 } else { 180 } else {
183 [self setFrame:newFrame]; 181 [self setFrame:newFrame];
184 [self setNeedsDisplay:YES]; 182 [self setNeedsDisplay:YES];
185 } 183 }
186 } 184 }
187 185
188 - (CGFloat)resizeDeltaX { 186 - (CGFloat)resizeDeltaX {
189 return [self frame].origin.x - lastXPos_; 187 return [self frame].origin.x - lastXPos_;
190 } 188 }
191 189
190 - (NSRect)animationEndFrame {
191 return [[self animator] frame];
192 }
193
192 #pragma mark - 194 #pragma mark -
193 #pragma mark Private Methods 195 #pragma mark Private Methods
194 196
195 // Returns the cursor to display over the grippy hover region depending on the 197 // Returns the cursor to display over the grippy hover region depending on the
196 // current drag state. 198 // current drag state.
197 - (NSCursor*)appropriateCursorForGrippy { 199 - (NSCursor*)appropriateCursorForGrippy {
198 NSCursor* retVal; 200 NSCursor* retVal;
199 if (!resizable_ || (!canDragLeft_ && !canDragRight_)) { 201 if (!resizable_ || (!canDragLeft_ && !canDragRight_)) {
200 retVal = [NSCursor arrowCursor]; 202 retVal = [NSCursor arrowCursor];
201 } else if (!canDragLeft_) { 203 } else if (!canDragLeft_) {
202 retVal = [NSCursor resizeRightCursor]; 204 retVal = [NSCursor resizeRightCursor];
203 } else if (!canDragRight_) { 205 } else if (!canDragRight_) {
204 retVal = [NSCursor resizeLeftCursor]; 206 retVal = [NSCursor resizeLeftCursor];
205 } else { 207 } else {
206 retVal = [NSCursor resizeLeftRightCursor]; 208 retVal = [NSCursor resizeLeftRightCursor];
207 } 209 }
208 return retVal; 210 return retVal;
209 } 211 }
210 212
211 @end 213 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698