Skip to content

Reworked Drag Behavior to be default on shift#25

Merged
carl-andersson-at-westermo merged 5 commits into
mainfrom
23-grid-snapping-toggle
Jun 12, 2026
Merged

Reworked Drag Behavior to be default on shift#25
carl-andersson-at-westermo merged 5 commits into
mainfrom
23-grid-snapping-toggle

Conversation

@carl-andersson-at-westermo

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Avalonia drag/snapping behavior so snapping is driven by a Shift-based default predicate and refactors the ShowcaseApp DynamicGraph example to configure snapping per-vertex instead of via global behavior.

Changes:

  • Introduces new snapping helpers (GridSnap, WidthSnap, HeightSnap) and a Shift-based DefaultSnapPredicate.
  • Tracks key modifiers during drag (CurrentPointerKeyModifiers) and adds/removes a "ChildDragging" class on the drag container.
  • Updates the Avalonia DynamicGraph showcase to apply snapping predicates/modifiers when creating new vertices.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.

File Description
Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs Refactors snapping defaults/helpers and drag state handling (Shift-based default snapping, key-modifier tracking, simplified Snap()).
Examples/ShowcaseApp.Avalonia/Pages/DynamicGraph.axaml.cs Removes global snapping setup and applies snapping configuration to newly created vertices in the demo.

Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs Outdated
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs Outdated
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Examples/ShowcaseApp.Avalonia/Pages/DynamicGraph.axaml.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs
Comment thread Westermo.GraphX.Controls.Avalonia/Behaviours/DragBehaviour.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@carl-andersson-at-westermo carl-andersson-at-westermo merged commit a7aa83a into main Jun 12, 2026
4 checks passed
@carl-andersson-at-westermo carl-andersson-at-westermo deleted the 23-grid-snapping-toggle branch June 12, 2026 08:31
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.

Grid Snapping Toggle

3 participants