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

Unified Diff: chrome/browser/cocoa/bookmark_bar_controller.mm

Issue 2824004: Not meant to be reviewed or checked in: bookmark bar dragging 06/14/2010 Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.h ('k') | chrome/browser/cocoa/bookmark_bar_view.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_controller.mm
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index f605dabde5fdae203d7a96a9aedd1d9e9d9bd43e..e2ff4a726a453e17f07b2fbb421f555c73345d9b 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -432,6 +432,44 @@ const NSTimeInterval kBookmarkBarAnimationDuration = 0.12;
return defaultImage_;
}
+- (void)performPeriodicDraggingUpdates:(id<NSDraggingInfo>)info {
+ NSLog(@"performPeriodicDraggingUpdates Ran!");
+ // Get the button being dragged from the pasteboard
+ NSData* data = [[info draggingPasteboard]
+ dataForType:kBookmarkButtonDragType];
+
+ if (data && [info draggingSource]) {
+ BookmarkButton* sourceButton = nil;
+ [data getBytes:&sourceButton length:sizeof(sourceButton)];
+
+ NSRect dragButtonFrame = [sourceButton frame];
+
+ // Get the offset amount that other buttons will be moved
+ CGFloat xOffset =
+ NSWidth(dragButtonFrame) + bookmarks::kBookmarkHorizontalPadding;
+
+ // Get the current point the mouse located at during the drag
+ NSPoint point = [info draggingLocation];
+
+ NSArray* array = buttons_.get();
+ NSUInteger startIndex = [array indexOfObject:sourceButton];
+
+ for (BookmarkButton* button in array) {
+ NSRect buttonFrame = [button frame];
+ NSUInteger endIndex = [array indexOfObject:button];
+ if (NSMinX(buttonFrame) < point.x && NSMaxX(buttonFrame) > point.x) {
+ if (endIndex < startIndex && NSMidX(buttonFrame) > point.x) {
+ buttonFrame.origin.x += xOffset;
+ [button setFrame:buttonFrame];
+ } else if (startIndex < endIndex && NSMidX(buttonFrame) < point.x) {
+ buttonFrame.origin.x -= xOffset;
+ [button setFrame:buttonFrame];
+ }
+ }
+ }
+ }
+}
+
- (void)closeFolderAndStopTrackingMenus {
showFolderMenus_ = NO;
[self closeAllBookmarkFolders];
@@ -2215,8 +2253,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
BookmarkButton* movedButton = [buttons_ objectAtIndex:fromIndex];
NSRect movedFrame = [movedButton frame];
NSPoint toOrigin = movedFrame.origin;
- CGFloat xOffset =
- NSWidth(movedFrame) + bookmarks::kBookmarkHorizontalPadding;
// Hide the button to reduce flickering while drawing the window.
[movedButton setHidden:YES];
[buttons_ removeObjectAtIndex:fromIndex];
@@ -2224,23 +2260,12 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
// Move the button from left to right within the bar.
BookmarkButton* targetButton = [buttons_ objectAtIndex:toIndex - 1];
NSRect toFrame = [targetButton frame];
- toOrigin.x = toFrame.origin.x - NSWidth(movedFrame) + NSWidth(toFrame);
- for (NSInteger i = fromIndex; i < toIndex; ++i) {
- BookmarkButton* button = [buttons_ objectAtIndex:i];
- NSRect frame = [button frame];
- frame.origin.x -= xOffset;
- [button setFrameOrigin:frame.origin];
- }
+ toOrigin.x = toFrame.origin.x + NSWidth(toFrame);
} else {
// Move the button from right to left within the bar.
BookmarkButton* targetButton = [buttons_ objectAtIndex:toIndex];
- toOrigin = [targetButton frame].origin;
- for (NSInteger i = fromIndex - 1; i >= toIndex; --i) {
- BookmarkButton* button = [buttons_ objectAtIndex:i];
- NSRect buttonFrame = [button frame];
- buttonFrame.origin.x += xOffset;
- [button setFrameOrigin:buttonFrame.origin];
- }
+ NSRect toFrame = [targetButton frame];
+ toOrigin.x = toFrame.origin.x - NSWidth(movedFrame);
}
[buttons_ insertObject:movedButton atIndex:toIndex];
[movedButton setFrameOrigin:toOrigin];
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.h ('k') | chrome/browser/cocoa/bookmark_bar_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698