Skip to content

Insert point on segment by clicking once (no more sliding); Ctrl+click to remove segment #2495

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

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

4adex
Copy link
Contributor

@4adex 4adex commented Mar 28, 2025

Part of #1870

When clicking a segment (new since video was recorded):

  • Clicking without any modifier key should split the segment where clicked. Currently this has the extra complication of entering an insertion mode where the point of the segment split can be slid within the segment and left click confirms it while right click cancels. We want to remove that extra step and just insert directly. An overlay should be drawn in cases where the cursor is hovered over the segment such that clicking would insert a split, it should be a short line segment (20px in diameter) running perpendicular to the curve.

  • Ctrl clicking should delete the segment that's clicked. Currently a user would have to split the segment then delete the newly created point.

@4adex 4adex marked this pull request as ready for review March 31, 2025 10:32
@4adex 4adex changed the title Segment hover, clicking and Ctrl + click Insert point when hovering on segment + Ctrl click to delete segment Mar 31, 2025
@Keavon
Copy link
Member

Keavon commented Apr 6, 2025

!build

Copy link

github-actions bot commented Apr 6, 2025

📦 Build Complete for b4fb9bb
https://f35b2fe6.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented Apr 6, 2025

This don't seem to be acting on a very reliable basis: https://files.keavon.com/-/IntrepidWhichAndeancondor/capture_4_.mp4

Please also make the size of the line and X visualization configurable in consts.rs.

@Keavon Keavon marked this pull request as draft April 6, 2025 09:17
@Keavon Keavon changed the title Insert point when hovering on segment + Ctrl click to delete segment Insert point on segment by clicking once (no more sliding); Ctrl+click to remove segment Apr 6, 2025
@Keavon Keavon force-pushed the master branch 3 times, most recently from aa7ff13 to e11b57a Compare April 6, 2025 11:41
@4adex 4adex marked this pull request as ready for review April 13, 2025 19:51
@4adex
Copy link
Contributor Author

4adex commented Apr 13, 2025

Moved the constants to consts.rs and also increased the tolerance so that it moves to insertion mode better. It seems to be unreliable because the size of overlay was more than the tolerance.

@Keavon
Copy link
Member

Keavon commented Apr 14, 2025

!build

Copy link

📦 Build Complete for 84c323a
https://2394aa5e.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented Apr 14, 2025

It looks like this currently "enters a mode" when the mouse gets nearby and that mode can be exited by right clicking/hitting escape. And it affects the hints bar by removing everything else from it. And it stays in the mode until the user moves their cursor far enough away to "break free" from it. Some of this is likely a holdover from the previous behavior (what's in master currently).

The desired new behavior is just showing that insertion line whenever you're within X distance of any segment (and the nearest segment if within X distance of multiple segments). And no change to the hints bar from the normal mode.

Thanks :)

@Keavon Keavon marked this pull request as draft April 14, 2025 06:27
@4adex
Copy link
Contributor Author

4adex commented Apr 16, 2025

Yes previous implementation used a new state when the clicked near the segment and then clicking again inserts the point, so I just changed that so that when pointer is moved closer to a segment compared to a threshold then it goes into that mode. I think that going into a separate state for inserting point prevents its collision with other features of the path tool. So should I change that it doesn't goes into a new mode?

@Keavon
Copy link
Member

Keavon commented Apr 16, 2025

So should I change that it doesn't goes into a new mode?

I think this will be the cleanest and most robust approach, yes.

@4adex 4adex marked this pull request as ready for review April 18, 2025 14:12
@4adex
Copy link
Contributor Author

4adex commented Apr 18, 2025

Done with the asked changes, removed the extra state which was being used for inserting point.

Copy link
Member

@0HyperCube 0HyperCube left a comment

Choose a reason for hiding this comment

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

Please write some tests for this behaviour.

Thanks for your work so far on this.

tool_data.segment = None;
responses.add(OverlaysMessage::Draw)
}
// If already hovering on a segment, then recalculate it's closest point
Copy link
Member

Choose a reason for hiding this comment

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

Why did you choose to calculate the state here and cache it instead of computing it when it is actually needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because that data is used for both drawing the overlays and actually for adding point when clicking, hence it makes better sense to calculate and cache it on PointerMove and use it when required.

Copy link
Member

Choose a reason for hiding this comment

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

Having this additional state creates unnecessary complexity; it makes systems harder to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calculating it over, will increase complexity of the operation so better cache it and use the method update_closest_point to update the position of the closest point on the current segment.
That's why I implemented it this way. Should I change?

Copy link
Member

Choose a reason for hiding this comment

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

As long as you write the appropriate test, I think this is fine then. However I struggle to see how making a function and calling it in two places creates complexity. Thanks.

@0HyperCube 0HyperCube marked this pull request as draft April 18, 2025 16:51
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.

3 participants