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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm

Issue 7528007: [Mac] Delete more bookmark bar folder code. This removes things that were missed last time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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 (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/bookmarks/bookmark_button.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/memory/scoped_nsobject.h" 8 #import "base/memory/scoped_nsobject.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 [delegate_ bookmarkDragDidEnd:self 249 [delegate_ bookmarkDragDidEnd:self
250 operation:operation]; 250 operation:operation];
251 // Tell delegate if it should delete us. 251 // Tell delegate if it should delete us.
252 if (operation & NSDragOperationDelete) { 252 if (operation & NSDragOperationDelete) {
253 dragEndScreenLocation_ = aPoint; 253 dragEndScreenLocation_ = aPoint;
254 [delegate_ didDragBookmarkToTrash:self]; 254 [delegate_ didDragBookmarkToTrash:self];
255 } 255 }
256 } 256 }
257 257
258 - (void)performMouseDownAction:(NSEvent*)theEvent { 258 - (void)performMouseDownAction:(NSEvent*)theEvent {
259 int eventMask = NSLeftMouseUpMask | NSMouseEnteredMask | NSMouseExitedMask |
260 NSLeftMouseDraggedMask;
261
262 BOOL keepGoing = YES;
263 [[self target] performSelector:[self action] withObject:self]; 259 [[self target] performSelector:[self action] withObject:self];
264 self.actionHasFired = YES; 260 self.actionHasFired = YES;
265
266 DraggableButton* insideBtn = nil;
267
268 while (keepGoing) {
269 theEvent = [[self window] nextEventMatchingMask:eventMask];
270 if (!theEvent)
271 continue;
272
273 NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow]
274 fromView:nil];
275 BOOL isInside = [self mouse:mouseLoc inRect:[self bounds]];
276
277 switch ([theEvent type]) {
278 case NSMouseEntered:
279 case NSMouseExited: {
280 NSView* trackedView = (NSView*)[[theEvent trackingArea] owner];
281 if (trackedView && [trackedView isKindOfClass:[self class]]) {
282 BookmarkButton* btn = static_cast<BookmarkButton*>(trackedView);
283 if (![btn acceptsTrackInFrom:self])
284 break;
285 if ([theEvent type] == NSMouseEntered) {
286 [[NSCursor arrowCursor] set];
287 [[btn cell] mouseEntered:theEvent];
288 insideBtn = btn;
289 } else {
290 [[btn cell] mouseExited:theEvent];
291 if (insideBtn == btn)
292 insideBtn = nil;
293 }
294 }
295 break;
296 }
297 case NSLeftMouseDragged: {
298 if (insideBtn)
299 [insideBtn mouseDragged:theEvent];
300 break;
301 }
302 case NSLeftMouseUp: {
303 self.durationMouseWasDown = [theEvent timestamp] - self.whenMouseDown;
304 if (!isInside && insideBtn && insideBtn != self) {
305 // Has tracked onto another BookmarkButton menu item, and released,
306 // so fire its action.
307 [[insideBtn target] performSelector:[insideBtn action]
308 withObject:insideBtn];
309
310 } else {
311 [self secondaryMouseUpAction:isInside];
312 [[self cell] mouseExited:theEvent];
313 [[insideBtn cell] mouseExited:theEvent];
314 }
315 keepGoing = NO;
316 break;
317 }
318 default:
319 /* Ignore any other kind of event. */
320 break;
321 }
322 }
323 } 261 }
324 262
325
326
327 // mouseEntered: and mouseExited: are called from our
328 // BookmarkButtonCell. We redirect this information to our delegate. 263 // BookmarkButtonCell. We redirect this information to our delegate.
329 // The controller can then perform menu-like actions (e.g. "hover over 264 // The controller can then perform menu-like actions (e.g. "hover over
330 // to open menu"). 265 // to open menu").
331 - (void)mouseEntered:(NSEvent*)event { 266 - (void)mouseEntered:(NSEvent*)event {
332 [delegate_ mouseEnteredButton:self event:event]; 267 [delegate_ mouseEnteredButton:self event:event];
333 } 268 }
334 269
335 // See comments above mouseEntered:. 270 // See comments above mouseEntered:.
336 - (void)mouseExited:(NSEvent*)event { 271 - (void)mouseExited:(NSEvent*)event {
337 [delegate_ mouseExitedButton:self event:event]; 272 [delegate_ mouseExitedButton:self event:event];
338 } 273 }
339 274
340 - (void)mouseMoved:(NSEvent*)theEvent { 275 - (void)mouseMoved:(NSEvent*)theEvent {
341 if ([delegate_ respondsToSelector:@selector(mouseMoved:)]) 276 if ([delegate_ respondsToSelector:@selector(mouseMoved:)])
342 [id(delegate_) mouseMoved:theEvent]; 277 [id(delegate_) mouseMoved:theEvent];
343 } 278 }
344 279
345 - (void)mouseDragged:(NSEvent*)theEvent { 280 - (void)mouseDragged:(NSEvent*)theEvent {
346 if ([delegate_ respondsToSelector:@selector(mouseDragged:)]) 281 if ([delegate_ respondsToSelector:@selector(mouseDragged:)])
347 [id(delegate_) mouseDragged:theEvent]; 282 [id(delegate_) mouseDragged:theEvent];
348 } 283 }
349 284
350 + (BookmarkButton*)draggedButton { 285 + (BookmarkButton*)draggedButton {
351 return gDraggedButton; 286 return gDraggedButton;
352 } 287 }
353 288
354 - (BOOL)canBecomeKeyView { 289 - (BOOL)canBecomeKeyView {
mrossetti 2011/08/08 21:42:24 Does the default implementation already return NO?
Robert Sesek 2011/08/08 21:42:48 I *think* it does, but it's not documented as such
355 // If button is an item in a folder menu, don't become key. 290 return NO;
356 return ![[self cell] isFolderButtonCell];
357 } 291 }
358 292
359 // This only gets called after a click that wasn't a drag, and only on folders. 293 // This only gets called after a click that wasn't a drag, and only on folders.
360 - (void)secondaryMouseUpAction:(BOOL)wasInside { 294 - (void)secondaryMouseUpAction:(BOOL)wasInside {
361 const NSTimeInterval kShortClickLength = 0.5; 295 const NSTimeInterval kShortClickLength = 0.5;
362 // Long clicks that end over the folder button result in the menu hiding. 296 // Long clicks that end over the folder button result in the menu hiding.
363 if (wasInside && ([self durationMouseWasDown] > kShortClickLength)) { 297 if (wasInside && ([self durationMouseWasDown] > kShortClickLength)) {
364 [[self target] performSelector:[self action] withObject:self]; 298 [[self target] performSelector:[self action] withObject:self];
365 } else { 299 } else {
366 // Mouse tracked out of button during menu track. Hide menus. 300 // Mouse tracked out of button during menu track. Hide menus.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 [image drawAtPoint:NSMakePoint(0, 0) 355 [image drawAtPoint:NSMakePoint(0, 0)
422 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) 356 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds))
423 operation:NSCompositeSourceOver 357 operation:NSCompositeSourceOver
424 fraction:kDragImageOpacity]; 358 fraction:kDragImageOpacity];
425 359
426 [dragImage unlockFocus]; 360 [dragImage unlockFocus];
427 return dragImage; 361 return dragImage;
428 } 362 }
429 363
430 @end // @implementation BookmarkButton(Private) 364 @end // @implementation BookmarkButton(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698