Repository navigation
TRIM highlights only the piece a click removes, EXTEND the extended object - #1126
Open
marcoarnulfo wants to merge 2 commits into
Open
marcoarnulfo wants to merge 2 commits into
marcoarnulfo wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Fixes #1118.
Stacked on #1092 (Shift+click does the other one in TRIM/EXTEND): until that one is merged, this diff also shows its commit. The commit for this issue is the last one.
At "Select object to trim", the canvas used the generic rollover highlight, which always lights up the whole object under the cursor, so you couldn't see which piece a click would remove. The trim geometry in
modify.rsnow has a pure step,trimmed, that returns what a pick keeps and what it removes without touching the drawing.trimuses it to replace the object, and TRIM's newInteractive::highlightuses it to tell the canvas which part to highlight. With no cutting edge in Quick mode (the click erases the object), the whole object is highlighted, as before. EXTEND works the same way:extendgot a pureextendedstep, and the highlight shows the object as the click leaves it, extension included. With Shift held, the highlight follows the command the click will run (#1092). Lines, arcs, circles, polylines, ellipses and splines (open and closed) all go through the code the click itself uses.On the canvas side, when the command returns a part, the hover look is drawn on that part instead of on the whole object. Working the part out means running the trim against every cutting edge (every object in Quick mode), so it is cached with the rest of the hover state: it is computed again only when the object, the cursor, Shift, the zoom, the drawing or the prompt changes, never on frames where the cursor is at rest. I kept the change to the hover code since #1061 is reorganising
canvas.rs; happy to rebase onto it if it lands first.In Standard mode, picking an object that no edge crosses still highlights the whole object, as it did before: nothing would change there, so I left it alone. Happy to switch if you'd rather show nothing in that case.
Validation:
trim_extend_options::trim_highlights_only_the_piece_a_pick_removes: fails on main (the highlight isNone, i.e. the whole object, where the piece(10,0)-(15,0)is expected), passes herecanvas::trim_highlight_tests::shift_shows_what_the_click_does: with Shift held in TRIM the highlight is the line extended to the boundary, not the line the click without Shift would erasecanvas::trim_highlight_tests::highlight_is_computed_once_while_the_cursor_rests: five frames with the cursor at rest compute the part once (five times without the cache)cargo test -p cadcraft-engine --test trim_extend_options --test trim_closed_polyline --test modify_curves --test fillet_chamfer,cargo test -p cadcraft-engine --lib modify,cargo test -p cadcraft-ui-egui --lib trim_cargo clippy -p cadcraft-engine -p cadcraft-ui-egui --all-targets -- -D warnings,cargo fmt --all -- --check