Skip to content

Add single node resizing #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2025
Merged

Add single node resizing #5

merged 4 commits into from
Apr 2, 2025

Conversation

iamnbutler
Copy link
Owner

Note: Resizing for multiple nodes at the same time isn't implemented yet

This commit adds resize controls to selected elements in the canvas:

1. Added a new resize.rs module with:
   - ResizeHandle enum to represent the four corner positions
   - ResizeOperation struct to track resize state
   - ResizeConfig to manage resize options (aspect ratio, resize from center)

2. Extended the DragType enum to add a Resize variant

3. Added visual resize handles:
   - Drew 7px square handles at each corner of a selected element
   - Handles have white background with selection-colored borders

4. Implemented resize functionality:
   - Added hit detection for resize handles
   - Implemented standard corner resizing
   - Added support for Shift+drag to preserve aspect ratio
   - Added support for Option+drag to resize from center
   - Made resize operations non-destructive until mouse release

The resize controls only appear when a single element is selected.
1. First pass: Draw all nodes and hover effects
2. Second pass: Draw selection outlines and resize handles
1. Third pass: Draw the group selection outline
  - Clarify non-obvious behaviors like subpixel alignment
@iamnbutler iamnbutler merged commit f0034dd into main Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant