mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
#7645: merge current main documentation without changing the qualified toggle
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
use craft_svg::tree::usvg;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{OnceCell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Write as _;
|
||||
use std::ops::{Range, RangeInclusive};
|
||||
@@ -774,6 +774,10 @@ struct Ctx {
|
||||
/// no usable one. The styles of a `<use>` instance share it, so each path is found and parsed
|
||||
/// once however many `<use>` elements show its text.
|
||||
paths: Rc<RefCell<HashMap<roxmltree::NodeId, Option<Rc<FollowedPath>>>>>,
|
||||
/// Each element id in the document and the first element in document order that carries it
|
||||
/// ([`Self::element`]). It is built when the first `<textPath>` names an element, and the
|
||||
/// styles of a `<use>` instance share it.
|
||||
ids: Rc<OnceCell<HashMap<Box<str>, roxmltree::NodeId>>>,
|
||||
}
|
||||
|
||||
/// The path a `<textPath>` follows ([`Ctx::text_path`]).
|
||||
@@ -788,6 +792,11 @@ struct FollowedPath {
|
||||
thread_local! {
|
||||
/// How many times [`Ctx::read_text_path`] has read a `<textPath>`'s path on this thread.
|
||||
static TEXT_PATH_READS: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
||||
/// How many times [`Ctx::element`] has walked a document's elements on this thread.
|
||||
static ID_WALKS: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
||||
/// When set, [`Ctx::element`] walks the document for each id instead of using the map, so
|
||||
/// tests can compare the two.
|
||||
static LINEAR_IDS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
|
||||
}
|
||||
|
||||
impl Ctx {
|
||||
@@ -802,6 +811,7 @@ impl Ctx {
|
||||
elems: RefCell::default(),
|
||||
strong: RefCell::default(),
|
||||
paths: Rc::default(),
|
||||
ids: Rc::default(),
|
||||
};
|
||||
let root = xml.root_element();
|
||||
let dim = |a: &str| root.attribute(a).and_then(|v| cx.length(v, DEFAULT_FONT_SIZE, 0.0)).filter(|v| *v > 0.0);
|
||||
@@ -824,6 +834,7 @@ impl Ctx {
|
||||
elems: RefCell::default(),
|
||||
strong: RefCell::default(),
|
||||
paths: self.paths.clone(),
|
||||
ids: self.ids.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1219,7 +1230,7 @@ impl Ctx {
|
||||
Some(d) => BezPath::from_svg(d).ok()?,
|
||||
None => {
|
||||
let id = href(tp)?.trim().strip_prefix('#')?;
|
||||
let el = xml.descendants().find(|n| n.is_element() && n.attribute("id") == Some(id))?;
|
||||
let el = self.element(xml, id)?;
|
||||
let d = match el.tag_name().name() {
|
||||
"path" => el.attribute("d")?.to_string(),
|
||||
_ => self.shape_path(el)?,
|
||||
@@ -1238,6 +1249,32 @@ impl Ctx {
|
||||
usable.then_some(FollowedPath { path: bp, author_length })
|
||||
}
|
||||
|
||||
/// The first element in document order whose `id` is `id`, as the DOM's `getElementById`
|
||||
/// finds it (https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid). The first
|
||||
/// call walks `xml` once to build [`Self::ids`]; later calls look the id up there. `xml` is
|
||||
/// the document [`Self::new`] read.
|
||||
fn element<'a, 'i>(&self, xml: &'a roxmltree::Document<'i>, id: &str) -> Option<XNode<'a, 'i>> {
|
||||
#[cfg(test)]
|
||||
if LINEAR_IDS.get() {
|
||||
ID_WALKS.set(ID_WALKS.get() + 1);
|
||||
return xml.descendants().find(|n| n.is_element() && n.attribute("id") == Some(id));
|
||||
}
|
||||
let ids = self.ids.get_or_init(|| {
|
||||
#[cfg(test)]
|
||||
ID_WALKS.set(ID_WALKS.get() + 1);
|
||||
let mut ids = HashMap::new();
|
||||
for n in xml.descendants().filter(|n| n.is_element()) {
|
||||
if let Some(id) = n.attribute("id") {
|
||||
ids.entry(Box::from(id)).or_insert(n.id());
|
||||
}
|
||||
}
|
||||
ids
|
||||
});
|
||||
let el = xml.get_node(*ids.get(id)?)?;
|
||||
debug_assert_eq!(el.attribute("id"), Some(id), "the id map was built from another document");
|
||||
Some(el)
|
||||
}
|
||||
|
||||
/// The equivalent path of a basic shape (SVG 2 › Basic Shapes), as path data: what a
|
||||
/// `<textPath>` that points at it follows. Circles and ellipses start at 3 o'clock and rounded
|
||||
/// rects at the end of the top-left corner, all running clockwise; lines and polylines follow
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use vectorcraft_doc::Document;
|
||||
|
||||
/// The texts [`prepare`] builds from `body` and how many times it read a `<textPath>`'s path.
|
||||
fn prepared(body: &str) -> (usize, u64, Vec<String>) {
|
||||
@@ -27,3 +28,134 @@ fn uses_of_a_text_on_a_path_read_the_path_once() {
|
||||
));
|
||||
assert_eq!((texts, reads), (51, 1));
|
||||
}
|
||||
|
||||
/// How many times [`prepare`] walked the document's elements to find the element a
|
||||
/// `<textPath>` names.
|
||||
fn id_walks(body: &str) -> u64 {
|
||||
let svg = format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">{body}</svg>"#);
|
||||
let xml = roxmltree::Document::parse(&svg).unwrap();
|
||||
let before = ID_WALKS.get();
|
||||
prepare(&svg, &xml, None, 96.0, &mut vec![]);
|
||||
ID_WALKS.get() - before
|
||||
}
|
||||
|
||||
/// The texts on paths in one file find the elements they name through one walk of the document.
|
||||
#[test]
|
||||
fn text_paths_find_their_elements_in_one_walk() {
|
||||
let paths: String = (0..20).map(|i| format!(r#"<path id="p{i}" d="M0 {i}L150 {i}"/>"#)).collect();
|
||||
let texts: String = (0..20).map(|i| format!(r##"<text id="t{i}"><textPath href="#p{i}">Path</textPath></text>"##)).collect();
|
||||
assert_eq!(id_walks(&format!("<defs>{paths}</defs>{texts}")), 1);
|
||||
// Texts shown only through `<use>` elements share the walk, and a missing id needs no other.
|
||||
let uses: String = (0..20).map(|i| format!(r##"<use href="#t{i}" font-size="20"/>"##)).collect();
|
||||
let missing = r##"<text><textPath xlink:href="#none" xmlns:xlink="http://www.w3.org/1999/xlink">Path</textPath></text>"##;
|
||||
assert_eq!(id_walks(&format!("<defs>{paths}{texts}</defs>{uses}{missing}")), 1);
|
||||
// A file whose texts name no element is not walked.
|
||||
assert_eq!(id_walks(r#"<text>Plain</text><text><textPath path="M0 20L150 20">Inline</textPath></text>"#), 0);
|
||||
assert_eq!(id_walks(r#"<path id="p" d="M0 20L150 20"/><text><textPath href="p">No hash</textPath></text>"#), 0);
|
||||
}
|
||||
|
||||
/// The document and warnings [`crate::import`] gives for `body`, with each `<textPath>`'s
|
||||
/// element found through the map of ids or, with `linear`, by walking the document for each one.
|
||||
fn imported(body: &str, linear: bool) -> (Document, Vec<String>) {
|
||||
let svg = format!(r#"<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="400">{body}</svg>"#);
|
||||
LINEAR_IDS.set(linear);
|
||||
let out = crate::import::import(&svg, &crate::ImportOptions::default(), crate::MAX_NODES);
|
||||
LINEAR_IDS.set(false);
|
||||
out.unwrap_or_else(|e| panic!("{e}"))
|
||||
}
|
||||
|
||||
/// The text objects of `d`, in paint order.
|
||||
fn text_objects(d: &Document) -> Vec<TextObject> {
|
||||
let mut v = vec![];
|
||||
d.walk(|n| {
|
||||
if let vectorcraft_doc::NodeKind::Text(t) = &n.kind {
|
||||
v.push((**t).clone());
|
||||
}
|
||||
});
|
||||
v
|
||||
}
|
||||
|
||||
/// The map of ids finds the element the document walk finds: the first element in document order
|
||||
/// with the id, whatever it is.
|
||||
#[test]
|
||||
fn text_paths_find_the_element_a_document_walk_finds() {
|
||||
let cases = [
|
||||
// Several paths, one of them named twice, and shapes.
|
||||
r##"<defs><path id="a" d="M0 20L150 20"/><path id="b" d="M0 50C50 0 100 100 150 50" pathLength="10"/><path id="a" d="M0 80L150 80"/>
|
||||
<circle id="c" cx="200" cy="200" r="80"/><rect id="r" x="10" y="10" width="200" height="100" rx="5"/></defs>
|
||||
<text font-size="12"><textPath href="#a">First</textPath></text>
|
||||
<text font-size="12"><textPath xlink:href=" #b " startOffset="5">Second</textPath></text>
|
||||
<text font-size="12"><textPath href="#c" side="right">Circle</textPath></text>
|
||||
<text font-size="12"><textPath href="#r" startOffset="50%">Rect</textPath></text>"##,
|
||||
// A missing id, an empty one, and one without a `#`.
|
||||
r##"<path id="p" d="M0 20L150 20"/><text><textPath href="#none">Missing</textPath></text>
|
||||
<text><textPath href="#">Empty</textPath></text><text><textPath href="p">Bare</textPath></text>"##,
|
||||
// The first element with the id has no path; the later path is not used.
|
||||
r##"<g id="p"><path d="M0 20L150 20"/></g><path id="p" d="M0 80L150 80"/><text><textPath href="#p">Group</textPath></text>"##,
|
||||
// Ids on texts and groups, one of them named twice.
|
||||
r##"<g id="g"><text id="t"><textPath href="#t">Self</textPath></text></g><text id="g">Later</text><text><textPath href="#g">Group</textPath></text>"##,
|
||||
// Uses of texts on paths, and an inline path beside an href.
|
||||
r##"<defs><path id="p" d="M0 20L150 20"/><text id="t"><textPath href="#p">Used</textPath></text></defs>
|
||||
<use href="#t" font-size="30"/><use href="#t" y="40"/><text><textPath href="#p" path="M0 90L150 90">Inline</textPath></text>"##,
|
||||
];
|
||||
for body in cases {
|
||||
let map = imported(body, false);
|
||||
assert_eq!(map, imported(body, true), "{body}");
|
||||
assert!(!text_objects(&map.0).is_empty(), "{body}");
|
||||
}
|
||||
}
|
||||
|
||||
/// With two elements of one id, a `<textPath>` follows the first.
|
||||
#[test]
|
||||
fn a_text_path_follows_the_first_element_with_its_id() {
|
||||
let text = r##"<text font-size="12"><textPath href="#p">Path</textPath></text>"##;
|
||||
let first = text_objects(&imported(&format!(r#"<path id="p" d="M0 20L150 20"/><path id="p" d="M0 80L150 80"/>{text}"#), false).0);
|
||||
let only = text_objects(&imported(&format!(r#"<path id="p" d="M0 20L150 20"/><path id="q" d="M0 80L150 80"/>{text}"#), false).0);
|
||||
let second = text_objects(&imported(&format!(r#"<path id="q" d="M0 20L150 20"/><path id="p" d="M0 80L150 80"/>{text}"#), false).0);
|
||||
assert!(matches!(first[0].kind, TextKind::OnPath { .. }), "{:?}", first[0].kind);
|
||||
assert_eq!(first, only);
|
||||
assert_ne!(first, second);
|
||||
// A first element with no path leaves the text without one.
|
||||
let (doc, warnings) = imported(&format!(r#"<g id="p"/><path id="p" d="M0 80L150 80"/>{text}"#), false);
|
||||
assert!(!matches!(text_objects(&doc)[0].kind, TextKind::OnPath { .. }), "{warnings:?}");
|
||||
}
|
||||
|
||||
/// Times importing a file with 20,000 paths and 2,000 texts on paths, finding each `<textPath>`'s
|
||||
/// element through the map of ids and by walking the document for each one, after checking that
|
||||
/// the two give the same document. Run it with
|
||||
/// `cargo test --release -p vectorcraft-svg --lib text_path_lookup_timing -- --ignored --nocapture`.
|
||||
#[test]
|
||||
#[ignore = "timing; run by hand in a release build"]
|
||||
fn text_path_lookup_timing() {
|
||||
let mut body = String::new();
|
||||
for i in 0..20_000 {
|
||||
let _ = write!(body, r#"<path id="p{i}" d="M0 {}L300 {}"/>"#, i % 400, i % 400);
|
||||
if i % 10 == 9 {
|
||||
let k = (i * 7919) % 20_000;
|
||||
let _ = write!(body, r##"<text font-size="8"><textPath href="#p{k}">L{i}</textPath></text>"##);
|
||||
}
|
||||
}
|
||||
let svg = format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">{body}</svg>"#);
|
||||
let run = |linear: bool| {
|
||||
LINEAR_IDS.set(linear);
|
||||
let start = std::time::Instant::now();
|
||||
let out = crate::import::import(&svg, &crate::ImportOptions::default(), crate::MAX_NODES);
|
||||
let took = start.elapsed();
|
||||
LINEAR_IDS.set(false);
|
||||
(out.unwrap_or_else(|e| panic!("{e}")), took)
|
||||
};
|
||||
let (map, _) = run(false);
|
||||
let (walk, _) = run(true);
|
||||
assert_eq!(map, walk);
|
||||
assert_eq!(text_objects(&map.0).len(), 2_000);
|
||||
let (mut maps, mut walks) = (vec![], vec![]);
|
||||
for _ in 0..7 {
|
||||
walks.push(run(true).1);
|
||||
maps.push(run(false).1);
|
||||
}
|
||||
println!("walk per textPath: {walks:?}");
|
||||
println!("map of ids: {maps:?}");
|
||||
walks.sort();
|
||||
maps.sort();
|
||||
println!("median: walk {:?}, map {:?}", walks[3], maps[3]);
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 { .. }));
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+3
-1
@@ -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. |
|
||||
@@ -535,12 +536,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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5
-3
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user