Skip to content

feat(movers): add configurable grid snapping and sliding AABB collision solver.#1831

Open
TheMapperJS wants to merge 1 commit into
tukui-org:mainfrom
TheMapperJS:feature/mover-grid-collision
Open

feat(movers): add configurable grid snapping and sliding AABB collision solver.#1831
TheMapperJS wants to merge 1 commit into
tukui-org:mainfrom
TheMapperJS:feature/mover-grid-collision

Conversation

@TheMapperJS

Copy link
Copy Markdown

Description

This PR adds two highly requested quality-of-life options directly to the /moveui popup panel: Grid Snapping and Mover Collision. These features significantly enhance the layout customization experience, making UI alignment clean, physical, and satisfying.

Key Features

  1. Configurable Grid Snapping (Drag & Drop):

    • Snaps movers to ElvUI's active visual grid lines (ElvUIGrid) in real-time during dragging and enforces a final, mathematically perfect grid snap upon release.
    • Snapping step sizes update dynamically (width / gridSize) when the grid size is changed in the move mode popup.
  2. 2D Sliding AABB Mover Collision:

    • Implements Axis-Aligned Bounding Box (AABB) collision resolution between active movers.
    • Uses minimum penetration depth resolution axis-by-axis, allowing frames to slide smoothly along each other's boundaries rather than overlapping, sticking, or "jumping" across the screen.
    • Screen parent containers (such as UIParent, ElvUIParent, and WorldFrame) are filtered out of the loop so movers only block against other actual layout frames.
  3. Smart Resolution & Scaling conversions:

    • Converts coordinates dynamically between individual frame-scale and global UIParent-scale. Snapping and collision boundaries remain pixel-perfect even if custom scales are applied to specific mover frames.
  4. Safety & Native Hooks:

    • Sticky Frames Integration: ElvUI's native edge-to-edge frame sticky-snapping takes priority over grid-snapping when frames are close, preserving alignment habits.
    • Shift Key Bypass: Pressing the Shift key while dragging temporarily bypasses all snapping and collision rules for custom overlapping layouts.
    • Persistent Profiles: Saved under E.db.general.gridSnap and E.db.general.moverCollision with defaults set to true.

Files Modified

  • Profile.lua: Registered profile defaults for gridSnap = true and moverCollision = true under P.general.
  • Config.lua: Expanded /moveui popup window height (from 190 to 215) and added two vertically stacked, styled checkboxes for "Grid Snapping" and "Mover Collision".
  • LibSimpleSticky.lua: Implemented IsOverlapping and ResolveCollisions sliding solvers, and hooked grid snapping and collision checks inside StickyFrames:GetUpdateFunc().
  • Movers.lua: Hooked StopMoving(frame) to enforce final snap calculations and commit the exact snapped positions to the layout database to prevent drift on /reload.

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