diff options
author | Alex Merry <dev@randomguy3.me.uk> | 2012-06-08 19:59:07 +0100 |
---|---|---|
committer | Alex Merry <dev@randomguy3.me.uk> | 2012-06-08 19:59:07 +0100 |
commit | ee3648293706ce512277532951fa015ecfc0ee3e (patch) | |
tree | c58ae3a73fa00bf91d7ea11d19c84ebf53c0f502 /tikzit/src/gtk/GraphInputHandler.m | |
parent | 96bb49b438646b54f1a667a66a9bb1b2c27d7b4f (diff) |
Set the cursor when dragging would resize bounding box
This makes it obvious to users when clicking will resize the bounding
box, rather than creating a new one.
Diffstat (limited to 'tikzit/src/gtk/GraphInputHandler.m')
-rw-r--r-- | tikzit/src/gtk/GraphInputHandler.m | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/tikzit/src/gtk/GraphInputHandler.m b/tikzit/src/gtk/GraphInputHandler.m index 4d77045..caaadeb 100644 --- a/tikzit/src/gtk/GraphInputHandler.m +++ b/tikzit/src/gtk/GraphInputHandler.m @@ -34,7 +34,7 @@ static const InputMask unionSelectMask = ShiftMask; leaderNode = nil; modifyEdge = nil; selectionBoxContents = [[NSMutableSet alloc] initWithCapacity:10]; - grabbedResizeHandle = NoHandle; + currentResizeHandle = NoHandle; } return self; @@ -94,6 +94,7 @@ static const InputMask unionSelectMask = ShiftMask; if (mode != m) { if (mode == BoundingBoxMode) { [renderer setBoundingBoxHandlesShown:NO]; + [[renderer surface] setCursor:NormalCursor]; } mode = m; [self deselectAll]; @@ -143,9 +144,9 @@ static const InputMask unionSelectMask = ShiftMask; } } else if (mode == BoundingBoxMode) { state = BoundingBoxState; - grabbedResizeHandle = [renderer boundingBoxResizeHandleAt:pos]; + currentResizeHandle = [renderer boundingBoxResizeHandleAt:pos]; [[self doc] startChangeBoundingBox]; - if (grabbedResizeHandle == NoHandle) { + if (currentResizeHandle == NoHandle) { [[[self doc] graph] setBoundingBox:NSZeroRect]; [renderer setBoundingBoxHandlesShown:NO]; } @@ -324,7 +325,7 @@ static const InputMask unionSelectMask = ShiftMask; } else if (state == BoundingBoxState) { Grid *grid = [renderer grid]; Graph *graph = [[self doc] graph]; - if (grabbedResizeHandle == NoHandle) { + if (currentResizeHandle == NoHandle) { NSRect bbox = NSRectAroundPoints( [grid snapScreenPoint:dragOrigin], [grid snapScreenPoint:pos] @@ -334,9 +335,9 @@ static const InputMask unionSelectMask = ShiftMask; NSRect bbox = [transformer rectToScreen:[graph boundingBox]]; NSPoint p2 = [grid snapScreenPoint:pos]; - if (grabbedResizeHandle == NorthWestHandle || - grabbedResizeHandle == NorthHandle || - grabbedResizeHandle == NorthEastHandle) { + if (currentResizeHandle == NorthWestHandle || + currentResizeHandle == NorthHandle || + currentResizeHandle == NorthEastHandle) { float dy = p2.y - NSMinY(bbox); if (dy < bbox.size.height) { @@ -347,9 +348,9 @@ static const InputMask unionSelectMask = ShiftMask; bbox.size.height = 0; } - } else if (grabbedResizeHandle == SouthWestHandle || - grabbedResizeHandle == SouthHandle || - grabbedResizeHandle == SouthEastHandle) { + } else if (currentResizeHandle == SouthWestHandle || + currentResizeHandle == SouthHandle || + currentResizeHandle == SouthEastHandle) { float dy = p2.y - NSMaxY(bbox); if (-dy < bbox.size.height) { @@ -359,9 +360,9 @@ static const InputMask unionSelectMask = ShiftMask; } } - if (grabbedResizeHandle == NorthWestHandle || - grabbedResizeHandle == WestHandle || - grabbedResizeHandle == SouthWestHandle) { + if (currentResizeHandle == NorthWestHandle || + currentResizeHandle == WestHandle || + currentResizeHandle == SouthWestHandle) { float dx = p2.x - NSMinX(bbox); if (dx < bbox.size.width) { @@ -372,9 +373,9 @@ static const InputMask unionSelectMask = ShiftMask; bbox.size.width = 0; } - } else if (grabbedResizeHandle == NorthEastHandle || - grabbedResizeHandle == EastHandle || - grabbedResizeHandle == SouthEastHandle) { + } else if (currentResizeHandle == NorthEastHandle || + currentResizeHandle == EastHandle || + currentResizeHandle == SouthEastHandle) { float dx = p2.x - NSMaxX(bbox); if (-dx < bbox.size.width) { @@ -393,6 +394,43 @@ static const InputMask unionSelectMask = ShiftMask; [[renderer transformer] setOrigin:newOrigin]; [renderer invalidateGraph]; } + if (mode == BoundingBoxMode && state != BoundingBoxState) { + ResizeHandle handle = [renderer boundingBoxResizeHandleAt:pos]; + if (handle != currentResizeHandle) { + currentResizeHandle = handle; + Cursor c = NormalCursor; + switch (handle) { + case EastHandle: + c = ResizeRightCursor; + break; + case SouthEastHandle: + c = ResizeBottomRightCursor; + break; + case SouthHandle: + c = ResizeBottomCursor; + break; + case SouthWestHandle: + c = ResizeBottomLeftCursor; + break; + case WestHandle: + c = ResizeLeftCursor; + break; + case NorthWestHandle: + c = ResizeTopLeftCursor; + break; + case NorthHandle: + c = ResizeTopCursor; + break; + case NorthEastHandle: + c = ResizeTopRightCursor; + break; + default: + c = NormalCursor; + break; + } + [[renderer surface] setCursor:c]; + } + } } - (void) mouseScrolledAt:(NSPoint)pos inDirection:(ScrollDirection)dir withMask:(InputMask)mask { |