diff --git a/crates/ui-egui/src/panels/tabs.rs b/crates/ui-egui/src/panels/tabs.rs index 49f8329d2..2a9069d5c 100644 --- a/crates/ui-egui/src/panels/tabs.rs +++ b/crates/ui-egui/src/panels/tabs.rs @@ -253,16 +253,20 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { ui.add_enabled(false, egui::Button::new(tl!("Select text")).frame(false)); return; }; - let sel: usize = pstate(ui.ctx(), "tabs-sel"); - if menu_item(ui, tl!("Clear All Tabs"), false, !stops.is_empty()) { - apply(app, &[]); + // Clamp the selection to the last stop, as `show` does for the ruler. + let mut sel: usize = pstate(ui.ctx(), "tabs-sel"); + if sel >= stops.len() { + sel = stops.len().saturating_sub(1); } - if menu_item(ui, tl!("Delete Tab"), false, sel < stops.len()) { + if menu_item(ui, tl!("Clear All Tabs"), !stops.is_empty(), false) { + super::paragraph::run_on_paragraphs(app, "text.tabs.clear", json!({})).ok(); + } + if menu_item(ui, tl!("Delete Tab"), sel < stops.len(), false) { stops.remove(sel); apply(app, &stops); } // Repeat Tab: copies of the selected stop at its distance from the previous one, across the ruler. - if menu_item(ui, tl!("Repeat Tab"), false, sel < stops.len()) { + if menu_item(ui, tl!("Repeat Tab"), sel < stops.len(), false) { let prev = if sel == 0 { 0.0 } else { stops[sel - 1].position }; let step = (stops[sel].position - prev).max(1.0); let base = stops[sel].clone(); @@ -409,6 +413,76 @@ mod tests { assert!((moved_to - end.x).abs() < 1.0, "stop at {moved_to}, released at {}", end.x); } + /// One frame of the panel menu with `events` → the rows' texts and where they are painted. + fn menu_frame(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec) -> Vec<(String, egui::Rect)> { + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0)); + let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), events, ..Default::default() }, |ui| menu(app, ui)); + out.textures_delta.clear(); + out.shapes + .iter() + .filter_map(|c| match &c.shape { + egui::Shape::Text(t) => Some((t.galley.text().to_string(), t.visual_bounding_rect())), + _ => None, + }) + .collect() + } + + /// Click the panel menu's row `label`, which shows no check mark. + fn choose(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str) { + let rows = menu_frame(ctx, app, vec![]); + let (text, r) = rows.iter().find(|(t, _)| t.trim_start_matches(['✓', ' ']) == label).unwrap_or_else(|| panic!("{label} in {rows:?}")); + assert!(!text.contains('✓'), "{label} shows a check mark"); + let at = r.center(); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + menu_frame(ctx, app, vec![egui::Event::PointerMoved(at), button(true)]); + menu_frame(ctx, app, vec![button(false)]); + } + + /// The panel menu's Repeat Tab, Delete Tab and Clear All Tabs can be chosen while the text has + /// tab stops and show no check mark. Repeat Tab and Delete Tab act on the stop selected on the + /// ruler, and Clear All Tabs removes every stop. + #[test] + fn panel_menu_repeats_deletes_and_clears_tab_stops() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({})).unwrap(); + app.session.execute("text.create", &json!({"x": 10, "y": 20, "text": "a b", "area": {"width": 300, "height": 100}})).unwrap(); + app.session.execute("text.tabs.set", &json!({"stops": [{"position": 30}, {"position": 50, "leader": "."}]})).unwrap(); + let ctx = egui::Context::default(); + let positions = |app: &VectorcraftApp| current(app).unwrap().1.iter().map(|s| s.position).collect::>(); + // Repeat Tab with the second stop selected: 20 copies of it, 20 pt apart (its distance from + // the first stop), leader and all. + set_pstate(&ctx, "tabs-sel", 1usize); + choose(&ctx, &mut app, "Repeat Tab"); + let repeated = positions(&app); + assert_eq!((repeated.len(), &repeated[..4]), (22, &[30.0, 50.0, 70.0, 90.0][..])); + assert!(current(&app).unwrap().1[2..].iter().all(|s| s.leader == ".")); + // Delete Tab removes the selected stop. + choose(&ctx, &mut app, "Delete Tab"); + assert_eq!(positions(&app)[..3], [30.0, 70.0, 90.0]); + // Clear All Tabs removes every stop, in one undo step of its own name. + choose(&ctx, &mut app, "Clear All Tabs"); + assert!(positions(&app).is_empty()); + assert_eq!(app.session.active().unwrap().history.undo.last().unwrap().label, "Clear All Tabs"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(positions(&app).len(), 21); + } + + /// After Delete Tab removes the last stop, the ruler shows the stop before it selected, and + /// Delete Tab removes that one next. + #[test] + fn delete_tab_after_the_last_stop_deletes_the_stop_the_ruler_shows_selected() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({})).unwrap(); + app.session.execute("text.create", &json!({"x": 10, "y": 20, "text": "a b", "area": {"width": 300, "height": 100}})).unwrap(); + app.session.execute("text.tabs.set", &json!({"stops": [{"position": 30}, {"position": 50}]})).unwrap(); + let ctx = egui::Context::default(); + set_pstate(&ctx, "tabs-sel", 1usize); + choose(&ctx, &mut app, "Delete Tab"); + assert_eq!(current(&app).unwrap().1.len(), 1); + choose(&ctx, &mut app, "Delete Tab"); + assert!(current(&app).unwrap().1.is_empty()); + } + /// Position Panel Above Text floats the panel over the text, its ruler's 0 on the frame's left /// edge and a stop's mark over the column it sets, at any zoom (#729). #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 306d36407..ba749e204 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -617,6 +617,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur The frames of threaded text share one Optical Margin Alignment setting: turning it on or off in one frame sets it in every frame, threading frames gives the thread its first frame's setting, and frames taken out of a thread keep it. Type › Optical Margin Alignment (`type.opticalMarginAlignment`) hangs the punctuation and letter edges at the ends of a type object's lines outside its margins: at the left of left-aligned lines, at the right of right-aligned lines, and at both ends of centered and justified lines, in point and area type of left-to-right paragraphs. Quotation marks, hyphens, full stops and commas hang wholly; asterisks, tildes, ellipses, en and em dashes, colons and semicolons hang by half; and A, V, W, Y, v, w and y hang by a tenth of their width. It is off by default and saved with the type object. The Paragraph panel menu's Hyphenation… (`ui.hyphenation`, `text.setFormat {wordsLongerThan, afterFirst, beforeLast, hyphenLimit, hyphenationZone, hyphenateCapitalized}`) sets each paragraph's hyphenation limits: the shortest word that breaks, the fewest letters on each side of the hyphen, the most hyphenated lines in a row, a zone at the right edge where the Single-line Composer breaks before a word instead of hyphenating it, and whether capitalized words break. The defaults are words longer than 5 letters, 3 letters on each side, no limit or zone, and capitalized words hyphenated; paragraph styles and the native file keep the options. + The Tabs panel menu's Clear All Tabs (`text.tabs.clear`), Delete Tab and Repeat Tab (`text.tabs.set`) can be chosen while the panel's ruler shows tab stops. Delete Tab removes the stop selected on the ruler. Repeat Tab replaces the stops after the selected stop with up to 20 copies of it. The copies are spaced by the selected stop's distance from the stop before it (or from the ruler's 0), and no copy is placed at 2,000 pt or beyond. Clear All Tabs removes every stop, so the default stops every ½ inch apply again. - **Interface languages, vertical type:** Preferences ▸ User Interface (or VectorCraft ▸ Language on macOS) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, German (every `de-*` locale), Spanish (neutral international Spanish, for every `es-*` locale), French (every `fr-*` locale), Italian (every `it-*` locale) Russian (every `ru-*` locale) and Ukrainian (every `uk-*` locale) cover the whole interface, Czech every menu label; Czech, German, Greek, Spanish, French, Hungarian, Italian, Japanese, Korean, Vietnamese, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Swedish, Ukrainian and Finnish also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, German, Spanish, French, Italian, Russian and Ukrainian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line); kinsoku applies to horizontal and vertical Japanese (Paragraph panel › Kinsoku Set, `text.setFormat {kinsoku}`: Hard, the default, keeps closing marks, iteration marks, the prolonged sound mark and small kana off the line start and opening brackets off its end; Soft lets 々, ー and small kana start a line as JLREQ's level 3 rules do; None turns it off), and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a line flush with its start (a paragraph's first line at its first-line indent, JIS X 4051's principle in JLREQ 3.1.5), and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline (new type in a Japanese interface starts top to top, with em box centre character alignment, #432); Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline, the em box top/right, centre or bottom/left, or the ICF (ideographic character face) top/right or bottom/left, from the font's BASE table or, without one, the average ink box of some ideographs and kana; Proportional Metrics (the same menu; `{proportionalMetrics}`) sets full-width glyphs on the font's proportional widths (OpenType `palt`) in horizontal type and upright glyphs on its proportional heights (`vpal`, shaped top to bottom; fonts without vertical metrics keep their cells) in vertical type, and Line-end Punctuation Half Width takes nothing more off the punctuation they re-spaced; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. The interface is available in Polish (`pl`): menus, panels, dialogs and messages, with one/few/many plurals; AI-drafted, native review pending (#1498). - **Transparency:** opacity masks (clip/invert/disable/link), exported as SVG `` and PDF soft masks. The constant alpha soft mask that PDF and `.ai` export draw a CMYK page with transparency through is white, so applications that read every soft mask by its luminosity show the page too (#1359, part of #1286). Disable, Enable, Unlink and Link Opacity Mask and Opacity Mask Options (`transparency.setOpacityMask`) record no undo step when every mask they act on already has the flags they set.