tiles: Fix resize not snapping to other panels#2481
Closed
ylinwind wants to merge 2 commits into
Closed
Conversation
Resize handles already computed the magnetic snap edge, but `resize()` applied `round_to_nearest_ten()` on every frame, quantizing the snapped value back to the grid so the snap to neighboring panels was invisible. Dragging works because `update_position` snaps without per-frame rounding. Make resize symmetric with drag: apply snapped values directly while resizing and align to the grid on mouse up. Also remove the now-unused `panel()` helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4ff007c to
54d466d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resizing a tile did not magnetically snap to neighboring panels, even though dragging (moving) a tile did.
The resize handles already computed the snapped edge via
calculate_resize_edge_snap, butresize()then calledround_to_nearest_ten()on x/y/width/height every frame. Withtile_grid_size = 8px, this quantized the snapped value back onto the grid, so the snap to another panel's edge was overridden/invisible. Dragging worked becauseupdate_positiondeliberately snaps without per-frame rounding ("smooth dragging") and only aligns to the grid on mouse up.This PR makes resize symmetric with drag:
resize()now applies the (already snapped) values directly, without per-frame grid rounding.pub(crate) panel()helper.No performance impact — this removes per-frame rounding work from the resize hot path; the snap logic is O(n) per frame, the same as the existing drag snap.
🤖 Generated with Claude Code