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

Side by Side Diff: ui/app_list/cocoa/item_drag_controller.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/app_list/cocoa/item_drag_controller.h" 5 #import "ui/app_list/cocoa/item_drag_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "ui/app_list/cocoa/apps_grid_view_item.h" 8 #import "ui/app_list/cocoa/apps_grid_view_item.h"
9 #include "ui/base/cocoa/window_size_constants.h" 9 #include "ui/base/cocoa/window_size_constants.h"
10 10
(...skipping 19 matching lines...) Expand all
30 @end 30 @end
31 31
32 @implementation ItemDragController 32 @implementation ItemDragController
33 33
34 - (id)initWithGridCellSize:(NSSize)size { 34 - (id)initWithGridCellSize:(NSSize)size {
35 if ((self = [super init])) { 35 if ((self = [super init])) {
36 NSRect frameRect = NSMakeRect(0, 36 NSRect frameRect = NSMakeRect(0,
37 0, 37 0,
38 size.width * kDraggingIconScale, 38 size.width * kDraggingIconScale,
39 size.height * kDraggingIconScale); 39 size.height * kDraggingIconScale);
40 scoped_nsobject<NSView> dragView([[NSView alloc] initWithFrame:frameRect]); 40 base::scoped_nsobject<NSView> dragView(
41 [[NSView alloc] initWithFrame:frameRect]);
41 [dragView setWantsLayer:YES]; 42 [dragView setWantsLayer:YES];
42 [dragView setHidden:YES]; 43 [dragView setHidden:YES];
43 44
44 dragLayer_.reset([[CALayer layer] retain]); 45 dragLayer_.reset([[CALayer layer] retain]);
45 [dragLayer_ setFrame:NSRectToCGRect(frameRect)]; 46 [dragLayer_ setFrame:NSRectToCGRect(frameRect)];
46 [[dragView layer] addSublayer:dragLayer_]; 47 [[dragView layer] addSublayer:dragLayer_];
47 48
48 [self setView:dragView]; 49 [self setView:dragView];
49 } 50 }
50 return self; 51 return self;
51 } 52 }
52 53
53 - (void)initiate:(AppsGridViewItem*)item 54 - (void)initiate:(AppsGridViewItem*)item
54 mouseDownLocation:(NSPoint)mouseDownLocation 55 mouseDownLocation:(NSPoint)mouseDownLocation
55 currentLocation:(NSPoint)currentLocation 56 currentLocation:(NSPoint)currentLocation
56 timestamp:(NSTimeInterval)eventTimestamp { 57 timestamp:(NSTimeInterval)eventTimestamp {
57 [self clearAnimations]; 58 [self clearAnimations];
58 [item setSelected:NO]; 59 [item setSelected:NO];
59 NSView* itemView = [item view]; 60 NSView* itemView = [item view];
60 NSPoint pointInGridCell = [itemView convertPoint:mouseDownLocation 61 NSPoint pointInGridCell = [itemView convertPoint:mouseDownLocation
61 fromView:nil]; 62 fromView:nil];
62 mouseOffset_ = NSMakePoint(pointInGridCell.x - NSMidX([itemView bounds]), 63 mouseOffset_ = NSMakePoint(pointInGridCell.x - NSMidX([itemView bounds]),
63 NSMidY([itemView bounds]) - pointInGridCell.y); 64 NSMidY([itemView bounds]) - pointInGridCell.y);
64 65
65 // Take a snapshot of the grid cell without the text label and hide the cell. 66 // Take a snapshot of the grid cell without the text label and hide the cell.
66 // Also remove the cell highlight on the image, added when it was clicked. 67 // Also remove the cell highlight on the image, added when it was clicked.
67 NSButton* button = [item button]; 68 NSButton* button = [item button];
68 scoped_nsobject<NSString> oldTitle([[item buttonTitle] retain]); 69 base::scoped_nsobject<NSString> oldTitle([[item buttonTitle] retain]);
69 [item setButtonTitle:[NSString string]]; 70 [item setButtonTitle:[NSString string]];
70 [[button cell] setHighlighted:NO]; 71 [[button cell] setHighlighted:NO];
71 NSBitmapImageRep* imageRep = 72 NSBitmapImageRep* imageRep =
72 [itemView bitmapImageRepForCachingDisplayInRect:[itemView visibleRect]]; 73 [itemView bitmapImageRepForCachingDisplayInRect:[itemView visibleRect]];
73 [itemView cacheDisplayInRect:[itemView visibleRect] 74 [itemView cacheDisplayInRect:[itemView visibleRect]
74 toBitmapImageRep:imageRep]; 75 toBitmapImageRep:imageRep];
75 [button setHidden:YES]; 76 [button setHidden:YES];
76 [item setButtonTitle:oldTitle]; 77 [item setButtonTitle:oldTitle];
77 78
78 [dragLayer_ setContents:reinterpret_cast<id>([imageRep CGImage])]; 79 [dragLayer_ setContents:reinterpret_cast<id>([imageRep CGImage])];
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 targetOrigin.y - NSMidY([itemView bounds]) * (kDraggingIconScale - 1), 154 targetOrigin.y - NSMidY([itemView bounds]) * (kDraggingIconScale - 1),
154 startRect.size.width, 155 startRect.size.width,
155 startRect.size.height); 156 startRect.size.height);
156 157
157 NSDictionary* animationDict = @{ 158 NSDictionary* animationDict = @{
158 NSViewAnimationTargetKey: [self view], 159 NSViewAnimationTargetKey: [self view],
159 NSViewAnimationStartFrameKey: [NSValue valueWithRect:startRect], 160 NSViewAnimationStartFrameKey: [NSValue valueWithRect:startRect],
160 NSViewAnimationEndFrameKey: [NSValue valueWithRect:targetRect] 161 NSViewAnimationEndFrameKey: [NSValue valueWithRect:targetRect]
161 }; 162 };
162 163
163 scoped_nsobject<NSViewAnimation> translate([[NSViewAnimation alloc] 164 base::scoped_nsobject<NSViewAnimation> translate([[NSViewAnimation alloc]
164 initWithViewAnimations:[NSArray arrayWithObject:animationDict]]); 165 initWithViewAnimations:[NSArray arrayWithObject:animationDict]]);
165 [translate setDuration:kAnimationDuration]; 166 [translate setDuration:kAnimationDuration];
166 [translate startAnimation]; 167 [translate startAnimation];
167 } 168 }
168 169
169 - (void)animateTransformFrom:(CATransform3D)fromValue 170 - (void)animateTransformFrom:(CATransform3D)fromValue
170 useDelegate:(BOOL)useDelegate { 171 useDelegate:(BOOL)useDelegate {
171 CABasicAnimation* animation = 172 CABasicAnimation* animation =
172 [CABasicAnimation animationWithKeyPath:@"transform"]; 173 [CABasicAnimation animationWithKeyPath:@"transform"];
173 [animation setFromValue:[NSValue valueWithCATransform3D:fromValue]]; 174 [animation setFromValue:[NSValue valueWithCATransform3D:fromValue]];
(...skipping 25 matching lines...) Expand all
199 if (!finished) 200 if (!finished)
200 return; 201 return;
201 202
202 DCHECK(shrinking_); 203 DCHECK(shrinking_);
203 [self clearAnimations]; 204 [self clearAnimations];
204 [dragLayer_ setContents:nil]; 205 [dragLayer_ setContents:nil];
205 [[self view] setHidden:YES]; 206 [[self view] setHidden:YES];
206 } 207 }
207 208
208 @end 209 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698