fix(engine): the marquee takes the objects it touches (#522)

The Selection tool's marquee selected a symbol instance, group, drawing
object, text or bitmap only when it lay wholly inside; one it covered
partly was left out. It now takes every object it touches, whole, as
the reference app does. Raw shapes are still cut at its edges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ayberk A.andClaude Opus 5.5 committed 2026-11-23 12:50:18 +03:00
1 parent 2df7775907
commit ea6755ea2a
5 files changed
+33 -10

No files matched your search

+10 -7
View File
@@ -46,7 +46,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Select Parts",
"",
None,
"{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects wholly inside it",
"{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches",
true,
select_rect,
),
@@ -631,7 +631,7 @@ fn on_editable_key(s: &Session) -> bool {
}
/// The marquee (ADR 0041, 0044): on every visible, unlocked layer, the parts of raw shapes under
/// the rectangle (cut at its edges) and the objects wholly inside it.
/// the rectangle (cut at its edges) and the objects it touches (#522).
fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
let a = Vec2::new(f32_req(p, "x0")?, f32_req(p, "y0")?);
let b = Vec2::new(f32_req(p, "x1")?, f32_req(p, "y1")?);
@@ -643,8 +643,8 @@ fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
if r.width() <= 0.0 || r.height() <= 0.0 {
return Ok(json!({"selected": s.selection.id_list(), "cut": 0}));
}
// What each layer has under the marquee, from one display list: wholly inside, or (raw
// shapes) partly.
// What each layer has under the marquee, from one display list: taken whole, or (raw
// shapes partly under it) cut.
let mut found: Vec<(LayerId, Vec<ElementId>, Vec<ElementId>)> = Vec::new();
let layers: Vec<LayerId> = s.timeline().layers.iter().map(|l| l.id).filter(|l| s.gathers(*l)).collect();
for l in layers {
@@ -654,9 +654,11 @@ fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
if bounds.is_empty() || bounds.intersect(&r).is_empty() {
continue;
}
if contains(&r, &bounds) {
// An object (instance, group, drawing object, text, bitmap) the marquee touches is
// taken whole (#522); a raw shape partly under it is cut at its edges.
if contains(&r, &bounds) || mergeable(&e).is_none() {
picked.push(e.id);
} else if mergeable(&e).is_some() {
} else {
partial.push(e.id);
}
}
@@ -688,7 +690,8 @@ fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
}
/// The marquee on the active layer: raw shapes partly under `r` are cut at its edges and the
/// parts inside are selected, the rest stay as they are; `picked` (wholly inside) are selected.
/// parts inside are selected, the rest stay as they are; `picked` (objects it touches, raw shapes
/// wholly inside) are selected.
/// How many pieces it cut, each piece with the shape it came from, and the pieces inside.
fn marquee_layer(s: &mut Session, r: &Rect, mut picked: Vec<ElementId>, partial: &[ElementId]) -> Result<(usize, CutOrigin, Vec<ElementId>)> {
let here = s.layer;
+19
View File
@@ -658,3 +658,22 @@ fn break_apart_twice_on_text_ends_in_raw_shapes() {
let err = s.execute("modify.break_apart", &json!({})).unwrap_err().to_string();
assert!(err.contains("raw shapes already"), "{err}");
}
/// #522: a marquee that touches part of a symbol instance or a group selects it whole, as it
/// does a drawing object; one it misses stays unselected.
#[test]
fn a_marquee_takes_the_instances_and_groups_it_touches() {
let mut s = Session::default();
run(&mut s, "draw.ellipse", json!({"x": 0, "y": 0, "w": 100, "h": 100, "stroke": null, "object": true}));
run(&mut s, "modify.convert_to_symbol", json!({"name": "Dot"}));
run(&mut s, "edit.deselect", json!({}));
run(&mut s, "draw.rect", json!({"x": 200, "y": 0, "w": 100, "h": 100, "stroke": null, "object": true}));
run(&mut s, "modify.group", json!({}));
run(&mut s, "edit.deselect", json!({}));
run(&mut s, "draw.rect", json!({"x": 400, "y": 0, "w": 100, "h": 100, "stroke": null, "object": true}));
run(&mut s, "edit.deselect", json!({}));
// Across the lower halves of the first two only.
run(&mut s, "raw.select_rect", json!({"x0": -10, "y0": 50, "x1": 350, "y1": 150}));
let kinds: Vec<&'static str> = s.selected_elements().iter().map(|(_, e)| match e.kind { ElementKind::Symbol { .. } => "symbol", ElementKind::Group { .. } => "group", _ => "other" }).collect();
assert!(kinds.contains(&"symbol") && kinds.contains(&"group") && kinds.len() == 2, "{kinds:?}");
}
+2 -1
View File
@@ -92,7 +92,8 @@ With the **Selection** tool (**V**) on merged drawing:
* **Double-click** a line to select every line joined to it, or a fill to select the fill and
its outline.
* **Drag a marquee** to select the parts of fills and lines under it, cut at the marquee's
edges, plus any objects wholly inside it. **Shift** adds more. If you click away without
edges, plus any objects it touches (symbol instances, groups, drawing objects, text and
bitmaps are taken whole). **Shift** adds more. If you click away without
changing anything, the drawing is whole again.
* **Drag an unselected line** or the edge of a fill to **bend** it into a curve through the
pointer. Its ends stay put, and a straight edge bends into one even arc wherever you grab it.
+1 -1
View File
@@ -622,7 +622,7 @@ These commands have no menu item: the panels, the stage and the timeline use the
- **Move Point** `raw.move_point` · changes the document
Parameters: ``{x, y, to_x, to_y, with?: [[x, y], ..], points?: [[id, cmd], ..], snap?, slop?, merge?: bool} moves the corner or end at (x, y), with every raw shape that shares it, to (to_x, to_y), snapped within `snap` to points, lines and fill edges (while Snap to Objects is on); the anchors at `with` move by as much; returns the points to pass on while a drag goes on``
- **Select Parts** `raw.select_rect` · changes the document
Parameters: `{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects wholly inside it`
Parameters: `{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches`
- **Merge Shapes** `raw.merge` · changes the document
Parameters: `{ids?: [..]} the raw shapes (default: the selection) merge again with the raw shapes they touch, in place`
- **Selection Tool Target** `raw.hit`
+1 -1
View File
@@ -772,7 +772,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) {
Drag::MultiMarquee { start, cur } => crate::onion::marquee(app, start, cur, shift),
Drag::Marquee { start, cur } => {
// The parts of raw fills and strokes under it, cut at its edges, and the objects
// wholly inside it (ADR 0041).
// it touches (ADR 0041, #522).
app.run("raw.select_rect", json!({"x0": start.x, "y0": start.y, "x1": cur.x, "y1": cur.y, "add": shift}));
}
Drag::Shape { start, cur } => create_shape(app, start, cur),