Skip to content

TRIM highlights only the piece a click removes, EXTEND the extended object - #1126

Open
marcoarnulfo wants to merge 2 commits into
storytold:mainfrom
marcoarnulfo:fix/trim-hover-preview
Open

marcoarnulfo wants to merge 2 commits into
storytold:mainfrom
marcoarnulfo:fix/trim-hover-preview

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

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.rs now has a pure step, trimmed, that returns what a pick keeps and what it removes without touching the drawing. trim uses it to replace the object, and TRIM's new Interactive::highlight uses 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: extend got a pure extended step, 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 is None, i.e. the whole object, where the piece (10,0)-(15,0) is expected), passes here
  • canvas::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 erase
  • canvas::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
  • (macOS, Apple silicon)

@marcoarnulfo marcoarnulfo changed the title TRIM/EXTEND: shift-select does the other one, as the prompt says TRIM highlights only the piece a click removes, EXTEND the extended object Oct 14, 2026

This branch has not been deployed

No deployments
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.

feature request trim highlight

1 participant