| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_bar_view.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" | 7 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" |
| 8 #import "chrome/browser/browser_theme_provider.h" | 8 #import "chrome/browser/browser_theme_provider.h" |
| 9 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 9 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
| 10 #import "chrome/browser/cocoa/bookmark_button.h" | 10 #import "chrome/browser/cocoa/bookmark_button.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 - (BookmarkBarController*)controller { | 102 - (BookmarkBarController*)controller { |
| 103 return controller_; | 103 return controller_; |
| 104 } | 104 } |
| 105 | 105 |
| 106 -(void)drawRect:(NSRect)dirtyRect { | 106 -(void)drawRect:(NSRect)dirtyRect { |
| 107 [super drawRect:dirtyRect]; | 107 [super drawRect:dirtyRect]; |
| 108 | 108 |
| 109 // Draw the bookmark-button-dragging drop indicator if necessary. | 109 // Draw the bookmark-button-dragging drop indicator if necessary. |
| 110 if (dropIndicatorShown_) { | 110 if (dropIndicatorShown_) { |
| 111 NSLog(@"Drop Indicator Should Be Drawn!"); |
| 111 const CGFloat kBarWidth = 1; | 112 const CGFloat kBarWidth = 1; |
| 112 const CGFloat kBarHalfWidth = kBarWidth / 2.0; | 113 const CGFloat kBarHalfWidth = kBarWidth / 2.0; |
| 113 const CGFloat kBarVertPad = 4; | 114 const CGFloat kBarVertPad = 4; |
| 114 const CGFloat kBarOpacity = 0.85; | 115 const CGFloat kBarOpacity = 0.85; |
| 115 | 116 |
| 116 // Prevent the indicator from being clipped on the left. | 117 // Prevent the indicator from being clipped on the left. |
| 117 CGFloat xLeft = MAX(dropIndicatorPosition_ - kBarHalfWidth, 0); | 118 CGFloat xLeft = MAX(dropIndicatorPosition_ - kBarHalfWidth, 0); |
| 118 | 119 |
| 119 NSRect uglyBlackBar = | 120 NSRect uglyBlackBar = |
| 120 NSMakeRect(xLeft, kBarVertPad, | 121 NSMakeRect(xLeft, kBarVertPad, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 176 |
| 176 - (void)draggingEnded:(id<NSDraggingInfo>)info { | 177 - (void)draggingEnded:(id<NSDraggingInfo>)info { |
| 177 // For now, we just call |-draggingExited:|. | 178 // For now, we just call |-draggingExited:|. |
| 178 [self draggingExited:info]; | 179 [self draggingExited:info]; |
| 179 } | 180 } |
| 180 | 181 |
| 181 - (BOOL)wantsPeriodicDraggingUpdates { | 182 - (BOOL)wantsPeriodicDraggingUpdates { |
| 182 // TODO(port): This should probably return |YES| and the controller should | 183 // TODO(port): This should probably return |YES| and the controller should |
| 183 // slide the existing bookmark buttons interactively to the side to make | 184 // slide the existing bookmark buttons interactively to the side to make |
| 184 // room for the about-to-be-dropped bookmark. | 185 // room for the about-to-be-dropped bookmark. |
| 185 return NO; | 186 return YES; |
| 186 } | 187 } |
| 187 | 188 |
| 188 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info { | 189 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info { |
| 189 // For now it's the same as draggingEntered:. | 190 // For now it's the same as draggingEntered:. |
| 190 // TODO(jrg): once we return YES for wantsPeriodicDraggingUpdates, | 191 // TODO(jrg): once we return YES for wantsPeriodicDraggingUpdates, |
| 191 // this should ping the controller_ to perform animations. | 192 // this should ping the controller_ to perform animations. |
| 193 if ([self wantsPeriodicDraggingUpdates]) { |
| 194 BOOL dragCouldHappen = [controller_ shouldShowIndicatorShownForPoint: |
| 195 [info draggingLocation]]; |
| 196 if (dragCouldHappen) { |
| 197 [controller_ performPeriodicDraggingUpdates:info]; |
| 198 } |
| 199 |
| 200 // TODO: Something needs to happen for the case where a drag occurs |
| 201 // from another place (web_drop_target, url_drop_target). Preferrably, |
| 202 // a button will appear that can be dragged. Alternatively, we're still |
| 203 // going to want to show the drop indicator for now. How can we check where |
| 204 // the drop is coming from? |
| 205 |
| 206 [controller_ draggingEntered:info]; // allow hover-open to work. |
| 207 return [info draggingSource] ? NSDragOperationMove : NSDragOperationCopy; |
| 208 } |
| 209 |
| 192 return [self draggingEntered:info]; | 210 return [self draggingEntered:info]; |
| 193 } | 211 } |
| 194 | 212 |
| 195 - (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)info { | 213 - (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)info { |
| 196 return YES; | 214 return YES; |
| 197 } | 215 } |
| 198 | 216 |
| 199 // Implement NSDraggingDestination protocol method | 217 // Implement NSDraggingDestination protocol method |
| 200 // performDragOperation: for URLs. | 218 // performDragOperation: for URLs. |
| 201 - (BOOL)performDragOperationForURL:(id<NSDraggingInfo>)info { | 219 - (BOOL)performDragOperationForURL:(id<NSDraggingInfo>)info { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return YES; | 261 return YES; |
| 244 } | 262 } |
| 245 return NO; | 263 return NO; |
| 246 } | 264 } |
| 247 | 265 |
| 248 - (void)setController:(id)controller { | 266 - (void)setController:(id)controller { |
| 249 controller_ = controller; | 267 controller_ = controller; |
| 250 } | 268 } |
| 251 | 269 |
| 252 @end // @implementation BookmarkBarView | 270 @end // @implementation BookmarkBarView |
| OLD | NEW |