Skip to content

Pick what objects draw; the ribbon's layer list moves the selection - #11

Merged
SkryxDev merged 1 commit into
mainfrom
fix/selection-hitboxes-layer
Nov 11, 2026
Merged

SkryxDev merged 1 commit into
mainfrom
fix/selection-hitboxes-layer

Conversation

@SkryxDev

Copy link
Copy Markdown
Member

What changes

Ribbon property lists act on the selection. Picking a layer in the ribbon's layer list with objects selected moves them to that layer, as AutoCAD does. Before, it only set the current layer, so the only way was to redraw the object. The colour, linetype and lineweight lists work the same way.

  • With nothing selected, they still set the current value.
  • With a selection, the list shows the value the objects share, or nothing when they differ.
  • Objects on a locked layer are left out, and the command line says how many.

Hitboxes follow what each object draws. A new audit (crates/engine/tests/it/pick_audit.rs) covers about 36 kinds of object. It picks each one on what it draws, and in the empty space around it. It runs once with the object alone and once among 400 others, so picking goes through the spatial index. The audit found and this PR fixes:

  • Wide, tapered and donut polylines were picked only on their centre line. They are now picked anywhere in their band, and a crossing box inside the band selects them.
  • Aligned, radius and diameter dimensions had parts that could not be picked at all. The spatial index finds candidates by their boxes, and those boxes left out:
    • the far end of an aligned dimension's line (DIMALIGNED keeps the point it was placed through, not one end), and
    • a radius or diameter dimension's words placed outside the circle.
  • The last letter of a word: the drawing's estimate of a text's width falls short of wide letters, so the index never offered the text there.

The index now stores how far each object can draw (select::reach), a cheap margin for words and dimensions. The exact test still runs on the few candidates it lets through. Window selection ("fully inside") still uses the drawing's bounds.

The cost is small. With 4,000 texts and dimensions, building the index goes from 11 ms to 22 ms. Computing the exact shapes at index time would have taken 290 ms, so the margin is used instead.

Checks

  • cargo xtask ci: fmt and clippy pass. In the full test run only the three known macOS-only failures remain (usage::non_unicode_output_names, read_file_refuses_a_name_that_is_not_unicode, thai_marks_stack_in_an_installed_font). i18n, assets, layers and wasm pass.
  • Tried in the app:
    • A click inside a wide polyline's band selects it.
    • With it selected, choosing "Center" in the ribbon's layer list moved it to Center, and CLAYER stayed "Outline".

🤖 Generated with Claude Code

The ribbon's layer, colour, linetype and lineweight lists act on the
selected objects when there are some (as AutoCAD does), and set the
current value only when nothing is selected. With a selection they show
the value the objects share, or nothing when they differ. Objects on a
locked layer are left out, and the command line says how many.

Picking now tests what each object draws:
- A polyline with width (constant or tapered, a donut) is picked
  anywhere in its band, and a crossing box inside the band crosses it.
- The spatial index finds objects by how far they can draw (`reach`):
  the drawing's box for words is an estimate a wide last letter
  outgrows, and a dimension's words outside a circle are past its
  defining points. Without this, those parts could not be picked.
- A linear or aligned dimension's bounds take in both ends of its line;
  DIMALIGNED keeps the point it was placed through, not one end.

A new test picks about 36 kinds of object on what they draw and in the
empty space around them, alone and through the spatial index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SkryxDev
SkryxDev merged commit 0adabfb into main Nov 11, 2026
1 check passed
@SkryxDev
SkryxDev deleted the fix/selection-hitboxes-layer branch November 11, 2026 17:48
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.

1 participant