Merge main into feat/save-pdf-custom-flattener

This commit is contained in:
dotCooCoo
2026-11-18 15:08:17 -08:00
12 changed files with 461 additions and 17 deletions
+15 -1
View File
@@ -123,11 +123,13 @@ impl<'a> Reader<'a> {
}
// A group holding only clipping paths (`q … u <path> W n U … Q`) doesn't clip on its own: `u`/`U` don't save
// the graphics state as `q`/`Q` do, so its paths clip the clipping group around it, as the file's PDF part draws it.
// In a compound path (`*u u <path> W n … U *U`, possibly nested in other groups) they are the compound
// path's subpaths, as its other grouped paths are: the compound clipping path, their union.
if matches!(kind, Kind::Group)
&& unread.is_empty()
&& !clips.is_empty()
&& clips.len() == kids.len()
&& matches!(self.frames.last(), Some(Frame { kind: Kind::Clip, .. }))
&& (matches!(self.frames.last(), Some(Frame { kind: Kind::Clip, .. })) || self.in_compound())
{
for kid in kids {
if let Some(parent) = self.frames.last_mut() {
@@ -212,6 +214,18 @@ impl<'a> Reader<'a> {
Ok(())
}
/// Is the innermost open frame a compound path (`*u`), or a group in one with only groups between them?
fn in_compound(&self) -> bool {
for f in self.frames.iter().rev() {
match f.kind {
Kind::Group => {}
Kind::Compound => return true,
_ => return false,
}
}
false
}
/// The compound path of `kids`, painted and made transparent as its subpaths say.
fn compound(&mut self, mut kids: Vec<Node>, gs: &GState) -> Option<Node> {
// The compound path's paint is its last path's (a gradient's instance wraps only
+36
View File
@@ -1734,6 +1734,42 @@ fn a_clipping_path_alone_in_a_group_clips_its_clipping_group() {
assert_eq!(fill(&children[1]).color(), Some(Color::rgb(1.0, 0.0, 0.0)));
}
/// Clipping paths grouped in a compound path (`*u u <path> W n … U *U`, possibly nested in other groups) are
/// the compound path's subpaths, as its other grouped paths are: the compound clipping path, their union, clips its
/// clipping group, however many there are and wherever in the group it is written.
#[test]
fn clipping_paths_grouped_in_a_compound_path_are_its_subpaths() {
let square = rect_path(0.0, 0.0, 80.0, 80.0);
let (a, b, c) = (rect_path(0.0, 0.0, 10.0, 10.0), rect_path(30.0, 0.0, 40.0, 10.0), rect_path(60.0, 0.0, 70.0, 10.0));
let clip = |p: &str| format!("{p}h\nW\nn\n");
let bodies = [
// One group of them, after the art.
format!("0 Ae\nq\n{RED}{square}f\n*u\n0 Ae\nu\n{}{}{}U\n*U\nQ\n", clip(&a), clip(&b), clip(&c)),
// Groups in a group, and one path straight in the compound path, before the art.
format!("0 Ae\nq\n*u\n0 Ae\nu\n0 Ae\nu\n{}{}U\n0 Ae\nu\n{}U\nU\n*U\n{RED}{square}f\nQ\n", clip(&a), clip(&b), clip(&c)),
format!("0 Ae\nq\n*u\n0 Ae\nu\n{}{}U\n{}*U\n{RED}{square}f\nQ\n", clip(&a), clip(&b), clip(&c)),
];
for body in &bodies {
let doc = read_ok(&layer(body)).doc;
let NodeKind::Group { children, clip: true } = &art(&doc)[0].kind else { panic!("{body}: {:?}", art(&doc)[0].kind) };
assert_eq!(children.len(), 2, "{body}: {children:?}");
let NodeKind::Compound { children: subpaths, .. } = &children[0].kind else { panic!("{body}: {:?}", children[0].kind) };
assert_eq!(subpaths.len(), 3, "{body}: {subpaths:?}");
assert!(subpaths.iter().all(|p| matches!(p.kind, NodeKind::Path { clipping: true, .. })), "{body}: {subpaths:?}");
assert_eq!(fill(&children[1]).color(), Some(Color::rgb(1.0, 0.0, 0.0)), "{body}");
}
// Hundreds of them, one union: not clipping groups nested past the document's depth limit.
let many = format!("0 Ae\nq\n{RED}{square}f\n*u\n0 Ae\nu\n{}U\n*U\nQ\n", clip(&a).repeat(300));
let doc = read_ok(&layer(&many)).doc;
let NodeKind::Group { children, clip: true } = &art(&doc)[0].kind else { panic!("{:?}", art(&doc)[0].kind) };
let NodeKind::Compound { children: subpaths, .. } = &children[0].kind else { panic!("{:?}", children[0].kind) };
assert_eq!(subpaths.len(), 300);
// A group of clipping paths outside a compound path or a clipping group is read as before: a clipping group.
let alone = format!("0 Ae\nu\n{}{}U\n{RED}{square}f\n", clip(&a), clip(&b));
let doc = read_ok(&layer(&alone)).doc;
assert!(matches!(art(&doc)[0].kind, NodeKind::Group { clip: true, .. }), "{:?}", art(&doc)[0].kind);
}
/// #1410: a compound path shows its last path's paint, and paths grouped in it stay its paths.
#[test]
fn compound_path_takes_its_last_paths_paint() {
+22 -2
View File
@@ -1355,15 +1355,35 @@ fn palette_window_state(modal: bool, popup: bool, active: bool) -> (egui::Window
(level, true)
}
/// How long none of the app's windows has focus before the app counts as inactive. Focus moving
/// between the app's own windows passes through a frame where none has it (a press on a palette's
/// bar takes it from the main window): lowering the palettes then let the window system give the
/// keyboard to another palette in the middle of the press. craft-ui's docking waits as long.
#[cfg(not(target_arch = "wasm32"))]
const AWAY_DELAY: f64 = 0.25;
/// Sends the palette windows of `layout` the level and visibility [`palette_window_state`] gives
/// when they change. craft-ui varies a palette's level through the viewport builder, which egui
/// applies when the window opens and not to one already on screen, so the commands go explicitly to
/// the windows there are. A window that opens while the others are hidden (a panel floated under a
/// dialog, a menu, a flyout or the drawer) opens shown at its palette level, so it gets the commands
/// in its first frame.
/// in its first frame. The app is active until none of its windows has had focus for
/// [`AWAY_DELAY`], counted from the first frame that saw none.
#[cfg(not(target_arch = "wasm32"))]
fn palette_window_levels(ctx: &egui::Context, layout: &Layout<String>, modal: bool, popup: bool) {
let active = ctx.input(|i| i.focused || i.raw.viewports.values().any(|v| v.focused == Some(true)));
let (focused, now) = ctx.input(|i| (i.focused || i.raw.viewports.values().any(|v| v.focused == Some(true)), i.time));
let away_key = area_id().with("palette-levels-away");
let active = if focused {
ctx.data_mut(|d| d.remove::<f64>(away_key));
true
} else {
let since = ctx.data_mut(|d| *d.get_temp_mut_or_insert_with(away_key, || now));
let left = AWAY_DELAY - (now - since);
if left > 0.0 {
ctx.request_repaint_after(std::time::Duration::from_secs_f64(left));
}
left > 0.0
};
let key = area_id().with("palette-levels-state");
let state = (modal, popup, active);
let windows: Vec<u64> = layout.floating.iter().map(|window| window.id).collect();
@@ -735,6 +735,40 @@ fn a_palette_window_keeps_out_of_the_way_of_the_main_windows_dialog_and_menus()
assert_ne!(inactive.0, WindowLevel::AlwaysOnTop, "and not above other applications' windows: {:?}", inactive.0);
}
/// Focus moving between the app's own windows passes through a frame where none has it: the
/// palettes keep their level then, or the window system hands the keyboard to another palette in
/// the middle of a press on a palette's bar. They leave the top level once the app has had no
/// focus for a while.
#[test]
fn focus_moving_between_the_apps_windows_leaves_the_palettes_on_top() {
let mut h = Harness::new();
let viewport = h.float("navigator");
h.host.borrow_mut().focus = ViewportId::ROOT;
h.frames(2);
take_palette_commands(&h, viewport);
let nowhere = ViewportId::from_hash_of("no window of the app");
h.host.borrow_mut().focus = nowhere;
h.frames(1);
h.host.borrow_mut().focus = viewport;
h.frames(2);
assert_eq!(take_palette_commands(&h, viewport), (vec![], vec![]), "a frame without focus leaves the palette's level");
// The wait starts again each time focus leaves: a second frame without focus, longer after
// the first than the wait, leaves the level too.
h.frames(6);
h.host.borrow_mut().focus = nowhere;
h.frames(1);
h.host.borrow_mut().focus = ViewportId::ROOT;
h.frames(2);
assert_eq!(take_palette_commands(&h, viewport), (vec![], vec![]), "the wait is counted from when focus last left");
h.host.borrow_mut().focus = nowhere;
h.frames(8);
let (_, levels) = take_palette_commands(&h, viewport);
assert_eq!(levels.last(), Some(&palette_window_state(false, false, false).0), "the app left: the palette leaves the top level");
h.host.borrow_mut().focus = ViewportId::ROOT;
h.frames(2);
assert_eq!(take_palette_commands(&h, viewport).1, [egui::WindowLevel::AlwaysOnTop], "and takes it again when the app is back");
}
/// With a menu of the in-window menu bar open, the palettes take the normal level (still shown):
/// the menu is drawn in the main window, or it would open under them.
#[test]
+111
View File
@@ -177,6 +177,19 @@ fn guide_row(ui: &mut Ui, view: &View, item: &Row, i: usize, out: &mut Out) {
}
out.actions.push(("guide.select".into(), json!({"indexes": [i], "toggle": m.shift || m.command})));
}
if resp.secondary_clicked() {
crate::panels::set_row_keys(ui.ctx(), ROW_KEYS, true);
if editable && !selected {
if !view.rows.is_empty() {
out.actions.push(("layer.highlight".into(), json!({"ids": [], "mode": "set"})));
out.rows_after_click = Some(vec![]);
}
out.actions.push(("guide.select".into(), json!({"indexes": [i]})));
}
}
resp.context_menu(|ui| {
guide_context_menu(ui, view, item, i, out);
});
// Dragged: the selected guides when this is one of them, else this one, to another layer's row.
// Only the primary button drags a guide row, and not while a drag down a column passes it.
if editable && resp.drag_started_by(egui::PointerButton::Primary) && view.column.is_none() {
@@ -194,6 +207,46 @@ fn guide_row(ui: &mut Ui, view: &View, item: &Row, i: usize, out: &mut Out) {
}
}
/// The right-click context menu of ruler guide row `i` (`item`).
fn guide_context_menu(ui: &mut Ui, view: &View, item: &Row, i: usize, out: &mut Out) {
let Some(g) = view.ruler_guides.get(i) else { return };
let selected = view.guides.contains(&i);
let editable = view.doc.guide_editable(g);
let guides: Vec<usize> = if selected { view.guides.clone() } else { vec![i] };
let node = g.id.and_then(|id| view.doc.node(id));
let guide_nodes: Vec<u64> = if selected {
guides.iter().filter_map(|&idx| view.ruler_guides.get(idx)?.id.map(|id| id.0)).collect()
} else {
node.map(|n| vec![n.id.0]).unwrap_or_default()
};
let visible = node.is_none_or(|n| n.visible);
if widgets::menu_item(ui, if visible { "Hide" } else { "Show" }, !guide_nodes.is_empty(), false) {
out.actions.push(("layer.setProps".into(), json!({ "ids": guide_nodes, "visible": !visible })));
ui.close();
}
let locked = node.is_some_and(|n| n.locked);
if widgets::menu_item(ui, if locked { "Unlock" } else { "Lock" }, !guide_nodes.is_empty(), false) {
out.actions.push(("layer.setProps".into(), json!({ "ids": guide_nodes, "locked": !locked })));
ui.close();
}
ui.separator();
if widgets::menu_item(ui, "Release Guides", editable, false) {
let params = if guides.len() > 1 { json!({}) } else { json!({ "index": i }) };
out.actions.push(("view.guides.release".into(), params));
ui.close();
}
if widgets::menu_item(ui, "Delete", editable, false) {
out.actions.push(("guide.remove".into(), json!({ "indexes": guides })));
ui.close();
}
ui.separator();
let layers_only = view.opts.layers_only;
if widgets::menu_item(ui, if layers_only { "Locate Layer" } else { "Locate Object" }, true, false) {
out.actions.push(("layer.locate".into(), json!({ "id": item.node.id.0, "layersOnly": layers_only })));
ui.close();
}
}
/// The row of the spine of blend `item` (#4820): a path mark and `<Path>`, the selection square
/// while the blend is selected. A click selects the blend, whose spine Direct Selection then edits
/// on the canvas; Shift or Cmd adds it to (or takes it from) the selection. The spine of a hidden
@@ -233,6 +286,64 @@ fn spine_row(ui: &mut Ui, view: &View, item: &Row, out: &mut Out) {
let action = if m.shift || m.command { "select.toggle" } else { "select.set" };
out.actions.push((action.into(), json!({"ids": [blend.0]})));
}
if resp.secondary_clicked() {
crate::panels::set_row_keys(ui.ctx(), ROW_KEYS, true);
if editable && !selected {
out.actions.push(("select.set".into(), json!({"ids": [blend.0]})));
}
}
resp.context_menu(|ui| {
spine_context_menu(ui, view, item, out);
});
}
/// The right-click context menu of blend spine row `item`.
fn spine_context_menu(ui: &mut Ui, view: &View, item: &Row, out: &mut Out) {
let blend = item.node.id;
let selected = view.sel.contains(&blend);
let editable = (view.doc.editable())(blend);
let has_spine = !matches!(&item.node.kind, NodeKind::Blend { spec, .. } if spec.no_spine);
let ensure_selected = |out: &mut Out| {
if !selected {
out.actions.push(("select.set".into(), json!({ "ids": [blend.0] })));
}
};
if widgets::menu_item(ui, "Select", editable, false) {
out.actions.push(("select.set".into(), json!({ "ids": [blend.0] })));
ui.close();
}
if widgets::menu_item(ui, "Blend Options…", editable, false) {
ensure_selected(out);
out.actions.push(("ui.blendOptions".into(), json!({})));
ui.close();
}
ui.separator();
if widgets::menu_item(ui, "Reverse Spine", editable && has_spine, false) {
ensure_selected(out);
out.actions.push(("object.blend.reverseSpine".into(), json!({})));
ui.close();
}
if widgets::menu_item(ui, "Reverse Front to Back", editable, false) {
ensure_selected(out);
out.actions.push(("object.blend.reverseFrontToBack".into(), json!({})));
ui.close();
}
if widgets::menu_item(ui, "Expand", editable, false) {
ensure_selected(out);
out.actions.push(("object.blend.expand".into(), json!({})));
ui.close();
}
if widgets::menu_item(ui, "Release", editable, false) {
ensure_selected(out);
out.actions.push(("object.blend.release".into(), json!({})));
ui.close();
}
ui.separator();
let layers_only = view.opts.layers_only;
if widgets::menu_item(ui, if layers_only { "Locate Layer" } else { "Locate Object" }, true, false) {
out.actions.push(("layer.locate".into(), json!({ "id": blend.0, "layersOnly": layers_only })));
ui.close();
}
}
/// Guide rows `guides` dragged over row `r` (`resp`) of layer `layer`: the row lights up, and the
+203
View File
@@ -3006,3 +3006,206 @@ fn context_menu_others_actions_sublayer_state_enables_all_commands() {
assert_eq!(lock_cmd, "layer.unlockAll");
assert!(lock_enabled, "locked sublayer enables Unlock All Layers");
}
/// One headless frame of the panel in a 300 × 600 window, returning every drawn text and its rect.
fn frame_texts(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<(String, egui::Rect)> {
let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::pos2(0.0, 0.0), vec2(300.0, 600.0))), events, ..Default::default() };
let mut out = ctx.run_ui(raw, |ui| show(app, ui));
out.textures_delta.clear();
let mut texts = vec![];
for s in out.shapes {
if let egui::epaint::Shape::Text(t) = s.shape {
texts.push((t.galley.text().to_string(), t.galley.rect.translate(t.pos.to_vec2())));
}
}
texts
}
/// Click `button` at `pos` (pressed in one frame, released in the next) and return the texts drawn
/// on the frame after release.
fn click_menu_at(app: &mut VectorcraftApp, ctx: &egui::Context, pos: egui::Pos2, button: egui::PointerButton) -> Vec<(String, egui::Rect)> {
let ev = |pressed| egui::Event::PointerButton { pos, button, pressed, modifiers: Default::default() };
frame_texts(app, ctx, vec![egui::Event::PointerMoved(pos), ev(true)]);
frame_texts(app, ctx, vec![ev(false)]);
frame_texts(app, ctx, vec![])
}
/// The menu item labels in `texts` (which start with `" "`), ordered from top to bottom.
fn menu_entries(texts: &[(String, egui::Rect)]) -> Vec<String> {
let mut entries: Vec<_> = texts.iter().filter(|(t, _)| t.starts_with(" ")).map(|(t, r)| (t.trim().to_string(), r.top())).collect();
entries.sort_by(|a, b| a.1.total_cmp(&b.1));
entries.into_iter().map(|(t, _)| t).collect()
}
fn text_rect(texts: &[(String, egui::Rect)], name: &str) -> egui::Rect {
texts.iter().find(|(t, _)| t == name).map(|(_, r)| *r).unwrap_or_else(|| panic!("{name} not in {texts:?}"))
}
/// Right-clicking a ruler guide row selects the guide (or keeps a multi-guide selection), opens its
/// context menu (Hide/Show, Lock/Unlock, Release Guides, Delete, Locate Object), and each item
/// dispatches its command with Undo/Redo registration (#8592).
#[test]
fn guide_row_context_menu_selects_and_runs_guide_actions() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap();
run(&mut app, "file.new", json!({"width": 200, "height": 200}));
run(&mut app, "shape.rectangle", json!({"x": 0, "y": 0, "width": 20, "height": 20}));
run(&mut app, "guide.add", json!({"vertical": true, "pos": 50}));
run(&mut app, "guide.add", json!({"vertical": false, "pos": 80}));
run(&mut app, "select.none", json!({}));
let layer = app.session.active().unwrap().doc.layers[0].id;
run(&mut app, "layer.highlight", json!({"ids": [layer.0], "mode": "set"}));
expand(&mut app, &json!({})).unwrap();
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let texts = frame_texts(&mut app, &ctx, vec![]);
let h_guide_pos = text_rect(&texts, "<Horizontal Guide>").center();
let v_guide_pos = text_rect(&texts, "<Vertical Guide>").center();
let selected_guides = |app: &VectorcraftApp| {
let st = app.session.active().unwrap();
vectorcraft_engine::cmd::guide_indexes(&st.doc, &st.selection.guides)
};
// Right-clicking an unselected guide row selects it, clears highlighted rows, and opens the menu.
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
assert_eq!(selected_guides(&app), [0], "right-click selects the guide");
assert!(rows_of(&app).is_empty(), "highlighted rows cleared when selecting a guide");
assert_eq!(menu_entries(&menu), ["Hide", "Lock", "Release Guides", "Delete", "Locate Object"]);
// Hide toggles the guide's visibility off in one undo step; right-clicking again shows "Show".
let guide_node = app.session.active().unwrap().doc.ruler_guides()[0].id.unwrap();
let undo_before = app.session.active().unwrap().history.undo.len();
click_menu_at(&mut app, &ctx, text_rect(&menu, " Hide").center(), egui::PointerButton::Primary);
assert!(!app.session.active().unwrap().doc.node(guide_node).unwrap().visible);
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
assert_eq!(menu_entries(&menu), ["Show", "Lock", "Release Guides", "Delete", "Locate Object"]);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Show").center(), egui::PointerButton::Primary);
assert!(app.session.active().unwrap().doc.node(guide_node).unwrap().visible);
// Lock toggles the guide's lock on in one undo step; right-clicking again shows "Unlock".
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Lock").center(), egui::PointerButton::Primary);
assert!(app.session.active().unwrap().doc.node(guide_node).unwrap().locked);
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
assert_eq!(menu_entries(&menu), ["Hide", "Unlock", "Release Guides", "Delete", "Locate Object"]);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Unlock").center(), egui::PointerButton::Primary);
assert!(!app.session.active().unwrap().doc.node(guide_node).unwrap().locked);
// Locate Object locates the guide's holding layer.
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Locate Object").center(), egui::PointerButton::Primary);
assert_eq!(rows_of(&app), vec![layer]);
// Multi-guide selection is preserved when right-clicking an already-selected guide row.
run(&mut app, "guide.select", json!({"indexes": [0, 1]}));
let _menu = click_menu_at(&mut app, &ctx, h_guide_pos, egui::PointerButton::Secondary);
assert_eq!(selected_guides(&app), [0, 1], "right-click on selected guide preserves multi-guide selection");
// Release Guides on a single guide converts it into a path in one undo step; Undo brings it back.
run(&mut app, "guide.select", json!({"indexes": [0]}));
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
let undo_before = app.session.active().unwrap().history.undo.len();
click_menu_at(&mut app, &ctx, text_rect(&menu, " Release Guides").center(), egui::PointerButton::Primary);
assert_eq!(app.session.active().unwrap().doc.ruler_guides().len(), 1, "one guide released to a path");
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
run(&mut app, "edit.undo", json!({}));
assert_eq!(app.session.active().unwrap().doc.ruler_guides().len(), 2, "Undo restores the released guide");
// Delete removes the guide in one undo step; Undo restores it.
let texts = frame_texts(&mut app, &ctx, vec![]);
let v_guide_pos = text_rect(&texts, "<Vertical Guide>").center();
let menu = click_menu_at(&mut app, &ctx, v_guide_pos, egui::PointerButton::Secondary);
let undo_before = app.session.active().unwrap().history.undo.len();
click_menu_at(&mut app, &ctx, text_rect(&menu, " Delete").center(), egui::PointerButton::Primary);
assert_eq!(app.session.active().unwrap().doc.ruler_guides().len(), 1, "Delete removes the guide");
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
run(&mut app, "edit.undo", json!({}));
assert_eq!(app.session.active().unwrap().doc.ruler_guides().len(), 2, "Undo restores the deleted guide");
}
/// Right-clicking a blend spine row selects the blend, opens its context menu (Select, Blend
/// Options…, Reverse Spine, Reverse Front to Back, Expand, Release, Locate Object), and each item
/// dispatches its command with Undo/Redo registration (#8592).
#[test]
fn spine_row_context_menu_selects_blend_and_runs_blend_actions() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap();
run(&mut app, "file.new", json!({"width": 300, "height": 200}));
let a = NodeId(run(&mut app, "shape.rectangle", json!({"x": 0, "y": 0, "width": 20, "height": 20}))["id"].as_u64().unwrap());
let b = NodeId(run(&mut app, "shape.rectangle", json!({"x": 200, "y": 0, "width": 20, "height": 20}))["id"].as_u64().unwrap());
run(&mut app, "select.set", json!({"ids": [a.0, b.0]}));
let blend = NodeId(run(&mut app, "object.blend.make", json!({}))["id"].as_u64().unwrap());
run(&mut app, "select.none", json!({}));
expand(&mut app, &json!({})).unwrap();
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let spine_rect = |texts: &[(String, egui::Rect)]| {
texts
.iter()
.filter(|(t, _)| t == "<Path>")
.max_by(|x, y| x.1.top().total_cmp(&y.1.top()))
.map(|(_, r)| *r)
.unwrap_or_else(|| panic!("spine <Path> not in {texts:?}"))
};
let texts = frame_texts(&mut app, &ctx, vec![]);
let spine_pos = spine_rect(&texts).center();
let selected = |app: &VectorcraftApp| app.session.active().unwrap().selection.objects.to_vec();
// Right-clicking the unselected spine row selects the blend and opens the context menu.
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
assert_eq!(selected(&app), [blend], "right-clicking the spine row selects the blend");
assert_eq!(menu_entries(&menu), ["Select", "Blend Options…", "Reverse Spine", "Reverse Front to Back", "Expand", "Release", "Locate Object"]);
// Blend Options… opens the Blend Options dialog.
click_menu_at(&mut app, &ctx, text_rect(&menu, " Blend Options…").center(), egui::PointerButton::Primary);
assert_eq!(app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some("blendOptions"));
crate::dialogs::cancel(&mut app);
// Reverse Spine reverses the key positions along the spine in one undo step.
let key_x = |app: &VectorcraftApp, id: NodeId| app.session.active().unwrap().doc.node(id).unwrap().geometric_bounds().unwrap().x0;
let a_x_before = key_x(&app, a);
let b_x_before = key_x(&app, b);
let undo_before = app.session.active().unwrap().history.undo.len();
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Reverse Spine").center(), egui::PointerButton::Primary);
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
assert!((key_x(&app, a) - b_x_before).abs() < 1e-6 && (key_x(&app, b) - a_x_before).abs() < 1e-6);
// Reverse Front to Back reverses the key stacking order in one undo step.
let key_ids = |app: &VectorcraftApp| -> Vec<NodeId> {
app.session.active().unwrap().doc.node(blend).unwrap().children().unwrap().iter().map(|c| c.id).collect()
};
assert_eq!(key_ids(&app), [a, b]);
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Reverse Front to Back").center(), egui::PointerButton::Primary);
assert_eq!(key_ids(&app), [b, a]);
// Locate Object highlights the blend row.
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
click_menu_at(&mut app, &ctx, text_rect(&menu, " Locate Object").center(), egui::PointerButton::Primary);
assert_eq!(rows_of(&app), vec![blend]);
// Expand replaces the blend with a group in one undo step; Undo brings the blend back.
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
let undo_before = app.session.active().unwrap().history.undo.len();
click_menu_at(&mut app, &ctx, text_rect(&menu, " Expand").center(), egui::PointerButton::Primary);
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
assert!(matches!(app.session.active().unwrap().doc.node(blend).unwrap().kind, NodeKind::Group { .. }));
run(&mut app, "edit.undo", json!({}));
assert!(matches!(app.session.active().unwrap().doc.node(blend).unwrap().kind, NodeKind::Blend { .. }));
// Release releases the blend into its keys and spine path in one undo step; Undo restores it.
expand(&mut app, &json!({})).unwrap();
let texts = frame_texts(&mut app, &ctx, vec![]);
let spine_pos = spine_rect(&texts).center();
let menu = click_menu_at(&mut app, &ctx, spine_pos, egui::PointerButton::Secondary);
let undo_before = app.session.active().unwrap().history.undo.len();
click_menu_at(&mut app, &ctx, text_rect(&menu, " Release").center(), egui::PointerButton::Primary);
assert_eq!(app.session.active().unwrap().history.undo.len(), undo_before + 1);
assert!(app.session.active().unwrap().doc.node(blend).is_none(), "blend released into keys and spine path");
run(&mut app, "edit.undo", json!({}));
assert!(matches!(app.session.active().unwrap().doc.node(blend).unwrap().kind, NodeKind::Blend { .. }));
}
+16 -1
View File
@@ -3781,7 +3781,22 @@ mod tests {
let (csv_off, csv_on) = (String::from_utf8_lossy(csv_off), String::from_utf8_lossy(csv_on));
assert!(!csv_off.contains(&hold), "off, the CSV file lists no hold");
assert!(csv_on.contains(&swap[0].shortcut), "on, the CSV file lists it: {}", swap[0].shortcut);
assert_eq!(sheet_off, sheet_off_again, "the sheet is the same each time");
// The writer stamps each file with the clock: its dates and its ID (fixed width), which differ
// between two exports a second apart. The rest of the file is the same each time.
let unstamped = |pdf: &[u8]| {
let mut b: Vec<u8> = pdf.iter().map(|&c| if c.is_ascii_digit() { b'0' } else { c }).collect();
for key in [&b"InstanceID>"[..], b"DocumentID>", b"/ID["] {
let mut at = 0;
while let Some(i) = b[at..].windows(key.len()).position(|w| w == key) {
let start = at + i + key.len();
let end = b[start..].iter().position(|&c| c == b'<' || c == b']').map_or(b.len(), |e| start + e);
b[start..end].fill(b'?');
at = end;
}
}
b
};
assert_eq!(unstamped(sheet_off), unstamped(sheet_off_again), "the sheet is the same each time");
assert_ne!(sheet_off, sheet_on, "on, the sheet lists the hold");
}
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -40,6 +40,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
| Date | Change | Summary |
|---|---|---|
| 2026-11-18 | minor | G12: Layers panel ruler guide and blend spine row context menus (#8592): Hide/Show, Lock/Unlock, Release Guides, Delete and Locate Object on guide rows; Select, Blend Options…, Reverse Spine, Reverse Front to Back, Expand, Release and Locate Object on blend spine rows. Scores and estimates unchanged. |
| 2026-11-18 | minor | G19: PDF export writes the document language chosen in Document Setup as the catalog's `/Lang` (its BCP 47 tag, `en-US` by default) and the XMP packet's `dc:language`, in exported and printed PDFs (#3644); `/MarkInfo` stays with tagged PDF (#3643). Scores and estimates unchanged. |
| 2026-11-16 | minor | G1: Recolor Artwork - native Lab entry in Color Picker, swatch libraries access in Color Picker, and row right-click context menu ("Pick from Swatches", "Limit to Library") (#4028); scores and estimates unchanged. |
| 2026-11-15 | minor | G4 type: modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `ui.checkSpelling`, #4936) with Not in Dictionary sentence context, suggestions, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done/Cancel, keyboard navigation, and one-step Undo/Redo; spell check complete; scores and estimates unchanged. |
@@ -534,12 +535,13 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
run hyphenates in its own language (Character panel). English, eleven Indian languages, Bulgarian, Turkish
and Russian have break points, and German, Polish, Portuguese and Italian have them in builds that embed
their patterns; other languages stay whole apart from the Exceptions list (#394, #4947).
- **Done (2026-11-18, #8592):** Layers panel guide and blend spine row context menus: right-clicking a ruler guide row shows Hide / Show, Lock / Unlock, Release Guides, Delete and Locate Object / Locate Layer (selecting an unselected editable guide or preserving a multi-guide selection); right-clicking a blend spine row selects the blend and shows Select, Blend Options…, Reverse Spine, Reverse Front to Back, Expand, Release and Locate Object / Locate Layer. Tests in `crates/ui-egui/src/panels/layers/tests.rs`.
- **Done (2026-11-14):** Layers panel row context menu: right-clicking a layer, group, or object row shows a context menu (Options…, Duplicate, Delete, Lock Others / Unlock All, Hide Others / Show All, Locate Object, Collect for Export) with proper selection behavior and Undo/Redo tracking. Tests in `crates/ui-egui/src/panels/layers/tests.rs`.
- **Missing:** 2 Preferences options stored but not acted on (#394), each waiting on a subsystem of its own:
Plug-ins & Scratch Disks › Primary and Secondary (documents are kept in memory; nothing pages to
disk), and Clipboard Handling › Legacy vector clipboard with its Preserve Paths / Preserve Appearance and
Overprints choice (Illustrator's own clipboard flavour, which has no public specification). Also Properties
panel per context, context menus in the panels that have none, and menus on guide and blend spine rows in the Layers panel.
panel per context, and context menus in the panels that have none.
- **Impact:** settings that silently do nothing erode trust.
- **Estimate:** 13–20 h.
+3 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -3
View File
File diff suppressed because one or more lines are too long