Changeset 2558 for trunk/AICustomTabDragging.m
- Timestamp:
- 04/20/05 19:37:46 (4 years ago)
- Files:
-
- trunk/AICustomTabDragging.m (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AICustomTabDragging.m
r2039 r2558 38 38 destTabBar = nil; 39 39 tabDragWindow = nil; 40 40 41 41 return(self); 42 42 } … … 86 86 NSPoint startPoint; 87 87 BOOL sourceWindowWillHide; 88 88 89 89 //Post the dragging will begin notification 90 90 [[NSNotificationCenter defaultCenter] postNotificationName:AICustomTabDragWillBegin object:self]; 91 91 92 92 //Setup 93 93 [destTabBar release]; destTabBar = nil; … … 95 95 dragTabCell = [inTabCell retain]; 96 96 selectTabAfterDrag = shouldSelect; 97 97 98 98 //Determine if the source window will hide as a result of this drag 99 99 sourceWindowWillHide = ([sourceTabBar removingLastTabHidesWindow] && [sourceTabBar numberOfTabViewItems] == 1); … … 101 101 destTabBar = [sourceView retain]; 102 102 } 103 103 104 104 //Adjust the drag offset so the cursor is atleast always touching the tab drag image 105 105 int width = [inTabCell frame].size.width; 106 106 int height = [inTabCell frame].size.height; 107 107 108 108 dragOffset = NSMakeSize([inTabCell frame].origin.x - clickLocation.x, [inTabCell frame].origin.y - clickLocation.y); 109 109 if(dragOffset.width > width) dragOffset.width = width; … … 111 111 if(dragOffset.height > height) dragOffset.height = height; 112 112 if(dragOffset.height < -height) dragOffset.height = -height; 113 113 114 114 //Create the drag window for our custom drag tracking 115 115 tabDragWindow = [AICustomTabDragWindow dragWindowForCustomTabView:sourceView … … 117 117 transparent:!([sourceTabBar removingLastTabHidesWindow])]; 118 118 [tabDragWindow setDisplayingFullWindow:sourceWindowWillHide animate:NO]; 119 119 120 120 //Position the drag window 121 121 startPoint = [[inEvent window] convertBaseToScreen:[inEvent locationInWindow]]; 122 122 startPoint = NSMakePoint(startPoint.x + dragOffset.width, startPoint.y + dragOffset.height); 123 123 [tabDragWindow moveToPoint:startPoint]; 124 124 125 125 //Hide the source window 126 126 if(sourceWindowWillHide){ 127 127 [[sourceTabBar window] setAlphaValue:0.0]; 128 128 } 129 129 130 130 //Perform the drag 131 131 pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; … … 139 139 source:self 140 140 slideBack:NO]; 141 141 142 142 //Sneaky Bug Fix --- 143 143 //After dropping a tab into a tab bar, the tabbar's cursor tracking is rebuilt. Unfortunately, since the floating 144 //window (With an image of the tab) used for dragging is still over the tab bar, any cursor rects we attempt to 144 //window (With an image of the tab) used for dragging is still over the tab bar, any cursor rects we attempt to 145 145 //install below it will not work. A sneaky solution to this is to remember the destination tab bar of the drag, 146 146 //and reset it's cursor tracking again, after the drag window has closed. … … 150 150 [_destinationOfLastDrag release]; _destinationOfLastDrag= nil; 151 151 } 152 152 153 153 } 154 154 155 155 //End a drag 156 156 - (void)acceptDragIntoTabView:(AICustomTabsView *)destTabView atIndex:(int)destIndex 157 { 157 { 158 158 if(destTabView == sourceTabBar){ 159 159 //Tab re-arranging we handle internally … … 170 170 } 171 171 } 172 172 173 173 //Remember the dest tab bar so we can reset cursor tracking (see dragTabCell:fromCustomTabsView:withEvent:) 174 174 _destinationOfLastDrag = [destTabBar retain]; … … 192 192 { 193 193 [tabDragWindow setDisplayingFullWindow:(!destTabBar) animate:YES]; 194 194 195 195 if(!destTabBar){ 196 196 [tabDragWindow moveToPoint:screenPoint]; … … 200 200 //Invoked in the dragging source as the drag ends 201 201 - (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation 202 { 202 { 203 203 if(operation == NSDragOperationNone){ //when dropped on the screen 204 204 //Sneaky Bug Fix --- … … 208 208 //we can assume it's a tab bar the system failed to send a draggingExited event, and send it ourself. 209 209 if(destTabBar) [destTabBar draggingExited:nil]; 210 210 211 211 screenPoint.x -= CUSTOM_TABS_INDENT; 212 212 if([[sourceTabBar delegate] respondsToSelector:@selector(customTabView:didMoveTabViewItem:toCustomTabView:index:screenPoint:)]){ … … 214 214 } 215 215 } 216 216 217 217 //Cleanup drag 218 218 [self cleanupDrag]; … … 230 230 [dragTabCell release]; dragTabCell = nil; 231 231 [destTabBar release]; destTabBar = nil; 232 [sourceTabBar release]; sourceTabBar = nil; 232 [sourceTabBar release]; sourceTabBar = nil; 233 233 } 234 234
