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
@@ -29,7 +29,7 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::frame::view_frame;
|
||||
use super::layer::{LayerError, find_view, render_composed_layer};
|
||||
use super::layer::{LayerError, find_view, render_canvas_layer, render_composed_layer};
|
||||
pub use super::svg::refs::HALO_FILTER_ID;
|
||||
use super::svg::refs::holds_reserved_id;
|
||||
use super::svg::sanitize::check_root_visibility;
|
||||
@@ -113,7 +113,7 @@ pub fn compose_canvas(
|
||||
if !references_scoped(&root, &scope) {
|
||||
return Err(ComposeError::UnscopedReference);
|
||||
}
|
||||
let layer = render_composed_layer(document, view_id, &HashSet::new())?;
|
||||
let layer = render_canvas_layer(document, view_id, &HashSet::new())?;
|
||||
root.children.push(Node::Element(checked(layer)?));
|
||||
Ok(root)
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ pub fn render_layer(
|
||||
view_id: &str,
|
||||
states: &HashSet<&str>,
|
||||
) -> Result<Element, LayerError> {
|
||||
layer(document, view_id, states, false)
|
||||
layer(document, view_id, states, Form::Review)
|
||||
}
|
||||
|
||||
/// The layer the composers draw (V1-2.2 owner brief 2026-10-30): the R3 tree with each point
|
||||
/// The layer of the PDF view (V1-2.2 owner brief 2026-10-30): the R3 tree with each point
|
||||
/// hitbox declaring its paint and its capture rule, `stroke="none"` and
|
||||
/// `pointer-events="visibleFill"`, so its clickable area is its circle whatever stroke the page
|
||||
/// or a drawing would give it (under `pointer-events="all"` a stroke widens the hit area even
|
||||
@@ -47,18 +47,50 @@ pub fn render_composed_layer(
|
||||
view_id: &str,
|
||||
states: &HashSet<&str>,
|
||||
) -> Result<Element, LayerError> {
|
||||
layer(document, view_id, states, true)
|
||||
layer(document, view_id, states, Form::Highlight)
|
||||
}
|
||||
|
||||
/// The layer of the editor canvas: the PDF view's elements in three passes, each in document
|
||||
/// order, every point hitbox, then every filled shape (zones and triggers), then every visible
|
||||
/// twin, which captures on what it paints (`visiblePainted`). « The visible wins » (owner
|
||||
/// decision 2026-11-01): a vertebral junction's disc is no longer taken by the zone drawn
|
||||
/// after it, a zone keeps what no disc covers, a hitbox ring what neither covers.
|
||||
pub fn render_canvas_layer(
|
||||
document: &AnatomicalSheetDocument,
|
||||
view_id: &str,
|
||||
states: &HashSet<&str>,
|
||||
) -> Result<Element, LayerError> {
|
||||
layer(document, view_id, states, Form::Canvas)
|
||||
}
|
||||
|
||||
/// Which product draws the layer.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum Form {
|
||||
/// The R3 tree, for the seed review drawings.
|
||||
Review,
|
||||
/// Declared hitboxes, document order.
|
||||
Highlight,
|
||||
/// Declared hitboxes, three passes, capturing twins.
|
||||
Canvas,
|
||||
}
|
||||
|
||||
/// The pass an element is painted (and hit) in, on the canvas.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum Pass {
|
||||
Hitbox,
|
||||
Shape,
|
||||
Twin,
|
||||
}
|
||||
|
||||
fn layer(
|
||||
document: &AnatomicalSheetDocument,
|
||||
view_id: &str,
|
||||
states: &HashSet<&str>,
|
||||
declared_hitbox: bool,
|
||||
form: Form,
|
||||
) -> Result<Element, LayerError> {
|
||||
let view = find_view(document, view_id).ok_or(LayerError::UnknownView)?;
|
||||
let context = Context {
|
||||
declared_hitbox,
|
||||
form,
|
||||
twin_opacity: if view.is_main() { "0.65" } else { "0.5" },
|
||||
categories: document
|
||||
.categories
|
||||
@@ -68,13 +100,23 @@ fn layer(
|
||||
view_names: document.views.iter().map(|v| (v.id(), v.name())).collect(),
|
||||
states,
|
||||
};
|
||||
let children = document
|
||||
let elements = document
|
||||
.annotations
|
||||
.iter()
|
||||
.filter(|a| a.view_id() == view_id)
|
||||
.flat_map(|a| context.elements(a))
|
||||
.map(Node::Element)
|
||||
.collect();
|
||||
.flat_map(|a| context.elements(a));
|
||||
let children = if form == Form::Canvas {
|
||||
// Each pass keeps the document order.
|
||||
let mut passes: [Vec<Node>; 3] = Default::default();
|
||||
for (pass, element) in elements {
|
||||
passes[pass as usize].push(Node::Element(element));
|
||||
}
|
||||
passes.concat()
|
||||
} else {
|
||||
elements
|
||||
.map(|(_, element)| Node::Element(element))
|
||||
.collect()
|
||||
};
|
||||
let attrs = vec![
|
||||
("data-layer", "annotations".to_owned()),
|
||||
("data-view-id", view_id.to_owned()),
|
||||
@@ -83,8 +125,7 @@ fn layer(
|
||||
}
|
||||
|
||||
struct Context<'a> {
|
||||
/// The hitbox declares `stroke="none"` and captures on its circle only (composed form).
|
||||
declared_hitbox: bool,
|
||||
form: Form,
|
||||
twin_opacity: &'static str,
|
||||
/// Last duplicate wins, as a JavaScript `Map` built from the list.
|
||||
categories: HashMap<&'a str, Option<&'a str>>,
|
||||
@@ -95,7 +136,7 @@ struct Context<'a> {
|
||||
type Attrs = Vec<(&'static str, String)>;
|
||||
|
||||
impl Context<'_> {
|
||||
fn elements(&self, annotation: &Annotation) -> Vec<Element> {
|
||||
fn elements(&self, annotation: &Annotation) -> Vec<(Pass, Element)> {
|
||||
let (geometry, color) = match annotation {
|
||||
Annotation::Observable(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
||||
Annotation::DetailTrigger(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
||||
@@ -119,11 +160,15 @@ impl Context<'_> {
|
||||
value_of(&data, "data-anno-name-en")
|
||||
);
|
||||
if annotation.trigger().is_some() {
|
||||
return vec![shape(geometry, &color, trigger_visual(), &data, &label)];
|
||||
let trigger = shape(geometry, &color, trigger_visual(), &data, &label);
|
||||
return vec![(Pass::Shape, trigger)];
|
||||
}
|
||||
match geometry {
|
||||
Geometry::Circle(c) => self.point(c.cx, c.cy, c.r, &color, &data, &label),
|
||||
_ => vec![shape(geometry, &color, zone_visual(), &data, &label)],
|
||||
_ => vec![(
|
||||
Pass::Shape,
|
||||
shape(geometry, &color, zone_visual(), &data, &label),
|
||||
)],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,14 +219,14 @@ impl Context<'_> {
|
||||
color: &str,
|
||||
data: &Attrs,
|
||||
label: &str,
|
||||
) -> Vec<Element> {
|
||||
) -> Vec<(Pass, Element)> {
|
||||
let mut hitbox: Attrs = vec![
|
||||
("cx", js_number(cx)),
|
||||
("cy", js_number(cy)),
|
||||
("r", js_number(r)),
|
||||
("fill", "transparent".to_owned()),
|
||||
];
|
||||
if self.declared_hitbox {
|
||||
if self.form != Form::Review {
|
||||
hitbox.push(("stroke", "none".to_owned()));
|
||||
hitbox.push(("pointer-events", "visibleFill".to_owned()));
|
||||
} else {
|
||||
@@ -197,12 +242,16 @@ impl Context<'_> {
|
||||
("fill-opacity", self.twin_opacity.to_owned()),
|
||||
("stroke", "#000".to_owned()),
|
||||
("stroke-width", "1.5".to_owned()),
|
||||
("pointer-events", "none".to_owned()),
|
||||
];
|
||||
let twin_capture = match self.form {
|
||||
Form::Canvas => "visiblePainted",
|
||||
Form::Review | Form::Highlight => "none",
|
||||
};
|
||||
visible.push(("pointer-events", twin_capture.to_owned()));
|
||||
visible.extend(data.iter().cloned());
|
||||
vec![
|
||||
titled("circle", hitbox, label),
|
||||
titled("circle", visible, label),
|
||||
(Pass::Hitbox, titled("circle", hitbox, label)),
|
||||
(Pass::Twin, titled("circle", visible, label)),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user