From 0661f0409f2e52780fd7e1407f912bde01b9b00d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 12:44:18 -0800 Subject: [PATCH] Tabs: dragging a tab stop draws a guide through the selected text While a stop is dragged on the Tabs panel's ruler, the canvas draws a line through the text whose stops the ruler shows, where the stop would land. For area type it crosses the frame cell the paragraph starts in, measured from where the first line starts (inside the inset, or past a text wrap object); for point type it crosses the paragraph's lines from the type's origin. It turns with rotated type and runs across the columns of vertical type. In a Ctrl-drag (Command on macOS) it follows the grabbed stop. No line shows while a release would delete the stop, and it goes on release, Escape, when no button is down, or when the panel is not drawn. It is not a document object and records no undo step. A stop drag whose release the ruler does not get now ends once no button is down, as a marker drag already did. The help page describes this guide: https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/manage-tab-stops.html Its extent, color and the rules above are VectorCraft's own. --- crates/ui-egui/src/canvas.rs | 1 + crates/ui-egui/src/panels/tabs.rs | 119 +++++++++++++- crates/ui-egui/src/panels/tabs/tests.rs | 197 ++++++++++++++++++++++++ docs/target-app-parity.md | 1 + 4 files changed, 315 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 19cae2d9cc..ed2e1aa7ba 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -423,6 +423,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let overlays = selection_visuals(app, &painter, &xf, (hidden_chars, selection_marks, hover_still), revolve_edit, view_info); draw_overlays(&painter, &xf, &overlays, &t, HandleLook::of(&app.session.prefs), &mut shared_paths); app.canvas.shared_paths = shared_paths; + crate::panels::tabs::paint_stop_guide(app, &painter, &xf); if !revolve_edit { shaper_widget_overlay(app, &painter, &xf); crate::panels::three_d::paint_graphic_handles(app, &painter, &xf); diff --git a/crates/ui-egui/src/panels/tabs.rs b/crates/ui-egui/src/panels/tabs.rs index 00814646c5..2f45f62f75 100644 --- a/crates/ui-egui/src/panels/tabs.rs +++ b/crates/ui-egui/src/panels/tabs.rs @@ -2,13 +2,15 @@ //! ruler numbered in the General unit on which a click adds a stop, dragging moves one and dragging //! it off the ruler deletes it. Ctrl-dragging a stop (Command on macOS) moves all the stops by the //! same distance. A stop placed or dragged on the ruler lands on the nearest whole point. With Snap -//! to Unit on, or Shift held, it lands on the ruler's nearest tick. +//! to Unit on, or Shift held, it lands on the ruler's nearest tick. While a stop is dragged, the +//! canvas draws a guide through the selected text where the stop would land. use std::collections::HashSet; use egui::{Sense, Stroke, Ui, vec2}; use serde_json::{Value, json}; use vectorcraft_doc::{Document, Node, NodeId, NodeKind, ParaStyle, TabAlign, TabStop, TextKind, TextObject}; +use vectorcraft_geom::{Point, Vec2}; use super::{pstate, set_pstate}; use crate::VectorcraftApp; @@ -340,7 +342,7 @@ fn current_para(app: &VectorcraftApp) -> Option<(Node, ParaStyle, f64)> { None => super::character::first_selected_text_node(app)?.clone(), }; let NodeKind::Text(t) = &n.kind else { return None }; - let para = editing.map_or(0, |(_, a, _)| t.paragraphs_in(a, a).start); + let para = shown_paragraph(app, t); let span = match &t.kind { TextKind::Area { frame } => frame.bounds().map_or(360.0, |b| b.width()), _ => 360.0, @@ -350,6 +352,12 @@ fn current_para(app: &VectorcraftApp) -> Option<(Node, ParaStyle, f64)> { Some((n, para, span.max(72.0))) } +/// The index of the paragraph of text `t` whose stops the panel shows: the paragraph of the Type +/// tool's insertion point, else the first. +fn shown_paragraph(app: &VectorcraftApp, t: &TextObject) -> usize { + super::character::text_editing(app).map_or(0, |(_, a, _)| t.paragraphs_in(a, a).start) +} + /// [`above_text`], then note the active document and text `n`. A floating panel is /// at least [`crate::panel_docking::PANEL_MIN_WIDTH`] wide, so for narrow text at a low zoom the /// panel comes out wider than asked; the ruler then draws text `n` at [`screen_scale`] and runs @@ -477,6 +485,94 @@ fn apply_moved_all(app: &mut VectorcraftApp, ctx: &egui::Context, stops: &mut Ve }) } +/// While a tab stop is dragged on the ruler: the document and text whose stops the ruler shows, the +/// paragraph it shows them for, where the dragged stop would land (points from the ruler's 0), and +/// the main window's frame in which [`show`] last set it. +#[derive(Clone, Copy, Debug, PartialEq)] +struct StopGuide { + doc: u64, + id: NodeId, + para: usize, + position: f64, + frame: u64, +} + +/// The guide through text `t` for paragraph `para`'s stop at 0 on the ruler, in document space: +/// its two ends and how far it moves per point of stop position. For area type it crosses the frame +/// cell the paragraph starts in, and the ruler's 0 is where the frame lets the paragraph's first +/// line start (the cell's edge inside the inset, or past a wrap object); for point +/// type it crosses the paragraph's lines, and the ruler's 0 is the type's origin. In vertical type +/// it runs across the columns. `None` for type on a path and for a paragraph that does not fit in +/// the frame. +fn guide_axis(t: &TextObject, para: usize) -> Option<(Point, Point, Vec2)> { + let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t); + if lay.on_path { + return None; + } + let text = t.plain_text(); + let start = if para == 0 { 0 } else { text.match_indices('\n').nth(para - 1)?.0 + 1 }; + let end = text.get(start..)?.find('\n').map_or(text.len(), |i| start + i); + let mut lines = lay.lines.iter().filter(|l| l.start >= start && l.start <= end); + let to_doc = |x: f64, y: f64| t.xf * lay.physical_point(Point::new(x, y)); + let (x, top, bottom) = match &t.kind { + TextKind::Area { .. } => { + // The layout measures a line's stops from where the frame lets the line start (past a + // wrap object, or in a frame that is not a rectangle): the paragraph's first line's + // room less its indent, mirrored for a right-to-left list. + let first = lines.next()?; + let style = t.para_at(para); + let indent = if first.rtl && style.list.is_some() { + style.right_indent + } else { + style.laid_out_left_indent() + if para == 0 && t.first_para_continues { 0.0 } else { style.first_line_indent } + }; + let cell = lay.line_xf.inverse().transform_rect_bbox(*lay.frames.get(first.region)?); + (first.avail.0 - indent, cell.y0, cell.y1) + } + TextKind::Point => { + let (top, bottom) = + lines.fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), l| (a.min(l.baseline - l.ascent), b.max(l.baseline + l.descent))); + (0.0, top, bottom) + } + _ => return None, + }; + let (a, b) = (to_doc(x, top), to_doc(x, bottom)); + let along = to_doc(x + 1.0, top) - a; + [a.x, a.y, b.x, b.y, along.x, along.y].iter().all(|v| v.is_finite()).then_some((a, b, along)) +} + +/// The guide [`show`] keeps through the selected text while a tab stop is dragged on the ruler, as +/// two document points: set in this frame of the main window or the one before, for text in the +/// active document. A drag that ends while the panel is not drawn leaves no guide behind. +pub(crate) fn stop_guide(app: &VectorcraftApp, ctx: &egui::Context) -> Option<(Point, Point)> { + let g = pstate::>(ctx, "tabs-guide")?; + let doc = app.session.active()?; + if doc.uid != g.doc || g.frame + 1 < ctx.cumulative_frame_nr_for(egui::ViewportId::ROOT) { + return None; + } + let NodeKind::Text(t) = &doc.doc.node(g.id)?.kind else { return None }; + // Lay the text out once per document change, not in every frame of the drag. + let key = (doc.uid, g.id, g.para, doc.revision); + type Axis = Option<((u64, NodeId, usize, u64), Option<(Point, Point, Vec2)>)>; + let (a, b, along) = match pstate::(ctx, "tabs-guide-axis") { + Some((k, axis)) if k == key => axis, + _ => { + let axis = guide_axis(t, g.para); + set_pstate::(ctx, "tabs-guide-axis", Some((key, axis))); + axis + } + }?; + Some((a + along * g.position, b + along * g.position)) +} + +/// Draw [`stop_guide`] on the canvas in the theme's accent. +pub(crate) fn paint_stop_guide(app: &VectorcraftApp, painter: &egui::Painter, xf: &crate::canvas::Xf) { + let ctx = painter.ctx(); + if let Some((a, b)) = stop_guide(app, ctx) { + painter.line_segment([xf.to_screen(a), xf.to_screen(b)], Stroke::new(1.0, Tokens::get(ctx).accent)); + } +} + pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let t = Tokens::get(ui.ctx()); let Some((node, para, span)) = current_para(app) else { @@ -643,7 +739,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // The stop within 5 px of `x`. let hit_at = |x: f32| stops.iter().position(|s| (to_x(s.position) - x).abs() <= 5.0); let cancel_drag = ui.input(|i| i.key_pressed(egui::Key::Escape)); - if cancel_drag || (marker_drag.is_some() && !resp.drag_stopped() && !ui.input(|i| i.pointer.any_down())) { + // A stop or marker drag also ends when no button is down and the ruler reports no release. + if cancel_drag || ((marker_drag.is_some() || drag.is_some()) && !resp.drag_stopped() && !ui.input(|i| i.pointer.any_down())) { set_pstate::>(ui.ctx(), "tabs-marker-drag", None); set_pstate::>(ui.ctx(), "tabs-drag", None); } @@ -728,6 +825,22 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { } } } + // While a stop is dragged, a guide through the selected text shows where it would land: the + // grabbed stop's place in a Ctrl-drag (Command on macOS), and none while a release would delete it. + let drag: Option = pstate(ui.ctx(), "tabs-drag"); + let drag_all = pstate::(ui.ctx(), "tabs-drag-all"); + let pointer = ui.input(|i| i.pointer.any_down().then(|| i.pointer.interact_pos()).flatten()); + let guide = drag.zip(pointer).filter(|(_, at)| at.y <= rect.bottom() + 20.0).and_then(|(i, at)| { + let position = if drag_all { moved_all(&stops, i, place(at.x))?.get(i)?.position } else { (i < stops.len()).then(|| place(at.x))? }; + let NodeKind::Text(text) = &node.kind else { return None }; + let frame = ui.ctx().cumulative_frame_nr_for(egui::ViewportId::ROOT); + Some(StopGuide { doc: app.session.active()?.uid, id: node.id, para: shown_paragraph(app, text), position, frame }) + }); + if guide.is_some() || pstate::>(ui.ctx(), "tabs-guide").is_some() { + // The canvas may be drawn before the panel in a frame: draw it again with the guide moved. + ui.ctx().request_repaint_of(egui::ViewportId::ROOT); + } + set_pstate(ui.ctx(), "tabs-guide", guide); resp.on_hover_text(tl!("Click to add a tab stop, drag to move it, drag it off the ruler to delete it")); } diff --git a/crates/ui-egui/src/panels/tabs/tests.rs b/crates/ui-egui/src/panels/tabs/tests.rs index e260db70ab..37d2a4d93d 100644 --- a/crates/ui-egui/src/panels/tabs/tests.rs +++ b/crates/ui-egui/src/panels/tabs/tests.rs @@ -1265,6 +1265,203 @@ fn escape_in_the_release_frame_cancels_a_stop_drag() { assert_eq!(positions(&app), [30.0, 70.0]); } +/// Press on the stop at `from` (points) and move to `to`, `below` px under the ruler, with +/// `modifiers` held, without letting go → where the pointer is. +fn hold_drag_on_ruler(ctx: &egui::Context, app: &mut VectorcraftApp, from: f64, to: f64, below: f32, modifiers: egui::Modifiers) -> egui::Pos2 { + let labels = ruler_frame(ctx, app, vec![], false); + let [(zero, a), (next, b), ..] = &labels[..] else { panic!("ruler labels {labels:?}") }; + assert_eq!(zero, "0"); + let per = next.parse::().unwrap() * app.session.general_unit().points(); + let x = |pt: f64| a.x - 2.0 + (pt / per) as f32 * (b.x - a.x); + let y = a.y + 15.0; + let held = egui::Event::ModifiersChanged(modifiers); + let press = egui::pos2(x(from), y); + let end = egui::pos2(x(to), y + below); + let button = egui::Event::PointerButton { pos: press, button: egui::PointerButton::Primary, pressed: true, modifiers }; + ruler_frame(ctx, app, vec![held.clone(), egui::Event::PointerMoved(press), button], false); + for f in [0.25, 0.5, 1.0] { + ruler_frame(ctx, app, vec![held.clone(), egui::Event::PointerMoved(press.lerp(end, f))], false); + } + end +} + +/// Let go at `at` with `modifiers` held, then draw one more frame. +fn release_on_ruler(ctx: &egui::Context, app: &mut VectorcraftApp, at: egui::Pos2, modifiers: egui::Modifiers) { + let button = egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: false, modifiers }; + ruler_frame(ctx, app, vec![egui::Event::ModifiersChanged(modifiers), button], false); + ruler_frame(ctx, app, vec![], false); +} + +/// Area type at (10, 20), 300 by 100 pt, with stops at `stops` points, and the app. +fn guide_app(stops: &[f64]) -> VectorcraftApp { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({})).unwrap(); + app.run("text.create", json!({"x": 10, "y": 20, "text": "a\tb\tc", "area": {"width": 300, "height": 100}})).unwrap(); + let stops: Vec<_> = stops.iter().map(|p| json!({"position": p})).collect(); + app.run("text.tabs.set", json!({"stops": stops})).unwrap(); + app +} + +fn near(a: Point, b: Point) -> bool { + (a - b).hypot() < 0.01 +} + +/// While a stop is dragged on the ruler, a guide crosses the selected area type at the place the +/// stop would land, measured from the frame's left edge, from the frame's top to its bottom. It +/// follows the pointer, adds nothing to the document or its undo history, and is gone after the +/// release, which moves the stop as before. +#[test] +fn dragging_a_stop_draws_a_guide_through_the_text() { + let mut app = guide_app(&[50.0]); + let ctx = egui::Context::default(); + ruler_frame(&ctx, &mut app, vec![], false); + assert_eq!(stop_guide(&app, &ctx), None, "before the drag"); + let frame = current(&app).unwrap().0.geometric_bounds().unwrap(); + let (before, layers) = (app.session.active().unwrap().history.undo.len(), app.session.active().unwrap().doc.layers.clone()); + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 0.0, egui::Modifiers::NONE); + let (a, b) = stop_guide(&app, &ctx).expect("a guide during the drag"); + assert!(near(a, Point::new(frame.x0 + 70.0, frame.y0)) && near(b, Point::new(frame.x0 + 70.0, frame.y1)), "{a:?} {b:?} in {frame:?}"); + let doc = app.session.active().unwrap(); + assert_eq!((doc.history.undo.len(), &doc.doc.layers), (before, &layers), "the guide is not part of the document"); + // The guide follows the pointer while the button stays down. + let held = egui::Event::ModifiersChanged(egui::Modifiers::NONE); + ruler_frame(&ctx, &mut app, vec![held, egui::Event::PointerMoved(end - vec2(20.0, 0.0))], false); + let (moved, _) = stop_guide(&app, &ctx).unwrap(); + assert!(moved.x < a.x - 1.0, "{moved:?} after {a:?}"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + assert_eq!(stop_guide(&app, &ctx), None, "after the release"); + assert_eq!(current(&app).unwrap().1.iter().map(|s| s.position).collect::>(), [70.0]); + assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1); +} + +/// When a text wrap object pushes the paragraph's lines right, the guide is measured from where the +/// first line starts, as the layout measures the stops, and a first-line indent does not move it. +#[test] +fn the_stop_guide_starts_where_a_wrap_object_lets_the_line_start() { + let mut app = guide_app(&[50.0]); + let text = current(&app).unwrap().0.id.0; + app.run("text.setFormat", json!({"firstLineIndent": 12})).unwrap(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 60, "height": 200})).unwrap(); + app.run("object.textWrap.make", json!({"offset": 0})).unwrap(); + app.run("select.set", json!({"ids": [text]})).unwrap(); + let ctx = egui::Context::default(); + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 0.0, egui::Modifiers::NONE); + let (a, b) = stop_guide(&app, &ctx).unwrap(); + assert!((a.x - 130.0).abs() < 0.01 && (b.x - 130.0).abs() < 0.01, "70 pt right of the wrap object's edge at 60: {a:?} {b:?}"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + // The tab after "a" ends at the stop: "b" starts 70 pt right of the wrap object's edge. + let NodeKind::Text(t) = ¤t(&app).unwrap().0.kind else { panic!("text") }; + let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t); + let b_at = lay.glyphs.iter().find(|g| t.plain_text().get(g.byte..).is_some_and(|s| s.starts_with('b'))).unwrap().origin.x; + assert!(((t.xf * Point::new(b_at, 0.0)).x - 130.0).abs() < 0.01, "b at {b_at}"); +} + +/// In a Ctrl-drag (Command on macOS) the guide follows the stop under the pointer, also when the +/// leftmost stop stops the drag at 0. +#[test] +fn a_command_drag_guide_follows_the_grabbed_stop() { + let mut app = guide_app(&[30.0, 50.0, 80.0]); + let ctx = egui::Context::default(); + let x0 = current(&app).unwrap().0.geometric_bounds().unwrap().x0; + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 0.0, egui::Modifiers::COMMAND); + let (a, _) = stop_guide(&app, &ctx).unwrap(); + assert!((a.x - (x0 + 70.0)).abs() < 0.01, "{a:?}"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::COMMAND); + assert_eq!(current(&app).unwrap().1.iter().map(|s| s.position).collect::>(), [50.0, 70.0, 100.0]); + // The stop grabbed at 70 pt can move 50 pt left before the stop at 50 pt reaches 0. + let end = hold_drag_on_ruler(&ctx, &mut app, 70.0, 5.0, 0.0, egui::Modifiers::COMMAND); + let (a, _) = stop_guide(&app, &ctx).unwrap(); + assert!((a.x - (x0 + 20.0)).abs() < 0.01, "{a:?}"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::COMMAND); + assert_eq!(stop_guide(&app, &ctx), None); +} + +/// No guide shows while a release would delete the stop, after Escape, after a release the ruler +/// did not see, or once the panel is no longer drawn. +#[test] +fn the_stop_guide_ends_with_the_drag() { + let mut app = guide_app(&[30.0, 50.0]); + let ctx = egui::Context::default(); + let positions = |app: &VectorcraftApp| current(app).unwrap().1.iter().map(|s| s.position).collect::>(); + // Off the ruler, where a release deletes the stop. + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 60.0, egui::Modifiers::NONE); + assert_eq!(stop_guide(&app, &ctx), None, "off the ruler"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + assert_eq!(positions(&app), [30.0]); + // Escape during the drag. + let end = hold_drag_on_ruler(&ctx, &mut app, 30.0, 60.0, 0.0, egui::Modifiers::NONE); + assert!(stop_guide(&app, &ctx).is_some()); + let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }; + ruler_frame(&ctx, &mut app, vec![escape], false); + ruler_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(end + vec2(5.0, 0.0))], false); + assert_eq!(stop_guide(&app, &ctx), None, "after Escape"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + assert_eq!(positions(&app), [30.0]); + // A drag whose release the ruler never got: the next frame without a button down ends it, so a + // later press elsewhere shows no guide and a later release moves nothing. + set_pstate(&ctx, "tabs-drag", Some(0usize)); + ruler_frame(&ctx, &mut app, vec![], false); + assert_eq!(pstate::>(&ctx, "tabs-drag"), None); + // A place in the panel right of its fields, above the ruler. + let ruler_y = ruler_frame(&ctx, &mut app, vec![], false)[0].1.y; + let away = egui::pos2(380.0, ruler_y - 30.0); + let press = egui::Event::PointerButton { pos: away, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE }; + ruler_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(away), press], false); + assert_eq!(stop_guide(&app, &ctx), None, "a press after a lost release"); + release_on_ruler(&ctx, &mut app, away, egui::Modifiers::NONE); + assert_eq!(positions(&app), [30.0]); + // The panel closed during a drag. + hold_drag_on_ruler(&ctx, &mut app, 30.0, 60.0, 0.0, egui::Modifiers::NONE); + assert!(stop_guide(&app, &ctx).is_some()); + for _ in 0..2 { + let mut out = ctx.run_ui(egui::RawInput::default(), |_| {}); + out.textures_delta.clear(); + } + assert_eq!(stop_guide(&app, &ctx), None, "the panel is no longer drawn"); +} + +/// The guide turns with rotated area type, and runs through point type from the type's origin +/// across its lines; in vertical type it runs across the columns. +#[test] +fn the_stop_guide_follows_rotated_point_and_vertical_type() { + let ctx = egui::Context::default(); + // Rotated area type: the guide is the frame's edge moved 70 pt along the frame's top. + let mut app = guide_app(&[50.0]); + app.run("object.rotate", json!({"angle": 30})).unwrap(); + let node = current(&app).unwrap().0; + let NodeKind::Text(t) = &node.kind else { panic!("text") }; + let TextKind::Area { frame } = &t.kind else { panic!("area type") }; + let local = frame.bounds().unwrap(); + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 0.0, egui::Modifiers::NONE); + let (a, b) = stop_guide(&app, &ctx).unwrap(); + let (ea, eb) = (t.xf * Point::new(local.x0 + 70.0, local.y0), t.xf * Point::new(local.x0 + 70.0, local.y1)); + assert!(near(a, ea) && near(b, eb), "{a:?} {b:?}, expected {ea:?} {eb:?}"); + assert!((a.x - b.x).abs() > 10.0, "not upright: {a:?} {b:?}"); + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + // Point type with its origin at (10, 20): the guide is upright at 10 + 70 and crosses the baseline. + for vertical in [false, true] { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({})).unwrap(); + app.run("text.create", json!({"x": 10, "y": 20, "text": "a\tb", "vertical": vertical})).unwrap(); + app.run("text.tabs.set", json!({"stops": [{"position": 50}]})).unwrap(); + let ctx = egui::Context::default(); + let end = hold_drag_on_ruler(&ctx, &mut app, 50.0, 70.0, 0.0, egui::Modifiers::NONE); + let (a, b) = stop_guide(&app, &ctx).unwrap_or_else(|| panic!("a guide, vertical {vertical}")); + let NodeKind::Text(t) = ¤t(&app).unwrap().0.kind else { panic!("text") }; + let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t); + let at = t.xf * lay.physical_point(Point::new(70.0, 0.0)); + if vertical { + assert!((a.y - at.y).abs() < 0.01 && (b.y - at.y).abs() < 0.01, "across the column: {a:?} {b:?}, {at:?}"); + assert!((a.x - b.x).abs() > 1.0, "{a:?} {b:?}"); + } else { + assert!((a.x - 80.0).abs() < 0.01 && (b.x - 80.0).abs() < 0.01, "{a:?} {b:?}"); + assert!(a.y < 19.0 && b.y > 20.0, "across the baseline: {a:?} {b:?}"); + } + release_on_ruler(&ctx, &mut app, end, egui::Modifiers::NONE); + assert_eq!(stop_guide(&app, &ctx), None); + } +} + /// A stop placed by a click on the ruler or dragged on it lands on the nearest whole point, and /// the moved stop stays selected. A position typed in the X field keeps its hundredths of a point. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f506da06e1..9118f54e08 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -753,6 +753,7 @@ since 2026-10-01. - **Names of new styles and symbols:** `charStyle.new` and `paraStyle.new` trim the white space around the name they are given, as `charStyle.rename` and `paraStyle.rename` do, and refuse a name that is then empty; Duplicate names its copy from the trimmed name. `symbol.new` and `symbol.duplicate` trim the name as Symbol Options does, and `library.use` adds a library's text style under its trimmed name. Public reference: [Character and paragraph styles](https://web.archive.org/web/20260825113735/https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html). - **Naming a new text style first:** Alt-click on New in the Character Styles or Paragraph Styles panel opens New Character Style or New Paragraph Style (`ui.newCharStyle`, `ui.newParaStyle`) with the name a plain click's style gets; OK makes the style from the text selected when the dialog opened, and Cancel adds none. Tests `panels::text_styles::tests::alt_clicking_new_character_style_asks_for_its_name` and `alt_clicking_new_paragraph_style_asks_for_its_name`. Public reference: [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), which lists Alt-click for opening panel options and names Actions, Brushes, Swatches and Symbols as exceptions. - **Moving all tab stops:** in the Tabs panel, a stop dragged on the ruler with Ctrl held (Command on macOS) moves every stop by the same distance, in one `text.tabs.set` and one undo step; the stops keep their order, alignment and leaders, the ruler shows them moving during the drag, and a drag that would take the leftmost stop below 0 leaves it at 0, or the rightmost past 100,000 pt leaves it at 100,000 pt, with the other stops at their spacing from it. A drag that leaves every stop where it was records no undo step. Ctrl must be held when the drag starts. Tests `panels::tabs::tests::command_drag_moves_all_the_stops_together`, `command_drag_stops_at_zero_and_keeps_the_spacing`, `command_drag_stops_at_the_largest_position_and_keeps_the_spacing` and `a_drag_that_moves_no_stop_records_no_undo_step`. Public reference: [Manage tab stops](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/manage-tab-stops.html), which says that a Ctrl-drag (Windows) or Command-drag (macOS) of a tab moves all the tab stops at the same time. +- **Tab stop drag guide:** while a stop is dragged on the Tabs panel's ruler, the canvas draws a line through the text whose stops the ruler shows, where the stop would land: across the frame cell the paragraph starts in for area type, measured from where the frame lets the paragraph's first line start (the cell's edge inside the inset, or past a text wrap object), and across the paragraph's lines from the type's origin for point type. It turns with rotated type and runs across the columns of vertical type. In a Ctrl-drag (Command on macOS) it follows the grabbed stop. No line is drawn while a release would delete the stop, and the line goes on release, on Escape, when no button is down, and when the panel is closed. It is not a document object and records no undo step. Its extent, color and these rules are VectorCraft's own. A stop drag whose release the ruler does not get also ends then, as a marker drag already did. Tests `panels::tabs::tests::dragging_a_stop_draws_a_guide_through_the_text`, `a_command_drag_guide_follows_the_grabbed_stop`, `the_stop_guide_ends_with_the_drag`, `the_stop_guide_follows_rotated_point_and_vertical_type` and `the_stop_guide_starts_where_a_wrap_object_lets_the_line_start`. Public reference: [Manage tab stops](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/manage-tab-stops.html), which describes a guide shown through the selected text during a tab stop move. - **Tabs indent markers on threaded frames:** when a marker drag gives the paragraphs of a threaded story values of their own, the Tabs panel sends one `text.setFormat {paragraphIndents}` with an entry for each paragraph of the story, whatever order the frames were selected in with the Selection tool, so the story flows through its frames again once rather than once for each paragraph, and a drag that changes no paragraph runs nothing; a paragraph that runs on from one frame into the next gets one entry, after Type tool Select All too. A selected story is one text: with the Selection tool, a marker drag on any of its frames sets every paragraph of the story, in its locked and hidden frames too. Tests `panels::tabs::tests::indent_markers_on_selected_threaded_frames_follow_the_story_and_set_a_split_paragraph_once`, `indent_markers_over_many_threaded_paragraphs_send_one_format_command`, `indent_markers_after_select_all_list_a_split_paragraph_once`, `indent_markers_on_some_threaded_frames_list_the_whole_story_once`, `indent_markers_on_one_threaded_frame_set_its_locked_and_hidden_frames`, `cmd::threads::tests::paragraph_indents_flow_a_threaded_story_once_as_one_command_per_paragraph_would`, `paragraph_indents_over_thousands_of_paragraphs_flow_the_story_once` and `paragraph_indents_check_every_entry_and_skip_a_change_that_changes_nothing`, and `cmd::typecmd::area_tests::set_format_refuses_a_param_of_the_wrong_type`. Public reference: [Indent text](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/indent-text.html). - **Width Point Edit:** Shift-double-click enables Adjust Adjoining Width Points; plain double-click and direct opening retain the default. Tool dispatch and headless dialog tests cover neighboring widths, Undo/Redo and Cancel. Public reference: [Variable-width strokes](https://helpx.adobe.com/illustrator/using/stroke-object.html). Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a feature lands.