diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index a168c28396..07579cd456 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -34,6 +34,7 @@ pub mod pie; pub mod place; pub mod printtiling; pub mod repeat_grid; +pub mod repeat_radial; pub mod rulerguide; pub mod select; pub mod settings; diff --git a/crates/tools/src/repeat_radial.rs b/crates/tools/src/repeat_radial.rs new file mode 100644 index 0000000000..05eafc8d1b --- /dev/null +++ b/crates/tools/src/repeat_radial.rs @@ -0,0 +1,436 @@ +//! Radial Repeat's on-canvas handles: a handle below the repeat adds or removes instances, and a +//! handle on the circle the instances sit on sets its radius, as the public "Create radial +//! repeats" page describes. Drawing and hit testing share the document-space geometry of +//! [`RadialHandles::of`]; a drag previews the existing Repeat Options command and commits as one +//! undo step. +use serde_json::{Value, json}; +use vectorcraft_doc::{Document, NodeId, NodeKind, OrientedBox, RepeatKind, Selection}; +use vectorcraft_geom::{Affine, Point, Rect, Vec2}; + +use crate::bbox::Handle; +use crate::{Action, Cursor, Mods, ToolContext}; + +/// The radius of the instances and radius handles (screen points). +pub const HANDLE_RADIUS: f32 = 5.0; + +/// How far (screen points) the instances handle sits below the bounding box, clear of its own +/// handles and rotate zones. +pub const HANDLE_GAP: f64 = 22.0; + +/// How far (screen points) the instances handle is dragged for each instance it adds or removes. +pub const INSTANCE_STEP: f64 = 16.0; + +/// How near (screen points) a press must come to a handle to take it. +const REACH: f64 = 8.0; + +/// The most instances a radial repeat has (as `object.repeat.options` accepts them). +const MAX_INSTANCES: f64 = 1000.0; + +/// A control of [`RadialHandles`]. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum RadialPart { + /// Below the repeat: drag down for more instances, up for fewer. + Instances, + /// On the circle, between the first two instances: drag outward for a larger radius, inward + /// for a smaller one. + Radius, +} + +/// The controls of a selected radial repeat, in document space. +#[derive(Clone, Copy, Debug)] +pub struct RadialHandles { + pub id: NodeId, + instances: u32, + /// The circle the instances' centers sit on. + pub center: Point, + pub radius: f64, + /// The unit direction from the center to the radius handle. + out: Vec2, + /// Document points of drag for each instance. + step: f64, + pub instances_at: Point, + pub radius_at: Point, +} + +impl RadialHandles { + /// The controls of a single editable radial repeat selected whole, the instances handle placed + /// below `frame` (the bounding box the Selection tool shows; its geometric bounds without one) + /// at `zoom`. + pub fn of(doc: &Document, selection: &Selection, frame: Option, zoom: f64) -> Option { + let [id] = selection.objects.as_slice() else { return None }; + if !selection.anchors.is_empty() || !selection.segments.is_empty() || !doc.is_editable(*id) || !zoom.is_finite() || zoom <= 0.0 { + return None; + } + let n = doc.node(*id)?; + let NodeKind::Repeat(spec) = &n.kind else { return None }; + let RepeatKind::Radial { instances, radius, center, start_angle, end_angle, .. } = spec.kind else { return None }; + if ![radius, center.x, center.y, start_angle, end_angle].iter().all(|v| v.is_finite()) { + return None; + } + let source = spec.source_bounds()?; + if !finite(source.center()) { + return None; + } + // As `repeat_transforms` lays the instances out: the first one at `start_angle` from the + // source's own direction, the rest a step apart. + let instances = instances.clamp(1, 1000); + let mut d = source.center() - center; + if d.hypot() < 1e-9 { + d = Vec2::new(0.0, -1.0); + } + let sweep = end_angle - start_angle; + let full = (sweep.abs() - 360.0).abs() < 1e-9; + let step = if full || instances == 1 { sweep / f64::from(instances) } else { sweep / f64::from(instances - 1) }; + // Halfway between the first two instances (opposite the only one of a full turn). + let out = (Affine::rotate((start_angle + step / 2.0).to_radians()) * d.normalize().to_point()).to_vec2(); + let radius = radius.max(0.0); + let frame = match frame { + Some(f) => aabb(f.corners())?, + None => n.geometric_bounds_with(&doc.symbol_boxes())?, + }; + let h = Self { + id: *id, + instances, + center, + radius, + out, + step: INSTANCE_STEP / zoom, + instances_at: Point::new(frame.center().x, frame.y1 + HANDLE_GAP / zoom), + radius_at: center + out * radius, + }; + (finite(h.instances_at) && finite(h.radius_at) && h.step.is_finite() && h.step > 0.0).then_some(h) + } + + /// Both controls with where they are. + pub fn parts(&self) -> [(RadialPart, Point); 2] { + [(RadialPart::Instances, self.instances_at), (RadialPart::Radius, self.radius_at)] + } + + /// The control under `p` (the nearer within reach) and the repeat's controls, unless a + /// bounding-box handle is there, which keeps its scaling. + fn hit(cx: &ToolContext, p: Point) -> Option<(Self, RadialPart)> { + if !cx.show_bbox || !finite(p) { + return None; + } + let h = Self::of(cx.doc, cx.selection, crate::select::selection_box(cx), cx.zoom)?; + let reach = cx.tol(REACH); + let (part, _) = + h.parts().into_iter().map(|(part, q)| (part, q.distance(p))).filter(|(_, d)| *d <= reach).min_by(|a, b| a.1.total_cmp(&b.1))?; + (!crate::select::bbox_handle_at(cx, p)).then_some((h, part)) + } + + /// The Repeat Options that dragging `part` by `d` (document points) from the press gives; + /// none when the drag is too far to measure. + fn options(&self, part: RadialPart, d: Vec2) -> Option { + match part { + RadialPart::Instances => { + let n = f64::from(self.instances) + (d.y / self.step).round(); + // NaN only comes from an infinite drag; the clamp keeps a huge one at the limit. + (!n.is_nan()).then(|| json!({ "instances": n.clamp(1.0, MAX_INSTANCES) as u32 })) + } + RadialPart::Radius => { + // Only the part of the drag along the line from the center moves the circle. + let r = ((self.radius + d.dot(self.out)).max(0.0) * 100.0).round() / 100.0; + r.is_finite().then(|| json!({ "radius": r })) + } + } + } + + /// The direction (counter-clockwise degrees) in which the radius handle moves the circle out. + fn out_angle(&self) -> f64 { + (-self.out.y).atan2(self.out.x).to_degrees() + } +} + +/// The page-square bounds of `corners`. +fn aabb(corners: [Point; 4]) -> Option { + let r = corners.iter().skip(1).fold(Rect::from_points(corners[0], corners[0]), |r, p| r.union_pt(*p)); + [r.x0, r.y0, r.x1, r.y1].iter().all(|v| v.is_finite()).then_some(r) +} + +fn finite(p: Point) -> bool { + p.x.is_finite() && p.y.is_finite() +} + +/// The resize cursor of `part`, turned with the view: up and down for the instances handle, along +/// the line from the center for the radius handle. +fn part_cursor(cx: &ToolContext, h: &RadialHandles, part: RadialPart) -> Cursor { + match part { + RadialPart::Instances => crate::select::handle_cursor(Handle::Bottom, -cx.view_angle()), + RadialPart::Radius => crate::select::handle_cursor(Handle::Right, h.out_angle() - cx.view_angle()), + } +} + +/// The cursor over a radial repeat's control at `p`, if one is there. +pub fn cursor(cx: &ToolContext, p: Point) -> Option { + let (h, part) = RadialHandles::hit(cx, p)?; + Some(part_cursor(cx, &h, part)) +} + +/// A drag of one of a radial repeat's controls. +#[derive(Clone, Debug)] +pub struct RadialDrag { + handles: RadialHandles, + part: RadialPart, + start: Point, + /// The options the press found, and the last ones previewed. + from: Value, + last: Option, +} + +impl RadialDrag { + pub fn hit(cx: &ToolContext, p: Point, mods: Mods) -> Option { + if mods.cmd || mods.ctrl || mods.alt { + return None; + } + let (handles, part) = RadialHandles::hit(cx, p)?; + let from = handles.options(part, Vec2::ZERO)?; + Some(Self { handles, part, start: p, from, last: None }) + } + + /// Whether the drag has changed the repeat (and so previews it). + pub fn adjusting(&self) -> bool { + self.last.is_some() + } + + pub fn cursor(&self, cx: &ToolContext) -> Cursor { + part_cursor(cx, &self.handles, self.part) + } + + /// Preview the options the pointer at `p` gives, when they change; the first change opens + /// the undo step. + pub fn drag(&mut self, p: Point) -> Vec { + if !finite(p) { + return vec![]; + } + let Some(v) = self.handles.options(self.part, p - self.start) else { return vec![] }; + if self.last.as_ref().unwrap_or(&self.from) == &v { + return vec![]; + } + let mut out = vec![]; + if self.last.is_none() { + out.push(Action::Begin("Repeat Options".into())); + } + out.push(Action::Preview("object.repeat.options".into(), v.clone())); + self.last = Some(v); + out + } + + /// Commit the drag; one that ends where it began leaves no undo step. + pub fn finish(self) -> Vec { + match self.last { + Some(v) if v == self.from => vec![Action::Cancel], + Some(_) => vec![Action::Commit], + None => vec![], + } + } + + pub fn cancel(self) -> Vec { + if self.last.is_some() { vec![Action::Cancel] } else { vec![] } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::testutil::{cx, doc_with_rect, paint}; + use std::sync::Arc; + use vectorcraft_doc::pattern::RepeatSpec; + + /// [`doc_with_rect`]'s 100 × 100 square at (100, 100) as a radial repeat of eight instances + /// with a radius of 100 pt about (150, 250), selected. The instances span (0, 100)–(300, 400). + fn radial() -> (Document, Selection) { + let (mut doc, id) = doc_with_rect(); + let mut source = doc.node(id).unwrap().clone(); + source.id = doc.alloc_id(); + doc.node_mut(id).unwrap().kind = NodeKind::Repeat(RepeatSpec::radial(vec![Arc::new(source)], 8, Some(100.0))); + let mut selection = Selection::default(); + selection.set([id]); + (doc, selection) + } + + fn set(doc: &mut Document, selection: &Selection, f: impl FnOnce(&mut u32, &mut f64, &mut f64, &mut f64)) { + let NodeKind::Repeat(spec) = &mut doc.node_mut(selection.objects[0]).unwrap().kind else { panic!("a repeat") }; + let RepeatKind::Radial { instances, radius, start_angle, end_angle, .. } = &mut spec.kind else { panic!("a radial repeat") }; + f(instances, radius, start_angle, end_angle); + } + + fn near(a: Point, b: Point) -> bool { + a.distance(b) < 1e-6 + } + + fn preview(out: &[Action]) -> Option<&Value> { + out.iter().find_map(|a| match a { + Action::Preview(cmd, v) if cmd == "object.repeat.options" => Some(v), + _ => None, + }) + } + + #[test] + fn the_handles_sit_below_the_repeat_and_on_its_circle_at_every_zoom() { + let (doc, selection) = radial(); + // Halfway between the first instance (straight up from the center) and the second, 45° + // clockwise from it. + let half = 22.5_f64.to_radians(); + let on_circle = Point::new(150.0 + 100.0 * half.sin(), 250.0 - 100.0 * half.cos()); + for zoom in [0.02, 1.0, 4.0] { + let h = RadialHandles::of(&doc, &selection, None, zoom).unwrap(); + assert!(near(h.instances_at, Point::new(150.0, 400.0 + HANDLE_GAP / zoom)), "{zoom}: {:?}", h.instances_at); + assert!(near(h.radius_at, on_circle), "{zoom}: {:?}", h.radius_at); + assert_eq!((h.center, h.radius), (Point::new(150.0, 250.0), 100.0)); + } + // Placed below the bounding box the Selection tool shows. + let frame = OrientedBox::aligned(Rect::new(-10.0, 90.0, 310.0, 410.0)); + let h = RadialHandles::of(&doc, &selection, Some(frame), 1.0).unwrap(); + assert!(near(h.instances_at, Point::new(150.0, 410.0 + HANDLE_GAP))); + } + + #[test] + fn the_radius_handle_follows_the_instances_angles() { + let (mut doc, selection) = radial(); + // One instance: opposite it. + set(&mut doc, &selection, |n, _, _, _| *n = 1); + let h = RadialHandles::of(&doc, &selection, None, 1.0).unwrap(); + assert!(near(h.radius_at, Point::new(150.0, 350.0)), "{:?}", h.radius_at); + // Three instances over a quarter turn from 90°: between those at 90° and 135°. + set(&mut doc, &selection, |n, _, a, b| (*n, *a, *b) = (3, 90.0, 180.0)); + let h = RadialHandles::of(&doc, &selection, None, 1.0).unwrap(); + let a = 112.5_f64.to_radians(); + assert!(near(h.radius_at, Point::new(150.0 + 100.0 * a.sin(), 250.0 - 100.0 * a.cos())), "{:?}", h.radius_at); + // A radius of 0: at the center, still apart from the instances handle. + set(&mut doc, &selection, |_, r, _, _| *r = 0.0); + let h = RadialHandles::of(&doc, &selection, None, 1.0).unwrap(); + assert!(near(h.radius_at, Point::new(150.0, 250.0))); + assert!(h.radius_at.distance(h.instances_at) > 2.0 * REACH); + } + + #[test] + fn no_handles_without_a_single_valid_radial_repeat() { + let (mut doc, mut selection) = radial(); + for zoom in [0.0, -1.0, f64::NAN, f64::INFINITY] { + assert!(RadialHandles::of(&doc, &selection, None, zoom).is_none(), "{zoom}"); + } + let paint = paint(); + let h = RadialHandles::of(&doc, &selection, None, 1.0).unwrap(); + { + let mut c = cx(&doc, &selection, &paint); + assert!(cursor(&c, h.instances_at).is_some()); + c.show_bbox = false; + assert!(cursor(&c, h.instances_at).is_none(), "the bounding box is hidden"); + } + let id = selection.objects[0]; + doc.node_mut(id).unwrap().locked = true; + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "a locked repeat"); + doc.node_mut(id).unwrap().locked = false; + doc.node_mut(id).unwrap().visible = false; + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "a hidden repeat"); + doc.node_mut(id).unwrap().visible = true; + for bad in [f64::NAN, f64::INFINITY] { + set(&mut doc, &selection, |_, r, _, _| *r = bad); + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "radius {bad}"); + set(&mut doc, &selection, |_, r, a, _| (*r, *a) = (100.0, bad)); + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "start angle {bad}"); + set(&mut doc, &selection, |_, _, a, _| *a = 0.0); + } + let other = doc.alloc_id(); + let mut second = doc.node(id).unwrap().clone(); + second.id = other; + let layer = doc.layers[0].id; + doc.insert(Some(layer), 1, second).unwrap(); + selection.set([id, other]); + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "two objects selected"); + selection.set([id]); + let NodeKind::Repeat(spec) = &mut doc.node_mut(id).unwrap().kind else { panic!("a repeat") }; + spec.kind = RepeatKind::Grid { + h_spacing: 10.0, + v_spacing: 10.0, + rows: 3, + cols: 3, + grid_type: Default::default(), + flip_rows: false, + flip_cols: false, + }; + assert!(RadialHandles::of(&doc, &selection, None, 1.0).is_none(), "a grid repeat"); + } + + #[test] + fn dragging_the_instances_handle_steps_the_count() { + let (doc, selection) = radial(); + let paint = paint(); + let mut c = cx(&doc, &selection, &paint); + let h = RadialHandles::of(&doc, &selection, crate::select::selection_box(&c), 1.0).unwrap(); + let mut d = RadialDrag::hit(&c, h.instances_at, Mods::default()).unwrap(); + assert!(d.drag(h.instances_at + Vec2::new(0.0, 7.0)).is_empty(), "less than half a step changes nothing"); + assert!(!d.adjusting()); + // Two steps down, a little sideways: ten instances, one undo step. + let out = d.drag(h.instances_at + Vec2::new(5.0, 32.0)); + assert!(matches!(out.first(), Some(Action::Begin(l)) if l == "Repeat Options"), "{out:?}"); + assert_eq!(preview(&out), Some(&json!({"instances": 10}))); + assert!(d.drag(h.instances_at + Vec2::new(0.0, 36.0)).is_empty(), "the same count isn't previewed again"); + assert!(d.adjusting()); + assert!(matches!(d.finish().as_slice(), [Action::Commit])); + // Far up: one instance at least; far down: 1,000 at most. + let mut d = RadialDrag::hit(&c, h.instances_at, Mods::default()).unwrap(); + assert_eq!(preview(&d.drag(h.instances_at - Vec2::new(0.0, 900.0))), Some(&json!({"instances": 1}))); + assert_eq!(preview(&d.drag(h.instances_at + Vec2::new(0.0, 1e300))), Some(&json!({"instances": 1000}))); + assert!(d.drag(Point::new(f64::NAN, 0.0)).is_empty(), "a non-finite pointer"); + // Back where it began: no undo step. + assert_eq!(preview(&d.drag(h.instances_at)), Some(&json!({"instances": 8}))); + assert!(matches!(d.finish().as_slice(), [Action::Cancel])); + // The step is the same on screen at every zoom: 16 px is a quarter point at 64. + c.zoom = 64.0; + let h = RadialHandles::of(&doc, &selection, crate::select::selection_box(&c), c.zoom).unwrap(); + let mut d = RadialDrag::hit(&c, h.instances_at, Mods::default()).unwrap(); + assert_eq!(preview(&d.drag(h.instances_at - Vec2::new(0.0, 0.25))), Some(&json!({"instances": 7}))); + assert!(matches!(d.cancel().as_slice(), [Action::Cancel])); + // Alt, Cmd and Ctrl keep the Selection tool's own gestures. + assert!(RadialDrag::hit(&c, h.instances_at, Mods { alt: true, ..Mods::default() }).is_none()); + } + + #[test] + fn dragging_the_radius_handle_moves_the_circle_in_and_out() { + let (doc, selection) = radial(); + let paint = paint(); + let c = cx(&doc, &selection, &paint); + let h = RadialHandles::of(&doc, &selection, crate::select::selection_box(&c), 1.0).unwrap(); + let out = (h.radius_at - h.center) / 100.0; + let across = Vec2::new(-out.y, out.x); + let mut d = RadialDrag::hit(&c, h.radius_at, Mods::default()).unwrap(); + // 25 pt out and 40 pt across: only the outward part counts. + let o = d.drag(h.radius_at + out * 25.0 + across * 40.0); + assert!(matches!(o.first(), Some(Action::Begin(l)) if l == "Repeat Options"), "{o:?}"); + assert_eq!(preview(&o), Some(&json!({"radius": 125.0}))); + assert!(d.drag(h.radius_at + across * 30.0).iter().any(|a| matches!(a, Action::Preview(_, v) if v == &json!({"radius": 100.0})))); + // Past the center: a radius of 0. + assert_eq!(preview(&d.drag(h.radius_at - out * 250.0)), Some(&json!({"radius": 0.0}))); + // Too far to measure: nothing previewed. + assert!(d.drag(Point::new(f64::MAX, -f64::MAX)).is_empty()); + assert!(matches!(d.finish().as_slice(), [Action::Commit])); + // Escape before any change leaves nothing to undo. + let d = RadialDrag::hit(&c, h.radius_at, Mods::default()).unwrap(); + assert!(d.cancel().is_empty()); + } + + #[test] + fn a_bounding_box_handle_wins_where_they_overlap() { + let (doc, selection) = radial(); + let paint = paint(); + let mut c = cx(&doc, &selection, &paint); + // Zoomed far out (the 300 pt repeat 6 px across), the radius handle lies on a + // bounding-box handle, which keeps its scaling; the instances handle stays clear of the box. + c.zoom = 0.02; + let h = RadialHandles::of(&doc, &selection, crate::select::selection_box(&c), c.zoom).unwrap(); + assert!(crate::select::bbox_handle_at(&c, h.radius_at)); + assert!(RadialDrag::hit(&c, h.radius_at, Mods::default()).is_none()); + assert!(cursor(&c, h.radius_at).is_none()); + assert!(!crate::select::bbox_handle_at(&c, h.instances_at)); + assert!(RadialDrag::hit(&c, h.instances_at, Mods::default()).is_some()); + // At full size both are the repeat's, with resize cursors along their drags. + c.zoom = 1.0; + let h = RadialHandles::of(&doc, &selection, crate::select::selection_box(&c), c.zoom).unwrap(); + assert!(RadialDrag::hit(&c, h.radius_at, Mods::default()).is_some()); + assert_eq!(cursor(&c, h.instances_at), Some(Cursor::ResizeV)); + // The radius handle points 22.5° clockwise from straight up: the up-and-down cursor. + assert_eq!(cursor(&c, h.radius_at), Some(Cursor::ResizeV)); + } +} diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 8a755395dc..543f9c7bb1 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -147,6 +147,8 @@ enum State { Mirror(crate::mirror::MirrorDrag), /// Drag a grid repeat's row, column or corner handle or a spacing slider. GridRepeat(crate::repeat_grid::GridDrag), + /// Drag a radial repeat's instances or radius handle. + RadialRepeat(crate::repeat_radial::RadialDrag), /// Dragging a bracket of type on a path. Bracket(BracketDrag), /// Dragging a 9-slice guide of the symbol being edited. @@ -826,6 +828,12 @@ impl Tool for SelectionTool { { return d.cancel(); } + if key == ToolKey::Escape + && matches!(self.state, State::RadialRepeat(_)) + && let State::RadialRepeat(d) = std::mem::take(&mut self.state) + { + return d.cancel(); + } if key == ToolKey::Escape && matches!(self.state, State::NineSlice(_)) && let State::NineSlice(d) = std::mem::take(&mut self.state) @@ -875,7 +883,7 @@ impl Tool for SelectionTool { State::Marquee { .. } => key == ToolKey::Letter('e'), State::Corner(_) => matches!(key, ToolKey::Up | ToolKey::Down), State::BlendWidget(_) => matches!(key, ToolKey::Up | ToolKey::Down | ToolKey::Left | ToolKey::Right), - State::Loaded { .. } | State::Mirror(_) | State::GridRepeat(_) | State::NineSlice(_) => key == ToolKey::Escape, + State::Loaded { .. } | State::Mirror(_) | State::GridRepeat(_) | State::RadialRepeat(_) | State::NineSlice(_) => key == ToolKey::Escape, _ => false, } } @@ -917,6 +925,7 @@ impl Tool for SelectionTool { State::Bracket(b) => b.adjusting(), State::Mirror(d) => d.adjusting(), State::GridRepeat(d) => d.adjusting(), + State::RadialRepeat(d) => d.adjusting(), _ => false, } } @@ -1228,6 +1237,9 @@ impl Tool for SelectionTool { if let State::GridRepeat(d) = &self.state { return d.cursor(cx); } + if let State::RadialRepeat(d) = &self.state { + return d.cursor(cx); + } if matches!(self.state, State::NineSlice(_)) || (matches!(self.state, State::Idle) && crate::nineslice::over_guide(cx, p)) { return Cursor::Move; } @@ -1235,7 +1247,8 @@ impl Tool for SelectionTool { && !m.cmd && !m.ctrl && !m.alt - && let Some(cursor) = crate::mirror::cursor(cx, p).or_else(|| crate::repeat_grid::cursor(cx, p)) + && let Some(cursor) = + crate::mirror::cursor(cx, p).or_else(|| crate::repeat_grid::cursor(cx, p)).or_else(|| crate::repeat_radial::cursor(cx, p)) { return cursor; } @@ -1553,6 +1566,21 @@ impl SelectionTool { _ => return Some(vec![]), } } + if let State::RadialRepeat(mut d) = self.state.clone() { + match ev.kind { + PointerKind::Drag | PointerKind::Up => { + let mut out = d.drag(ev.pos); + if ev.kind == PointerKind::Up { + out.extend(d.finish()); + self.state = State::Idle; + } else { + self.state = State::RadialRepeat(d); + } + return Some(out); + } + _ => return Some(vec![]), + } + } if matches!(self.state, State::Idle) && ev.kind == PointerKind::Down && let Some(d) = crate::mirror::MirrorDrag::hit(cx, ev.pos, ev.mods) @@ -1569,6 +1597,14 @@ impl SelectionTool { self.hover = None; return Some(vec![]); } + if matches!(self.state, State::Idle) + && ev.kind == PointerKind::Down + && let Some(d) = crate::repeat_radial::RadialDrag::hit(cx, ev.pos, ev.mods) + { + self.state = State::RadialRepeat(d); + self.hover = None; + return Some(vec![]); + } None } diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 847b60fd87..ba72946d38 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -78,7 +78,7 @@ use tool_overlays::{DIAL_RADIUS, HiddenMarks}; pub use tool_overlays::{HiddenChars, SpellingMarks}; use tool_overlays::{ grid_repeat_overlay, hidden_chars_overlay, live_paint_gap_overlays, mirror_axis_overlay, nine_slice_overlay, original_path_overlay, - print_tiling_overlay, rotate_view_dial, shaper_widget_overlay, slice_overlay, spelling_overlay, thread_overlays, + print_tiling_overlay, radial_repeat_overlay, rotate_view_dial, shaper_widget_overlay, slice_overlay, spelling_overlay, thread_overlays, }; pub(crate) use view::animated_zoom; pub(crate) use view::drag_rotation; @@ -1347,6 +1347,7 @@ fn selection_visuals( draw_inside_overlay(app, painter, xf); mirror_axis_overlay(app, painter, xf); grid_repeat_overlay(app, painter, xf); + radial_repeat_overlay(app, painter, xf); if app.ui.view.text_threads { // Under the tools' overlays: a selected frame's own ports are drawn over its thread's. let mut threads = thread_overlays(app, xf.zoom); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 9a5d7fc0b3..4f01911a26 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -4722,6 +4722,102 @@ fn grid_repeat_handles_set_rows_and_spacing_in_one_undo_step_each() { assert_eq!((grid(&app).0, grid(&app).2), (5, 10.0), "the spacing's own undo step"); } +/// A selected radial repeat draws its instances handle and its radius handle (none with the +/// bounding box hidden). In a zoomed view turned 30°, dragging the instances handle two steps down +/// adds two instances without scaling the source, and dragging the radius handle 20 pt outward +/// makes the circle 20 pt larger, as one undo step each; Escape puts a drag back. +#[test] +fn radial_repeat_handles_set_instances_and_radius_in_one_undo_step_each() { + use vectorcraft_tools::repeat_radial::{HANDLE_RADIUS, INSTANCE_STEP, RadialHandles}; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 180, "y": 40, "width": 40, "height": 40})).unwrap(); + app.run("object.repeat.radial", json!({"instances": 6, "radius": 60})).unwrap(); + app.ui.task_bar = false; + app.ui.view.rulers = false; + let ctx = egui::Context::default(); + // The first frame fits the artboard in the window; then zoom to 1.5 px a point and turn 30°. + frame(&mut app, &ctx, vec![]); + app.view_mut().unwrap().zoom = 1.5; + app.view_mut().unwrap().rotation = 30.0; + frame(&mut app, &ctx, vec![]); + // Instances, radius and the source's bounds. + let radial = |app: &VectorcraftApp| { + let st = app.session.active().unwrap(); + let n = st.doc.node(st.selection.objects[0]).unwrap(); + let vectorcraft_doc::NodeKind::Repeat(spec) = &n.kind else { panic!("a repeat") }; + let vectorcraft_doc::RepeatKind::Radial { instances, radius, .. } = spec.kind else { panic!("a radial repeat") }; + (instances, radius, spec.source_bounds().unwrap()) + }; + let handles = |app: &mut VectorcraftApp| { + let frame = app.selection_box(); + let st = app.session.active().unwrap(); + RadialHandles::of(&st.doc, &st.selection, frame, app.view().unwrap().zoom).unwrap() + }; + let before = radial(&app); + assert_eq!((before.0, before.1), (6, 60.0)); + let h = handles(&mut app); + let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap()); + let circle_at = + |drawn: &[Shape], at: Pos2| drawn.iter().any(|s| matches!(s, Shape::Circle(c) if c.center.distance(at) < 0.01 && c.radius == HANDLE_RADIUS)); + let drawn = shapes(&mut app, &ctx); + assert!(circle_at(&drawn, xf.to_screen(h.instances_at)), "the instances handle is drawn"); + assert!(circle_at(&drawn, xf.to_screen(h.radius_at)), "the radius handle is drawn"); + app.ui.view.bounding_box = false; + let drawn = shapes(&mut app, &ctx); + assert!(!circle_at(&drawn, xf.to_screen(h.instances_at)) && !circle_at(&drawn, xf.to_screen(h.radius_at)), "hidden with the bounding box"); + app.ui.view.bounding_box = true; + frame(&mut app, &ctx, vec![]); + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + let drag = |app: &mut VectorcraftApp, from: Pos2, to: Pos2| { + frame(app, &ctx, vec![egui::Event::PointerMoved(from), button(from, true)]); + for k in 1..=4 { + frame(app, &ctx, vec![egui::Event::PointerMoved(from + (to - from) * k as f32 / 4.0)]); + } + }; + let release = |app: &mut VectorcraftApp, at: Pos2| frame(app, &ctx, vec![button(at, false)]); + // 2.2 steps down the page (the screen's down turned 30°): two more instances. + let to = xf.to_screen(h.instances_at + vectorcraft_geom::Vec2::new(0.0, 2.2 * INSTANCE_STEP / 1.5)); + drag(&mut app, xf.to_screen(h.instances_at), to); + assert_eq!(radial(&app).0, 8, "the drag previews"); + release(&mut app, to); + let after = radial(&app); + assert_eq!((after.0, after.1), (8, 60.0)); + assert_eq!(after.2, before.2, "the source keeps its size"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(radial(&app).0, 6, "one undo step"); + app.run("edit.redo", json!({})).unwrap(); + assert_eq!(radial(&app).0, 8); + // 20 pt outward from the center. + frame(&mut app, &ctx, vec![]); + let h = handles(&mut app); + let out = (h.radius_at - h.center) / h.radius; + let to = xf.to_screen(h.radius_at + out * 20.0); + drag(&mut app, xf.to_screen(h.radius_at), to); + release(&mut app, to); + assert_eq!((radial(&app).0, radial(&app).1), (8, 80.0)); + assert_eq!(radial(&app).2, before.2, "the source keeps its size"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!((radial(&app).0, radial(&app).1), (8, 60.0), "the radius's own undo step"); + // Escape during a drag puts the radius back and leaves no undo step. + frame(&mut app, &ctx, vec![]); + let h = handles(&mut app); + drag(&mut app, xf.to_screen(h.radius_at), xf.to_screen(h.radius_at + out * 30.0)); + assert_eq!(radial(&app).1, 90.0, "the drag previews"); + let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + let screen = egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0)); + let mut full = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), events: vec![escape], ..Default::default() }, |ui| { + crate::shortcuts::handle(&mut app, ui.ctx()); + show(&mut app, ui) + }); + full.textures_delta.clear(); + assert_eq!(radial(&app).1, 60.0); + release(&mut app, xf.to_screen(h.radius_at + out * 30.0)); + assert_eq!(radial(&app).1, 60.0, "the release after Escape changes nothing"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(radial(&app).0, 6, "the instances step is the one before"); +} + /// While a symbol with 9-slice guides is edited, the canvas draws its four guides dotted across /// its art, with ruler guides hidden too, and none once the mode ends. Dragging the left guide in /// a zoomed view moves that guide alone, as one undo step. diff --git a/crates/ui-egui/src/canvas/tool_overlays.rs b/crates/ui-egui/src/canvas/tool_overlays.rs index 67f6ac861a..b05259f8f6 100644 --- a/crates/ui-egui/src/canvas/tool_overlays.rs +++ b/crates/ui-egui/src/canvas/tool_overlays.rs @@ -535,6 +535,32 @@ pub(super) fn grid_repeat_overlay(app: &mut VectorcraftApp, p: &egui::Painter, x } } +/// A selected radial repeat's circle with its radius handle on it, and its instances handle below +/// it, at the places the Selection tool's hit testing finds them. +pub(super) fn radial_repeat_overlay(app: &mut VectorcraftApp, p: &egui::Painter, xf: &Xf) { + use vectorcraft_tools::repeat_radial::{HANDLE_RADIUS, RadialHandles}; + if app.session.tool_id() != "selection" || !app.ui.view.bounding_box { + return; + } + let frame = app.selection_box(); + let Some(st) = app.session.active() else { return }; + let Some(h) = RadialHandles::of(&st.doc, &st.selection, frame, xf.zoom) else { return }; + let t = Tokens::get(p.ctx()); + // The circle the instances' centers sit on, while it is a sensible size on screen. + let (c, r) = (xf.to_screen(h.center), (h.radius * xf.zoom) as f32); + if c.is_finite() && r.is_finite() && r > 0.5 && r < 20_000.0 { + p.circle_stroke(c, r, Stroke::new(3.0, t.measure_bg)); + p.circle_stroke(c, r, Stroke::new(1.0, t.selection)); + } + for (_, at) in h.parts() { + let c = xf.to_screen(at); + if c.is_finite() { + p.circle_filled(c, HANDLE_RADIUS, t.measure_bg); + p.circle_stroke(c, HANDLE_RADIUS, Stroke::new(2.0, t.selection)); + } + } +} + /// The radius of the Rotate View dial, in screen points. pub(super) const DIAL_RADIUS: f32 = 40.0; diff --git a/docs/gaps.md b/docs/gaps.md index eda7bb21dd..088912552d 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -139,7 +139,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done:** the selection tools take a clipping path (a clip group's or a layer's clipping mask) on its outline, within the selection tolerance, before the art it clips, so Direct Selection reshapes a mask where the art covers its edge; Select Behind lists the same, and the eyedropper and the tools that act on what is drawn are unchanged. Broader G1 estimates unchanged. - **Done:** one selected clip group's Properties panel has Edit Clipping Path and Edit Contents at its top, which select its clipping path or its clipped art for the selection tools (public doc cited in target-app-parity.md). Broader G1 estimates unchanged. - **Done:** the Properties panel has the additional contextual controls of the public Properties panel overview: Blend Options in Quick Actions for one blend with the Blend tool, Merge Live Paint for a Live Paint group selected with more paths to merge (Live Paint Make and Merge refuse type, images and other objects that aren't paths, which used to vanish among the group's sources), the Width Profile list in Appearance with the Width tool or a variable-width stroke, an applied effect's Delete icon beside fx (with several effects it opens the Appearance panel), and Corner and Corner Radius for corners selected with Direct Selection (public doc cited in target-app-parity.md). Broader G1 estimates unchanged. -- **Done (#2691):** a selected Grid Repeat ([public page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html)) shows a handle below the grid, one right of it and one past its bottom-right corner: dragging them adds or removes rows, columns or both (1 to 500). A slider between the first two columns and one between the first two rows set the horizontal and vertical spacing, staying halfway across the gap under the pointer. Each drag is one undo step through `object.repeat.options` and Escape cancels it; the controls hide with the edges or the bounding box, and bounding-box handles keep priority where they meet. Radial Repeat handles remain. Estimates unchanged. +- **Done (#2691):** a selected Grid Repeat ([public page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html)) shows a handle below the grid, one right of it and one past its bottom-right corner: dragging them adds or removes rows, columns or both (1 to 500). A slider between the first two columns and one between the first two rows set the horizontal and vertical spacing, staying halfway across the gap under the pointer. Each drag is one undo step through `object.repeat.options` and Escape cancels it; the controls hide with the edges or the bounding box, and bounding-box handles keep priority where they meet. A selected Radial Repeat ([public page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/create-radial-repeats.html)) shows a handle below it, dragged down for more instances and up for fewer (16 px each, 1 to 1,000), and a handle on its circle between the first two instances, dragged outward or inward for a larger or smaller radius (0 or more); the same undo, Escape, visibility and priority rules apply. The radial splitter remains. Estimates unchanged. - **Done (#2651):** Object › Repeat › Options… for a Grid Repeat has a Preview checkbox ([public page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html)): while it is on the repeat on the canvas follows the fields, Cancel puts the original back without a history step and OK keeps the previewed values as one undo step. Radial and Mirror Repeat Options have none, as their public pages list none. Estimate unchanged. - **Done (#2877):** a selected Mirror Repeat shows its axis: drag the line or the center handle to move it, an end handle to rotate it (Shift: 45°); each drag is one undo step and Escape cancels it. Bounding-box handles take priority over the axis line; the center and end handles keep their actions. Broader G1 estimates unchanged. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..3222960ef2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -641,6 +641,7 @@ since 2026-10-01. - **Graph legend swatches have their series' stroke:** a default legend swatch of a stacked column, stacked bar, area or pie series has the thin white stroke of the series' marks (VectorCraft's own rule), beside the plot or across the top, and a stroke kept on the series is on the swatch too. Each series' group then paints with one stroke, so a stacked column or area graph the graph tools draw is saved to `.ai` with its data and settings and opens again as a live graph; a stacked bar graph is still written as its art, as the reader has no type for it. Evidence: `cmd::graph::tests::a_legend_swatch_has_the_stroke_of_its_series_marks`, `cmd::graph::tests::a_drawn_stacked_column_graph_saved_as_ai_opens_as_a_graph_that_takes_new_data`, `cmd::graph::tests::a_drawn_graph_saved_as_ai_opens_as_a_graph_unless_the_save_warns`. Scores unchanged. - **Graph section in the Properties panel:** with one graph selected, or series of one graph picked with Group Selection, the Properties panel shows a Graph section. Its Graph Type… button opens the dialog of Object › Graph › Type… ([Format pie graphs](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/format-pie-graphs.html)). Its Graph Data… button opens the dialog of Object › Graph › Data…; this button is VectorCraft's own. Column… shows when every series it would change draws columns or bars, and Marker… when every one draws lines, scatter points or radar lines; this is VectorCraft's own rule. Regression tests in `crates/ui-egui/src/panels/properties/tests.rs`. Scores unchanged. - **Selected Grid Repeat handles (#2691):** `tools/src/repeat_grid.rs` tests place the handles outside the grid at zoom 0.5, 1 and 4, preview rows, columns and spacing, leave no undo step for a drag that ends where it began, and give bounding-box handles priority; a headless canvas regression drags the row handle two tiles down in a zoomed view (3 → 5 rows, the source unchanged, one Undo back) and the column-spacing slider. Scores and hours unchanged. +- **Selected Radial Repeat handles:** `tools/src/repeat_radial.rs` tests place the instances handle below the repeat and the radius handle on its circle between the first two instances at zoom 0.02, 1 and 4 (opposite a single instance, at the center with a radius of 0), step the count by whole instances within 1 to 1,000, set the radius from the outward part of a drag and stop it at 0, hide the handles for a locked, hidden or invalid repeat, leave no undo step for a drag that ends where it began, and give bounding-box handles priority; a headless canvas regression in a zoomed view turned 30° drags the instances handle (6 → 8 instances, the source unchanged, one Undo back) and the radius handle (60 → 80 pt), and Escape puts a radius drag back. Scores and hours unchanged. - **Selected Mirror Repeat handles:** a headless canvas regression creates the default mirror repeat and drags its Top bounding-box handle where the axis crosses it; the repeat grows vertically while its width stays fixed. Existing mirror-axis checks cover center movement and end-handle hit priority. The focused UI mirror tests pass. Scores and hours unchanged. - **Transform effect options (#885):** Effect › Distort & Transform › Transform… has visible Transform Objects, Transform Patterns and Scale Strokes & Effects checkboxes (`distort.transform` params `objects`, `patterns`, `strokes`; files without them draw as before). With Transform Objects off the geometry stays and makes no copies; Scale Strokes & Effects scales stroke weights, dashes and the fills' and strokes' effect distances by the mean scale, and Transform Patterns moves pattern tiles, each copy `k` by the transformation `k` times. Such objects draw, export and expand through the same per-copy art, so the canvas and Expand Appearance agree (engine `tests_transformfx`, effects `tests_transformfx`, the dialog test). A Transform effect in a fill's or stroke's own effects applies the same options to that fill or stroke: its weight and dashes and its pattern follow the transformation, and with copies each copy is an object of its own; the canvas, export, Expand Appearance and Use Preview Bounds use the same art (effects `tests_transformfx`). The effects listed after it in that fill's or stroke's list keep their own distances and apply to the transformed art and to each copy, as an object's later effects do after the object's Transform effect: a Drop Shadow after it keeps its offset, an Offset Path after it offsets by its own distance, and an SVG filter after it keeps its scale and the origin of its user space. With Transform Objects off, the effects before it keep their distances too. Before, Scale Strokes & Effects scaled a fill's or stroke's later effects by the mean scale, so existing documents with such effects draw differently. Effects apply in the order they are listed ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)); how the two options treat the effects after a fill's or stroke's own Transform effect is VectorCraft's own rule, following that order (effects `tests::rasterfollow::a_fills_own_transform_leaves_the_shadow_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_offset_after_it`, `tests::rasterfollow::a_fills_own_transform_leaves_the_svg_filter_after_it`, `tests::transformfx::a_fills_own_transform_with_scale_strokes_and_effects_leaves_its_later_effects`; engine `plugins::a_transform_after_a_painted_fill_effect_leaves_the_later_shadow_on_every_paint`). Public reference: [Scale objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html), [How to apply effects](https://helpx.adobe.com/illustrator/using/effects.html), [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html). Scores and hours unchanged. - **Raster effects before a Transform effect:** effects apply in the order they are listed ([Appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/appearance-attributes-in-illustrator.html)). A Drop Shadow, glow, blur, Feather or pixel filter listed before a Transform effect in the same list (an object's effects, or a fill's or stroke's own) now follows that Transform effect: its sizes scale by the mean scale, and a Drop Shadow's offset turns, reflects and scales with the art. VectorCraft applies this rule with Scale Strokes & Effects on or off. Before, such an effect was drawn at its own distances around the transformed art. The canvas, export, Expand Appearance, Object › Expand, Outline Stroke and the 3D effects use the same values (effects `tests::rasterfollow`; render `a_transform_after_a_drop_shadow_scales_the_shadow_with_the_art`; engine `objexpand::a_shadow_before_a_transform_expands_as_the_canvas_draws_it`, `outlinestroke::a_shadow_before_a_transform_outlines_as_the_canvas_draws_it`). Not yet: a Transform effect that makes copies or moves at random leaves the raster effects before it as they are. The light direction of Underpainting, Rough Pastels, Conté Crayon, Bas Relief, Plaster and Texturizer and the stroke direction of Sprayed Strokes and Graphic Pen now turn and reflect with such a Transform effect, each set to the nearest of its menu's choices (at a tie, the one clockwise of it; VectorCraft's own rule), and Color Halftone's four screen angles turn and reflect with the art ([Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html); effects `tests::rasterfollow::bas_relief_light_follows_rotation_and_reflection` and the tests after it). Not yet: filters whose strokes or patterns run along fixed page axes without a direction setting (Angled Strokes, Crosshatch, Mezzotint's lines, Halftone Pattern's lines, Grain's horizontal and vertical types, De-Interlace) keep those axes, and an uneven scale or a shear sets a direction from the one vector it maps, not a skewed pattern. Scores and hours unchanged. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 8e06948b33..8c104ff5bc 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -395,7 +395,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Command search: Up and Down move through the results, Enter runs the highlighted one | done | #1798 (#1757) | | Learn panel: Window › Learn and Explore tutorials on the app bar open it; For you holds a Quick skill guide card, Skills lists VectorCraft's own skills with progress rings that fill and counts of tutorials finished, a tutorial shows its numbered steps with a check box each that marks the step done once its sample is open, a finished tutorial has a check mark, Back goes up a level; a tool's name in a step is a link that marks the tool where the toolbars show it (its button, its group's flyout, a torn-off strip, a toolbar made with New Toolbar or the All Tools drawer) without choosing it; View more opens the tutorial's practice sample as a new untitled document, Finish tutorial then marks it finished with all its steps, and Next Up shows the next tutorial in the same skill; Reset progress clears the progress (no video) | done | [the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `learn.list`, `learn.tab`, `learn.skills`, `learn.skill`, `learn.show`, `learn.back`, `learn.locateTool`, `learn.openSample`, `learn.markStep`, `learn.finish`, `learn.next`, `learn.resetProgress`; the mark's look and 3-second lifetime, marking steps by hand, keeping the progress in the preferences and Reset progress are VectorCraft's own rules; `panels::learn::tests`, `toolbar::tests` | | Pathfinder panel: a group selected alone counts its nested shapes, so an expanded stroked object keeps the Shape Modes enabled | done | #1642 (#1635) | -| Selected Grid Repeat shows row, column and corner handles and spacing sliders; bounding-box handles take priority where they meet | done | #2691, `tools/src/repeat_grid.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html); drags preview and commit `object.repeat.options` as one undo step, Escape cancels; Radial Repeat has no handles yet | +| Selected Grid Repeat shows row, column and corner handles and spacing sliders; bounding-box handles take priority where they meet | done | #2691, `tools/src/repeat_grid.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html); drags preview and commit `object.repeat.options` as one undo step, Escape cancels; a selected Radial Repeat shows an instances handle below it (16 px of drag per instance, 1 to 1,000) and a radius handle on its circle the same way (`tools/src/repeat_radial.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/create-radial-repeats.html)); its splitter has no handle yet | | Grid Repeat Options (Object › Repeat › Options…) has a Preview checkbox: the repeat on the canvas follows the fields while the dialog is open, Cancel puts the original back without a history step, OK keeps the previewed values as one undo step | done | #2651; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html) lists the Preview option for the grid options only, so Radial and Mirror Repeat Options have none; `dialogs/command.rs` tests | | Type on a Path Options (Type › Type on a Path › Type on a Path Options…, or a double-click on the Type on a Path tools) has a Preview checkbox, off when it opens: the selected type on a path follows Effect, Flip, Align to Path and Spacing while the dialog is open, Cancel puts it back without a history step, OK keeps the previewed values as one undo step | done | #5360; the [public page](https://helpx.adobe.com/illustrator/using/creating-type-path.html) lists the dialog's options, and public tutorials of the dialog show its Preview checkbox; `tests/pathtype.rs` | | Graph Type (Object › Graph › Type…, or a double-click on a graph tool) is a dialog of its own: a menu at the top shows Graph Options or the page of an axis; Graph Options has a button per graph type, Value Axis with Separate Scales, the Style checkboxes (Add Drop Shadow, Add Legend Across Top, First Row in Front, First Column in Front) and the options of the type picked (Column or Bar Width and Cluster Width; Mark Data Points, Connect Data Points, Edge-to-Edge Lines and Draw Filled Lines; a pie graph's Legend, Position and Sort); the Value Axis page (Left Axis and Right Axis with the value axis on both sides) has Tick Values with Override Calculated Values, Tick Marks and Add Labels, and the Category Axis page has Tick Marks with Draw Tick Marks Between Labels; with series picked by Group Selection the type and value axis go to those series | done | Public pages: [graph types](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/change-graph-types.html), [value axes](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/change-graph-value-axes.html), [columns, bars and lines](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/format-columns-bars-and-lines.html), [pie graphs](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/format-pie-graphs.html), [separate scales](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/assign-different-scales-to-value-axes.html), [combined types](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/combine-different-graph-types.html). The options dimmed for a type, the pages listed and the Legend checkbox are VectorCraft's own rules. Dialog `graphType`; `dialogs/graph_type.rs` and its tests |