Skip to content
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

editor.diagram: add support for grid snapping #949

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

alexanderpann
Copy link
Collaborator

@alexanderpann alexanderpann commented Sep 16, 2024

Diagrams can now show a grid that is used for snapping elements to it. It can be configured (visibility, grid snapping, grid color/size/style) in the editor definition of the diagram itself:

Screenshot 2024-09-16 at 09 20 29

The elements sometimes don't snap to the grid itself but that seems to be an issue in the library itself. Taken from https://github.com/jgraph/mxgraph/blob/ff141aab158417bd866e2dfebd06c61d40773cd2/java/src/com/mxgraph/swing/handler/mxGraphHandler.java#L1105:

Drag image size depends on the initial position and may sometimes
not align with the grid when dragging. This is because the rounding of the width
and height at the initial position may be different than that at the current
position as the left and bottom side of the shape must align to the grid lines.
Only fix is a full repaint of the drag cells at each new mouse location.

@alexanderpann alexanderpann marked this pull request as draft September 16, 2024 12:33
@alexanderpann alexanderpann marked this pull request as ready for review September 17, 2024 07:43
Copy link
Collaborator

@HeikoBecker HeikoBecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this feature. Looks great!

LGTM.

@alexanderpann alexanderpann merged commit c302db3 into maintenance/mps20223 Sep 18, 2024
1 check passed
@alexanderpann alexanderpann deleted the feature/diagram_grid_snapping branch September 18, 2024 06:00
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.

2 participants