| 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/bookmark_button.h" | 5 #import "chrome/browser/cocoa/bookmark_button.h" | 
| 6 #include "base/logging.h" | 6 #include "base/logging.h" | 
| 7 #import "base/scoped_nsobject.h" | 7 #import "base/scoped_nsobject.h" | 
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 
| 9 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 9 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 
| 10 #import "chrome/browser/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/cocoa/browser_window_controller.h" | 
|  | 11 #import "chrome/browser/cocoa/view_id_util.h" | 
| 11 | 12 | 
| 12 // The opacity of the bookmark button drag image. | 13 // The opacity of the bookmark button drag image. | 
| 13 static const CGFloat kDragImageOpacity = 0.7; | 14 static const CGFloat kDragImageOpacity = 0.7; | 
| 14 | 15 | 
| 15 @interface BookmarkButton(Private) | 16 @interface BookmarkButton(Private) | 
| 16 | 17 | 
| 17 // Make a drag image for the button. | 18 // Make a drag image for the button. | 
| 18 - (NSImage*)dragImage; | 19 - (NSImage*)dragImage; | 
| 19 | 20 | 
| 20 @end  // @interface BookmarkButton(Private) | 21 @end  // @interface BookmarkButton(Private) | 
| 21 | 22 | 
| 22 | 23 | 
| 23 @implementation BookmarkButton | 24 @implementation BookmarkButton | 
| 24 | 25 | 
| 25 @synthesize delegate = delegate_; | 26 @synthesize delegate = delegate_; | 
| 26 | 27 | 
|  | 28 - (id)initWithFrame:(NSRect)frameRect { | 
|  | 29   // BookmarkButton's ViewID may be changed to VIEW_ID_OTHER_BOOKMARKS in | 
|  | 30   // BookmarkBarController, so we can't just override -viewID method to return | 
|  | 31   // it. | 
|  | 32   if ((self = [super initWithFrame:frameRect])) | 
|  | 33     view_id_util::SetID(self, VIEW_ID_BOOKMARK_BAR_ELEMENT); | 
|  | 34   return self; | 
|  | 35 } | 
|  | 36 | 
|  | 37 - (void)dealloc { | 
|  | 38   view_id_util::UnsetID(self); | 
|  | 39   [super dealloc]; | 
|  | 40 } | 
|  | 41 | 
| 27 - (const BookmarkNode*)bookmarkNode { | 42 - (const BookmarkNode*)bookmarkNode { | 
| 28   return [[self cell] bookmarkNode]; | 43   return [[self cell] bookmarkNode]; | 
| 29 } | 44 } | 
| 30 | 45 | 
| 31 - (BOOL)isFolder { | 46 - (BOOL)isFolder { | 
| 32   const BookmarkNode* node = [self bookmarkNode]; | 47   const BookmarkNode* node = [self bookmarkNode]; | 
| 33   return (node && node->is_folder()); | 48   return (node && node->is_folder()); | 
| 34 } | 49 } | 
| 35 | 50 | 
| 36 - (BOOL)isEmpty { | 51 - (BOOL)isEmpty { | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 144   [image drawAtPoint:NSMakePoint(0, 0) | 159   [image drawAtPoint:NSMakePoint(0, 0) | 
| 145             fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) | 160             fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) | 
| 146            operation:NSCompositeSourceOver | 161            operation:NSCompositeSourceOver | 
| 147             fraction:kDragImageOpacity]; | 162             fraction:kDragImageOpacity]; | 
| 148 | 163 | 
| 149   [dragImage unlockFocus]; | 164   [dragImage unlockFocus]; | 
| 150   return dragImage; | 165   return dragImage; | 
| 151 } | 166 } | 
| 152 | 167 | 
| 153 @end  // @implementation BookmarkButton(Private) | 168 @end  // @implementation BookmarkButton(Private) | 
| OLD | NEW | 
|---|