-
-
Notifications
You must be signed in to change notification settings - Fork 577
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
base: master
Are you sure you want to change the base?
Conversation
!build |
|
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. |
aa7ff13
to
e11b57a
Compare
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. |
!build |
|
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 :) |
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? |
I think this will be the cleanest and most robust approach, yes. |
Done with the asked changes, removed the extra state which was being used for inserting point. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Part of #1870