| | 102 | } |
|---|
| | 103 | |
|---|
| | 104 | |
|---|
| | 105 | |
|---|
| | 106 | #pragma mark - |
|---|
| | 107 | |
|---|
| | 108 | - (void)viewFrameDidChange:(NSNotification *)notification { |
|---|
| | 109 | NSClipView *clipView; |
|---|
| | 110 | NSRect frame, visibleRect; |
|---|
| | 111 | |
|---|
| | 112 | clipView = [notification object]; |
|---|
| | 113 | frame = [[clipView documentView] frame]; |
|---|
| | 114 | visibleRect = [clipView documentVisibleRect]; |
|---|
| | 115 | |
|---|
| | 116 | if(frame.size.width > visibleRect.size.width || frame.size.height > visibleRect.size.height) |
|---|
| | 117 | [clipView setDocumentCursor:[NSCursor openHandCursor]]; |
|---|
| | 118 | else |
|---|
| | 119 | [clipView setDocumentCursor:[NSCursor arrowCursor]]; |
|---|
| 209 | | [[FHController controller] zoom:self]; |
|---|
| | 245 | _dragging = NO; |
|---|
| | 246 | } |
|---|
| | 247 | |
|---|
| | 248 | |
|---|
| | 249 | |
|---|
| | 250 | - (void)mouseUp:(NSEvent *)event { |
|---|
| | 251 | if(!_dragging) |
|---|
| | 252 | [[FHController controller] zoom:self]; |
|---|
| | 253 | } |
|---|
| | 254 | |
|---|
| | 255 | |
|---|
| | 256 | |
|---|
| | 257 | - (void)mouseDragged:(NSEvent *)event { |
|---|
| | 258 | NSPoint point, originalPoint; |
|---|
| | 259 | NSRect originalRect; |
|---|
| | 260 | float x, y; |
|---|
| | 261 | |
|---|
| | 262 | _dragging = YES; |
|---|
| | 263 | |
|---|
| | 264 | originalPoint = [event locationInWindow]; |
|---|
| | 265 | originalRect = [self visibleRect]; |
|---|
| | 266 | |
|---|
| | 267 | [[NSCursor closedHandCursor] push]; |
|---|
| | 268 | |
|---|
| | 269 | do { |
|---|
| | 270 | event = [[self window] nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask]; |
|---|
| | 271 | |
|---|
| | 272 | if([event type] == NSLeftMouseDragged) { |
|---|
| | 273 | point = [event locationInWindow]; |
|---|
| | 274 | x = originalPoint.x - point.x; |
|---|
| | 275 | y = originalPoint.y - point.y; |
|---|
| | 276 | |
|---|
| | 277 | [self scrollRectToVisible:NSOffsetRect(originalRect, x, y)]; |
|---|
| | 278 | } |
|---|
| | 279 | } while([event type] != NSLeftMouseUp); |
|---|
| | 280 | |
|---|
| | 281 | [NSCursor pop]; |
|---|