fix(anatomy): V1-2.2 the visible wins on the editor canvas
Owner decision 2026-11-01. The canvas paints and hits every point hitbox, then every zone and trigger, then every visible twin, which captures on what it paints; a junction's disc is no longer taken by the zone drawn after it. The PDF view keeps the document order and its bytes. Click spec: the five fixme run unmarked, six projects incl. a 320 px phone.
This commit is contained in:
1 parent
e67715025c
commit
9c606aa567
13 files changed
+504
-64
No files matched your search
@@ -175,3 +175,30 @@ fn take_from(node: &mut Value) -> Option<Value> {
|
||||
}
|
||||
kids.iter_mut().find_map(take_from)
|
||||
}
|
||||
|
||||
/// Owner decision 2026-11-01 (V1-2.2, « the visible wins »), the editor canvas only: applied
|
||||
/// after `with_isolated_layer` to a frozen canvas tree, written apart from the core. The layer's
|
||||
/// markers are put in three passes, each keeping the frozen order: every point hitbox (a circle
|
||||
/// with `fill="transparent"`), then every other shape, then every visible twin (a circle with
|
||||
/// `pointer-events="none"`), which captures on `visiblePainted`.
|
||||
pub fn with_canvas_passes(tree: &mut Value) {
|
||||
let layer = tree["children"].as_array_mut().unwrap().last_mut().unwrap();
|
||||
let markers = std::mem::take(layer["children"].as_array_mut().unwrap());
|
||||
let pass = |m: &Value| match (&m["attrs"]["fill"], &m["attrs"]["pointer-events"]) {
|
||||
(f, _) if m["name"] == "circle" && f == "transparent" => 0,
|
||||
(_, p) if m["name"] == "circle" && p == "none" => 2,
|
||||
_ => 1,
|
||||
};
|
||||
let mut ranked: Vec<(u8, Value)> = markers.into_iter().map(|m| (pass(&m), m)).collect();
|
||||
ranked.sort_by_key(|(rank, _)| *rank);
|
||||
let out: Vec<Value> = ranked
|
||||
.into_iter()
|
||||
.map(|(rank, mut marker)| {
|
||||
if rank == 2 {
|
||||
marker["attrs"]["pointer-events"] = json!("visiblePainted");
|
||||
}
|
||||
marker
|
||||
})
|
||||
.collect();
|
||||
layer["children"] = Value::Array(out);
|
||||
}
|
||||
Reference in new issue
Block a user