From efd476cbc71365976070fb53797870fa0b066fac Mon Sep 17 00:00:00 2001 From: RatkoR Date: Sun, 8 Nov 2026 04:51:18 +0100 Subject: [PATCH] #5197: the ruler shows the spaces between text columns (#5261) In a section of several text columns the horizontal ruler was one white strip from margin to margin. The space between each two columns is now shaded like the margins, so the ruler shows where each column ends and the next starts. The edges of a space can be dragged, through layout.columns, one undo step per drag, to change the spacing. Equal columns stay equal, so every space changes with it, as in Word for Mac. Between unequal columns only the column at that edge and the space change. As in Word for Mac, the middle of a space has no grip of its own. Columns stay at least a quarter inch wide and spaces 0-300 pt, as the Columns dialog allows, snapped to 1/16 inch. Right-to-left sections are read from the right edge. Outside the main text, outside Print Layout and in a table the ruler is unchanged. A selection across sections shows no spaces, since a drag would set the columns of each section it touches; nor does a page the caret isn't on. Columns from a file that the command wouldn't take back (over 12, a column under a quarter inch, a space over 300 pt, wider than the text) are shaded but not dragged. A tab stop's marker keeps its own drag where it sits on an edge. The indent markers still follow the page rather than the caret's column; that is #2196 (PR #2215). Fixes #5197. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Martin Ball --- ROADMAP.md | 2 + crates/ui-egui/src/canvas.rs | 1 + crates/ui-egui/src/canvas/column_ruler.rs | 343 ++++++++++++++++++++++ crates/ui-egui/src/canvas/rulers.rs | 10 + docs/gaps.md | 2 + docs/ui-parity.md | 4 +- 6 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/canvas/column_ruler.rs diff --git a/ROADMAP.md b/ROADMAP.md index 7bff0e3c34..3e49fab3a5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -365,6 +365,7 @@ Imported Word 97–2003 `.doc`/`.dot` files now ask for a supported DOCX target | 2026-10-29 | Insert › Shapes shows the basic shapes as a grid of code-drawn icon tiles, each with an accessible name and tooltip, instead of a text list (#4349) | | 2026-11-03 | A password-protected file named on the command line (double-clicked in the file manager) asks for its password when the first blank document was replaced because File › Options chose a region; the window now follows that replacement at once, so the first frame no longer takes it for a document switch and drops the Password box (#5299) | | 2026-11-01 | Markdown export: a list inside a block quote stays in the quote (`> - item`), its continuation lines included; it was read as quoted list paragraphs but written without `>`, so the list moved out of the quote on every save | +| 2026-11-01 | Rulers: in a section of several text columns the horizontal ruler shades the space between each two columns like the margins (Print Layout, in the main text outside tables, with the selection in one section); dragging an edge of a space changes the spacing (equal columns stay equal, as in Word for Mac), one undo step per drag (#5197) | | 2026-10-29 | Window sizing falls back to the screen rectangle when the reported inner size is invalid, and an Equation symbol tooltip no longer repeats a missing glyph's name or code point | | 2026-10-29 | A NUL in a document title no longer reaches the native window title, which panicked on X11 (#3634): displayed titles and suggested file names drop NUL characters and fall back to the untitled name when empty; the stored title is unchanged | | 2026-10-28 | The Traditional Chinese interface draws hanzi to the Taiwan standard: on the desktop an installed Traditional Chinese font (PingFang TC on macOS, Microsoft JhengHei on Windows, Noto Sans CJK TC on Linux) comes before the embedded Noto Sans CJK SC, which drew 說, 這, 為, 戶 in mainland shapes; without one, and on the web, nothing changes. | @@ -944,6 +945,7 @@ MATH glyphs that reference the same construction now share its immutable variant | 2026-10-28 | trivial | Note conversion walks reference offsets and formatting runs together, #4750; readiness estimates unchanged. | | 2026-10-29 | trivial | DOCX comment IDs use ordered paragraph lookup and one durable-ID reservation set; threading and ID rules unchanged | | 2026-10-28 | trivial | #4658: bound Markdown reference-label rejection work, preserving literal source and ordinary link matching | +| 2026-11-01 | trivial | Progress log: the ruler shows the spaces between text columns (#5197) | | 2026-10-29 | trivial | Progress log: Insert › Shapes icon grid (#4349) | | 2026-10-29 | trivial | HTML import keeps preformatted lines with CR, CRLF or LF input newlines (#4810); numeric character references retain their separate meaning; readiness estimates unchanged. | | 2026-10-29 | trivial | Progress log: window fallback geometry and equation symbol tooltips | diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index c3ed1a1db9..92aa25890b 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -15,6 +15,7 @@ use crate::WordApp; use crate::theme::{Tokens, regular, semibold}; mod balloons; +mod column_ruler; mod context_menu; #[cfg(test)] pub(crate) use context_menu::issue_heading; diff --git a/crates/ui-egui/src/canvas/column_ruler.rs b/crates/ui-egui/src/canvas/column_ruler.rs new file mode 100644 index 0000000000..76e35a2636 --- /dev/null +++ b/crates/ui-egui/src/canvas/column_ruler.rs @@ -0,0 +1,343 @@ +//! The caret section's text columns on the horizontal ruler (#5197): the space between each two +//! columns is shaded like the margins, and its edges are dragged to change the columns' widths +//! and spacing, through `layout.columns`. As in Word for Mac, the space has no grip of its own +//! in the middle: only its edges drag. + +use serde_json::Value; +use wordcraft_doc::section::SectionProps; +use wordcraft_doc::{Pos, StoryRef}; + +use super::{DocLayout, Rect, Sense, Tokens, Ui, WordApp, json, pos2}; + +/// Which edge of the space between two columns a drag grabs, in reading order: the end of the +/// column before it or the start of the column after it. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub(crate) enum GapGrip { + End, + Start, +} + +/// The narrowest column a drag leaves: a quarter inch, as the Columns dialog allows. +const MIN_COLUMN: f32 = 18.0; + +/// The widest space a drag leaves between two columns, as the Columns dialog allows. +const MAX_SPACE: f32 = 300.0; + +/// The caret section's columns on a page, for the ruler. +pub(super) struct ColumnGaps { + /// The caret's section. + sect: SectionProps, + /// The page x of the section's text area's left edge. + origin: f32, + /// Each space between two neighbouring columns in reading order: its (left, right) page x. + gaps: Vec<(f32, f32)>, +} + +/// The spaces between the caret section's columns on page `pi`: none outside the main text or +/// Print Layout (where text runs in one column), in a table (whose own markers take the ruler), +/// in a section of one column, for a selection across sections (a drag would set the columns of +/// each) or when the caret isn't on that page (the ruler stays put while the whole document is +/// selected). +pub(super) fn column_gaps(app: &WordApp, layout: &DocLayout, pi: usize) -> Option { + let sel = &app.session.sel; + if sel.focus.story != StoryRef::Body || sel.anchor.story != StoryRef::Body { + return None; + } + if app.session.view.mode != wordcraft_layout::ViewMode::Print || app.session.view.read_mode { + return None; + } + if sel.focus.path.cell().is_some() || crate::table_ruler::text_area(app, layout, pi).is_some() { + return None; + } + let doc = &app.session.doc; + let section = |p: &Pos| doc.section_index_of(p.path.0.first().copied().unwrap_or(0) as usize); + if section(&sel.anchor) != section(&sel.focus) { + return None; + } + if layout.caret_on(&sel.focus, pi).map(|c| c.page) != Some(pi) { + return None; + } + let sect = wordcraft_engine::cmd::page::sect(&app.session); + if sect.columns.count <= 1 { + return None; + } + let page = layout.pages.get(pi)?; + // A continuous section can change the margins on the page: its columns start at its own + // margin, moved as the page's text area is (on an even page of a mirrored layout, #2914). + let sections = app.session.doc.sections(); + let (_, page_sect) = sections.get(page.section)?; + let origin = page.body.x + sect.margin_left + sect.gutter - page_sect.margin_left - page_sect.gutter; + let gaps = gaps_of(§).into_iter().map(|(l, r)| (origin + l, origin + r)).collect(); + Some(ColumnGaps { sect, origin, gaps }) +} + +/// Each space between two neighbouring columns of `s` in reading order, as (left, right) points +/// from the text area's left edge. +fn gaps_of(s: &SectionProps) -> Vec<(f32, f32)> { + s.column_boxes() + .windows(2) + .filter_map(|w| match w { + // Leftwards in a right-to-left section. + [(ax, aw), (bx, bw)] => Some(if bx >= ax { (ax + aw, *bx) } else { (bx + bw, *ax) }), + _ => None, + }) + .collect() +} + +/// Shades the spaces between the columns on the ruler `bar`, over the white text area. +pub(super) fn draw(painter: &egui::Painter, cg: &ColumnGaps, bar: Rect, x0: f32, scale: f32, t: &Tokens) { + for (l, r) in &cg.gaps { + let (sl, sr) = (x0 + l * scale, x0 + r * scale); + if sr > sl { + painter.rect_filled(Rect::from_min_max(pos2(sl, bar.min.y), pos2(sr, bar.max.y)), 0.0, t.ruler_margin); + } + } +} + +/// The drag zones of the spaces between the columns: each of their edges, none over a tab +/// stop's marker (`tabs`), which keeps its own drag. Registered after the tab stops (whose +/// set-a-stop zone spans the text area) and before the indent markers, which keep the pointer +/// where they overlap. Columns the command wouldn't take back get no zones. +pub(super) fn handles(app: &mut WordApp, ui: &Ui, cg: &ColumnGaps, bar: Rect, x0: f32, scale: f32, tabs: &[Rect]) { + if !draggable(&cg.sect) { + return; + } + let rtl = cg.sect.rtl; + for (gap, (l, r)) in cg.gaps.iter().enumerate() { + let (sl, sr) = (x0 + l * scale, x0 + r * scale); + // Left to right, the space's left edge ends the column before it; right to left, it + // starts the column after it. + let (left, right) = if rtl { (GapGrip::Start, GapGrip::End) } else { (GapGrip::End, GapGrip::Start) }; + // A narrow space is split at its middle, so both edges can be grabbed. + let mid = (sl + sr) / 2.0; + let zones = [ + (left, Rect::from_min_max(pos2(sl - 3.0, bar.min.y), pos2((sl + 3.0).min(mid), bar.max.y))), + (right, Rect::from_min_max(pos2((sr - 3.0).max(mid), bar.min.y), pos2(sr + 3.0, bar.max.y))), + ]; + for (grip, zone) in zones { + if tabs.iter().any(|t| t.intersects(zone)) { + continue; + } + let r = + ui.interact(zone, ui.scope_id().with(("ruler_column", gap, grip)), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal); + let r = if r.dragged() { r } else { r.on_hover_text(tl!("Column Edge")) }; + if r.dragged() + && let Some(pp) = r.interact_pointer_pos() + { + let v = (pp.x - x0) / scale - cg.origin; + let at = if rtl { cg.sect.text_width() - v } else { v }; + let Some(params) = column_drag(&cg.sect, gap, grip, at) else { continue }; + if !r.drag_started() { + app.session.join_next_undo(); + } + let _ = app.run_keep_view("layout.columns", params); + } + } + } +} + +/// The `layout.columns` parameters after dragging `grip` of the space after column `gap` (in +/// reading order) to `at` points from the text area's start edge (its right edge in a +/// right-to-left section). Equal columns stay equal, so every space changes, as in Word for Mac; +/// between unequal columns only the column at that edge and the space change. Columns stay at +/// least a quarter inch wide and the space 0–300 pt, snapped to 1/16 inch. `None` when there is +/// no such space or `at` is junk. +pub(crate) fn column_drag(s: &SectionProps, gap: usize, grip: GapGrip, at: f32) -> Option { + let n = s.columns.count as usize; + if !at.is_finite() || !draggable(s) || gap + 1 >= n { + return None; + } + let tw = s.text_width(); + let sep = s.columns.separator; + if s.columns.widths.len() != n { + // Column k is w wide and starts at k·(w + space), w = (tw − (n − 1)·space) / n: solved + // for the space that puts the edge at `at`. + let (i, nf) = (gap as f32, n as f32); + let space = match grip { + GapGrip::End => ((i + 1.0) * tw - at * nf) / (nf - 1.0 - i), + _ => at * nf / (i + 1.0) - tw, + }; + let most = ((tw - MIN_COLUMN * nf) / (nf - 1.0)).clamp(0.0, MAX_SPACE); + // Snapped, and at the limit the last 1/16 inch below it. + let space = (space / 4.5).round() * 4.5; + let space = if space > most { (most / 4.5).floor() * 4.5 } else { space.max(0.0) }; + return Some(json!({"count": n, "space": space, "separator": sep, "apply": "section"})); + } + // Unequal columns: (width, space after) each. + let mut cols = s.columns.widths.clone(); + let start: f32 = cols.iter().take(gap).map(|(w, sp)| w + sp).sum(); + let (&(w0, sp), &(w1, sp1)) = (cols.get(gap)?, cols.get(gap + 1)?); + let at = (at / 4.5).round() * 4.5; + let (end0, start1, end1) = (start + w0, start + w0 + sp, start + w0 + sp + w1); + let (w0, sp, w1) = match grip { + GapGrip::End => { + // `max` and `min` rather than `clamp`, which panics on bounds from a hostile file. + let e = at.min(start1.max(start + MIN_COLUMN)).max((start + MIN_COLUMN).max(start1 - MAX_SPACE)); + (e - start, start1 - e, w1) + } + GapGrip::Start => { + let b = at.min((end1 - MIN_COLUMN).min(end0 + MAX_SPACE)).max(end0); + (w0, b - end0, end1 - b) + } + }; + if let Some(c) = cols.get_mut(gap) { + *c = (w0, sp); + } + if let Some(c) = cols.get_mut(gap + 1) { + *c = (w1, sp1); + } + Some(json!({"widths": cols.iter().map(|(w, sp)| [*w, *sp]).collect::>(), "separator": sep, "apply": "section"})) +} + +/// Whether `layout.columns` takes the section's columns back after a drag: 2–12 columns, unequal +/// ones each at least a quarter inch wide with 0–300 pt after it and no wider together than the +/// text. A file can hold others (up to 45 columns, any widths); their spaces are shown, not +/// dragged. +fn draggable(s: &SectionProps) -> bool { + let n = s.columns.count as usize; + let widths = &s.columns.widths; + if !(2..=12).contains(&n) { + return false; + } + if widths.len() != n { + return true; + } + // The last column has no space after it (the command drops one). + let space = |i: usize, sp: f32| if i + 1 == n { 0.0 } else { sp }; + let total: f32 = widths.iter().enumerate().map(|(i, (w, sp))| w + space(i, *sp)).sum(); + total <= s.text_width() + 1.0 && widths.iter().enumerate().all(|(i, (w, sp))| *w >= MIN_COLUMN && (0.0..=MAX_SPACE).contains(&space(i, *sp))) +} + +#[cfg(test)] +mod tests { + use super::*; + use wordcraft_doc::section::Columns; + + /// Letter paper with inch margins: 468 pt of text. + fn letter(columns: Columns) -> SectionProps { + SectionProps { page_w: 612.0, page_h: 792.0, margin_left: 72.0, margin_right: 72.0, gutter: 0.0, columns, ..Default::default() } + } + + fn equal(count: u32, space: f32) -> SectionProps { + letter(Columns { count, space, ..Default::default() }) + } + + fn widths(v: &Value) -> Vec<(f32, f32)> { + v["widths"].as_array().into_iter().flatten().map(|c| (c[0].as_f64().unwrap_or(0.0) as f32, c[1].as_f64().unwrap_or(0.0) as f32)).collect() + } + + /// #5197: two equal columns half an inch apart leave a space from 216 to 252 pt. + #[test] + fn the_spaces_between_columns_are_where_the_columns_are_not() { + assert_eq!(gaps_of(&equal(2, 36.0)), vec![(216.0, 252.0)]); + assert_eq!(gaps_of(&equal(3, 36.0)), vec![(132.0, 168.0), (300.0, 336.0)]); + assert!(gaps_of(&equal(1, 36.0)).is_empty(), "one column, no space"); + // Right to left, the first column is on the right: the same spaces, read leftwards. + let rtl = SectionProps { rtl: true, ..equal(3, 36.0) }; + assert_eq!(gaps_of(&rtl), vec![(300.0, 336.0), (132.0, 168.0)]); + let unequal = letter(Columns { count: 2, space: 18.0, widths: vec![(100.0, 18.0), (350.0, 0.0)], ..Default::default() }); + assert_eq!(gaps_of(&unequal), vec![(100.0, 118.0)]); + } + + /// #5197: dragging an edge of the space between equal columns keeps them equal and changes + /// the spacing, so the dragged edge lands at the pointer. + #[test] + fn dragging_an_edge_between_equal_columns_changes_the_spacing() { + let s = equal(2, 36.0); + // The first column's end, from 216 to 207: 9 pt more space each side, 18 in all. + let v = column_drag(&s, 0, GapGrip::End, 207.0).unwrap_or_default(); + assert_eq!(v, json!({"count": 2, "space": 54.0, "separator": false, "apply": "section"})); + // The second column's start, from 252 to 261: the same. + assert_eq!(column_drag(&s, 0, GapGrip::Start, 261.0).unwrap_or_default()["space"], 54.0); + // Past the middle the space closes; it never goes negative. + assert_eq!(column_drag(&s, 0, GapGrip::End, 400.0).unwrap_or_default()["space"], 0.0); + // At most 300 pt: 297, the last 1/16 inch below it. + assert_eq!(column_drag(&s, 0, GapGrip::End, 0.0).unwrap_or_default()["space"], 297.0); + // And it never leaves a column narrower than a quarter inch. + let narrow = equal(12, 0.0); + let most = (468.0 - 18.0 * 12.0) / 11.0; + let space = column_drag(&narrow, 0, GapGrip::End, 0.0).unwrap_or_default()["space"].as_f64().unwrap_or(0.0) as f32; + assert!(space <= most, "{space} leaves every column a quarter inch ({most})"); + assert_eq!(space % 4.5, 0.0, "{space} is on the 1/16 inch grid at the limit too"); + // Three columns: the second space's start edge, from 336 to 345. + let s = equal(3, 36.0); + assert_eq!(column_drag(&s, 1, GapGrip::Start, 345.0).unwrap_or_default()["space"], 49.5); + } + + /// #5197: between unequal columns only the column at the dragged edge and the space change. + #[test] + fn dragging_between_unequal_columns_changes_its_neighbours() { + let s = letter(Columns { count: 3, space: 18.0, widths: vec![(100.0, 18.0), (200.0, 18.0), (132.0, 0.0)], ..Default::default() }); + // The first column's end, 100 → 90: it narrows and the space after it widens. + assert_eq!(widths(&column_drag(&s, 0, GapGrip::End, 90.0).unwrap_or_default()), vec![(90.0, 28.0), (200.0, 18.0), (132.0, 0.0)]); + // The third column's start, 336 → 300, back into the second column: it stops at the + // second column's end (318), the space closes and the third column takes it. + assert_eq!(widths(&column_drag(&s, 1, GapGrip::Start, 300.0).unwrap_or_default()), vec![(100.0, 18.0), (200.0, 0.0), (150.0, 0.0)]); + // The second column's start, 118 → 1000: the column never gets narrower than a quarter + // inch. + assert_eq!(widths(&column_drag(&s, 0, GapGrip::Start, 1000.0).unwrap_or_default()), vec![(100.0, 200.0), (18.0, 18.0), (132.0, 0.0)]); + } + + /// Junk positions and spaces that aren't there change nothing. + #[test] + fn column_drags_ignore_junk() { + let s = equal(2, 36.0); + assert!(column_drag(&s, 0, GapGrip::End, f32::NAN).is_none()); + assert!(column_drag(&s, 1, GapGrip::End, 100.0).is_none(), "two columns have one space"); + assert!(column_drag(&equal(1, 36.0), 0, GapGrip::Start, 100.0).is_none()); + assert!(column_drag(&equal(13, 0.0), 0, GapGrip::End, 10.0).is_none(), "more columns than the command takes"); + // Unequal widths from a file that the command wouldn't take back aren't dragged. + let narrow = letter(Columns { count: 2, widths: vec![(5.0, 0.0), (463.0, 0.0)], ..Default::default() }); + assert!(column_drag(&narrow, 0, GapGrip::End, 30.0).is_none(), "a column under a quarter inch"); + let wide = letter(Columns { count: 2, widths: vec![(100.0, 400.0), (50.0, 0.0)], ..Default::default() }); + assert!(column_drag(&wide, 0, GapGrip::End, 90.0).is_none(), "a space over 300 pt"); + let over = letter(Columns { count: 2, widths: vec![(300.0, 18.0), (300.0, 0.0)], ..Default::default() }); + assert!(column_drag(&over, 0, GapGrip::End, 290.0).is_none(), "wider than the text"); + let last = letter(Columns { count: 2, widths: vec![(200.0, 18.0), (250.0, 999.0)], ..Default::default() }); + assert!(column_drag(&last, 0, GapGrip::End, 190.0).is_some(), "the last column's space after it doesn't count"); + } + + /// Through the command: a drag's result is applied to the caret's section, keeps the line + /// between columns, and is one undo step. + #[test] + fn a_column_drag_sets_the_sections_columns() { + let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("one two three")), Default::default()); + app.run("layout.columns", json!({"count": 2, "separator": true})).unwrap(); + let before = wordcraft_engine::cmd::page::sect(&app.session); + // The first column's end, 9 pt to the left: 18 pt more space, the columns still equal. + let end = before.column_boxes()[0].0 + before.column_boxes()[0].1; + let params = column_drag(&before, 0, GapGrip::End, end - 9.0).unwrap(); + app.run("layout.columns", params).unwrap(); + let after = wordcraft_engine::cmd::page::sect(&app.session); + assert_eq!(after.columns.count, 2); + assert!(after.columns.widths.is_empty(), "the columns stay equal"); + assert_eq!(after.columns.space, before.columns.space + 18.0); + assert!(after.columns.separator, "the line between the columns stays"); + let boxes = after.column_boxes(); + assert!((boxes[0].1 - (end - 9.0)).abs() < 0.01, "the edge is at the pointer: {boxes:?}"); + let laid = app.session.layout(); + let page = laid.pages.first().unwrap(); + let cg = column_gaps(&app, &laid, 0).unwrap(); + assert_eq!(cg.gaps.len(), 1); + assert!((cg.gaps[0].0 - (page.body.x + boxes[0].1)).abs() < 0.01, "the ruler's space starts where the first column ends"); + assert!(app.session.undo()); + assert_eq!(wordcraft_engine::cmd::page::sect(&app.session).columns, before.columns); + } + + /// A drag sets the columns of every section the selection touches, so a selection across + /// sections gets no spaces on the ruler; nor does a page the caret isn't on. + #[test] + fn no_column_spaces_for_a_selection_across_sections_or_another_page() { + let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("one\ntwo")), Default::default()); + app.run("caret.docEnd", json!({})).unwrap(); + app.run("layout.break", json!({"kind": "nextPage"})).unwrap(); + app.run("layout.columns", json!({"count": 2, "apply": "section"})).unwrap(); + let laid = app.session.layout(); + assert_eq!(laid.pages.len(), 2); + assert!(column_gaps(&app, &laid, 1).is_some(), "the caret's page shows the second section's columns"); + assert!(column_gaps(&app, &laid, 0).is_none(), "the first page has one column"); + app.run("select.all", json!({})).unwrap(); + let laid = app.session.layout(); + assert!(column_gaps(&app, &laid, 1).is_none(), "the selection runs into a section of one column"); + } +} diff --git a/crates/ui-egui/src/canvas/rulers.rs b/crates/ui-egui/src/canvas/rulers.rs index 0362bbee81..86f5d89e72 100644 --- a/crates/ui-egui/src/canvas/rulers.rs +++ b/crates/ui-egui/src/canvas/rulers.rs @@ -24,6 +24,11 @@ pub(super) fn rulers(app: &mut WordApp, ui: &mut Ui, h: Rect, v: Rect, rects: &[ hp.rect_filled(bar, 0.0, t.ruler_margin); let text = Rect::from_min_max(pos2(x0 + page.body.x * scale, bar.min.y), pos2(x0 + page.body.right() * scale, bar.max.y)); hp.rect_filled(text, 0.0, t.ruler); + // The spaces between the caret section's text columns, shaded like the margins (#5197). + let columns = super::column_ruler::column_gaps(app, layout, pi); + if let Some(cg) = &columns { + super::column_ruler::draw(&hp, cg, bar, x0, scale, &t); + } let rp = app.session.doc.para_at(&app.session.sel.focus).map(|para| app.session.doc.styles.resolve_para(¶.props)); // Graduations in the File › Options unit. let (unit, div, step) = ruler_scale(app.session.units()); @@ -101,6 +106,11 @@ pub(super) fn rulers(app: &mut WordApp, ui: &mut Ui, h: Rect, v: Rect, rects: &[ // spans the text area, so a border marker keeps its drag) and before the indent markers, // which keep the pointer where they overlap. crate::table_ruler::columns(app, ui, layout, pi, bar, x0, scale); + // Outside a table, the spaces between the text columns, in the same order (#5197). + if let Some(cg) = &columns { + let tabs = crate::ruler_tabs::marker_rects(app, bar, &px, &rp.tabs); + super::column_ruler::handles(app, ui, cg, bar, x0, scale, &tabs); + } // Dragging the left-indent marker. let id = ui.scope_id().with("ruler_left"); let mr = Rect::from_center_size(pos2(left, bar.max.y - 3.0), vec2(12.0, 12.0)); diff --git a/docs/gaps.md b/docs/gaps.md index 7527aa05d3..6bef0c7165 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -217,6 +217,8 @@ Page Setup's margin, paper-size and document-grid number boxes scroll long text | 2026-10-31 | trivial | Pagination gap #4: a float anchored right after a page break inside a paragraph, before text, is drawn on the new page (#4262) | | 2026-10-31 | trivial | Pagination gap #4: a float anchored on a later page of a long paragraph is drawn on that page, also when footnotes or widow control move its line on (#4250) | | 2026-10-28 | trivial | Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged. | +| 2026-11-02 | trivial | In Print Layout the horizontal ruler shades the spaces between the caret section's text columns, and their edges drag the spacing (#5197); no ranked gap changed; readiness estimates unchanged | +| 2026-11-01 | trivial | Arrowheads keep their kind, width and length (DrawingML `a:headEnd`/`a:tailEnd` `type`/`w`/`len`, VML `startarrow`/`endarrow` with `…arrowwidth`/`…arrowlength`), read and written back, and are drawn 2, 3 or 5 times the line's width long and wide (small, medium, large), a line under 2 points as a 2-point one, as measured in Word for Windows; every kind is still drawn as a triangle; no ranked gap changed; readiness estimates unchanged | | 2026-11-04 | trivial | #19: ODT settings for what the standard leaves open removed: one choice for each case | | 2026-11-04 | trivial | #19: ODT element audit; files from other applications checked | | 2026-11-04 | trivial | PR #4609: relative REF keeps context already displayed by the own or a needed ancestor label; six synthetic legal-template cases and separate-list context follow the Word for Windows measurements reported by @pakiat in PR discussion. Existing unknown-switch/cache boundaries and readiness estimates unchanged; no new native Word run. | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 84b19512a2..db5c197d59 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -42,9 +42,10 @@ Document title opens Rename Document; the account badge opens Options › Genera | Backstage (Home, New, Open, Info, Save As, Print, Share, Export, Options) | Home and New separate (#254), Info properties kept (#268), Options in Word's panes with working settings (#485), Print page with preview, page range and copies (#641); Return on the Print page prints, as in Word, whose ⌘P opens on Print as the default button (not while a field or list on the page has the keyboard); launched with nothing to open, the app starts on Home (the Start screen: Blank document, templates, Recent; no document is open until one is picked or opened, so Esc or Back shows an empty window with the ribbon greyed out but for Help, #1129; File › Options works there, AutoCorrect Options included, #4585), with File › Options › General › Start-up to turn it off (#766); Info › Inspect Document finds and removes hidden text by its effective formatting (direct, character or paragraph style) in every story: body, headers, footers, notes, comments and text boxes, and lists what it couldn't reach (#1344); File › New, Open, the mailings and personal templates open their document beside the open ones, so they ask nothing; File › Close (Mod+W, Mod+F4) closes the shown document and keeps the window, showing the next open document, or no page after the last one, as Word does; the window's close button asks about each document with unsaved changes in turn, showing it, and Cancel stops the quit (#1712); each side-menu item has an icon, drawn in code (#1714); Info › Properties › Advanced Properties… opens the Custom Document Properties dialog (#2982); New lists personal templates (`.dotx`/`.dotm`) from the user templates folder under Personal, a subfolder per category, and its search covers them; a click makes an untitled document attached to the template; Save As › Save as Word Template starts in that folder; the folder is set in Options › Advanced › File locations (#2852; no thumbnails yet, no workgroup templates) | | 68% | 4–6 | | Rulers: indents, tabs, margins, table columns | indents draggable (one undo, #62); tab stops: corner selector (Left/Center/Right/Decimal/Bar), click to set, drag to move, drag off to clear, per-kind markers, Alt skips the snap, one undo step per gesture, double-click opens the Tabs dialog (#320); table column and row markers drag their borders (one undo) and in a cell the indents are measured from it (#700); the numbers thin out as the page shrinks on screen (every 1, 2, 4… units, never closer than 30 px, the small ticks never closer than 4 px, the text keeps its size), give way to an indent, tab or column marker on them, and the margins get ticks only; both rulers span the caret's page at its own scale in every layout (one column, One Page, Multiple Pages) and follow the caret to another page (#1878) | ✅ | 92% | 1 | | On-canvas objects: select, drag, resize handles, nudge | ✅ tested (#228); a picture or shape behind text can be dragged across the overlapping text (body and header/footer), whether or not it was selected first, while a click without movement still edits that text. Inside a Drawing Canvas a click picks the member under it (shape, picture or text box) on its own, its frame and handles shown inside the canvas frame; it is dragged, resized, turned and nudged inside the canvas, and Shape Format, Delete, Cut and Copy act on it alone; a click in a text box member's text puts the caret there (#2637, `objects::tests::clicking_and_dragging_inside_a_canvas_works_on_its_members`). Not yet: Shift+click on several members, dragging a member out of its canvas, drag-selecting a text box member's text, members of a turned canvas | ✅ | 75% | — | +| Rulers: indents, tabs, margins, table columns | indents draggable (one undo, #62); tab stops: corner selector (Left/Center/Right/Decimal/Bar), click to set, drag to move, drag off to clear, per-kind markers, Alt skips the snap, one undo step per gesture, double-click opens the Tabs dialog (#320); table column and row markers drag their borders (one undo) and in a cell the indents are measured from it (#700); the numbers thin out as the page shrinks on screen (every 1, 2, 4… units, never closer than 30 px, the small ticks never closer than 4 px, the text keeps its size), give way to an indent, tab or column marker on them, and the margins get ticks only; both rulers span the caret's page at its own scale in every layout (one column, One Page, Multiple Pages) and follow the caret to another page (#1878); in a section of several text columns the spaces between them are shaded like the margins (Print Layout, in the main text outside tables, with the selection in one section), an edge dragged changes the spacing (equal columns stay equal, as in Word for Mac), one undo step per drag (#5197) | ✅ | 92% | 1 | +| On-canvas objects: select, drag, resize handles, nudge | ✅ tested (#228); a picture or shape behind text can be dragged across the overlapping text (body and header/footer), whether or not it was selected first, while a click without movement still edits that text | ✅ | 75% | — | | On-canvas objects: select, drag, Ctrl+drag to copy, Ctrl+Shift+drag to copy along an axis, resize handles, nudge | ✅ tested (#228, #1014); Ctrl/Command+Shift on a selected floating picture, shape or text box copies along the dominant horizontal or vertical axis, with guides only along the free axis; the original and clipboard stay, the duplicate is selected, and the drop is one undo step. Inline copies still follow the text insertion cursor (#4764). Synthetic Linux pointer/render tests only; native desktop and Word untested; an In Line with Text object drags within the text as in Word: a dashed insertion cursor follows the pointer through the text and the drop (or Ctrl+drop copy) lands there, still inline (#2233, #2234) | ✅ | 75% | — | | Rotation handle, crop handles on canvas, alignment guides, smart guides | rotation handle (Shift: 15° steps), pictures and shapes without text stories preview their content turning while the pointer is held; release commits one `arrange.rotation` command and Escape cancels (#2277); text boxes retain a frame-only rotation preview, with text staying upright; turned frames resize along their axes (#332), and the arrow over each handle turns with the frame to the nearest of the four resize arrows (#3932); crop handles: Picture Format › Crop puts the picture in crop mode, black crop handles trim a side (a corner, two) keeping the scale and the visible part in place, the cropped-away part shows dimmed, Esc/Enter/a click outside/Crop again keep the crop, one undo step per drag (unturned pictures; no Crop to Shape, Aspect Ratio or Fill/Fit); alignment guides, our own design: a moved picture, shape or text box snaps its left, centre or right (top, middle or bottom) to the page's edges and centre, the margins and the other floating objects on the page within 6 screen points, x and y independently, turned objects by their rotated bounds, with a thin line across the page for each guide while dragging; Alt moves freely; File › Options › Advanced › Editing (`ui.alignmentGuides`) turns them off. Smart guides missing | Word for Mac 16.113.4 shows no guide lines and snaps inconsistently (to the page's left edge, not its top, right or bottom; Word check K); Word for Windows' guides not observed | 75% | 1–2 | -| On-canvas objects: select, drag, resize handles, nudge | ✅ tested (#228); a picture or shape behind text can be dragged across the overlapping text (body and header/footer), whether or not it was selected first, while a click without movement still edits that text | ✅ | 75% | — | | On-canvas objects: select, drag, Ctrl+drag to copy, Ctrl+Shift+drag to copy along an axis, resize handles, nudge | ✅ tested (#228, #1014); Ctrl/Command+Shift on a selected floating picture, shape or text box copies along the dominant horizontal or vertical axis, with guides only along the free axis; the original and clipboard stay, the duplicate is selected, and the drop is one undo step. Inline copies still follow the text insertion cursor (#4764). Synthetic Linux pointer/render tests only; native desktop and Word untested; an In Line with Text object drags within the text as in Word: a bold insertion cursor (solid, twice the caret's width) follows the pointer through the text and the drop (or Ctrl+drop copy) lands there, still inline (#2233, #2234, #4195) | ✅ | 75% | — | | Rotation handle, crop handles on canvas, alignment guides, smart guides | rotation handle (Shift: 15° steps), pictures and shapes without text stories preview their content turning while the pointer is held; release commits one `arrange.rotation` command and Escape cancels (#2277); text boxes retain a frame-only rotation preview, with text staying upright; turned frames resize along their axes (#332); crop handles: Picture Format › Crop puts the picture in crop mode, black crop handles trim a side (a corner, two) keeping the scale and the visible part in place, the cropped-away part shows dimmed, Esc/Enter/a click outside/Crop again keep the crop, one undo step per drag (unturned pictures; no Crop to Shape, Aspect Ratio or Fill/Fit); alignment guides, our own design: a moved picture, shape or text box snaps its left, centre or right (top, middle or bottom) to the page's edges and centre, the margins and the other floating objects on the page within 6 screen points, x and y independently, turned objects by their rotated bounds, with a thin line across the page for each guide while dragging; Alt moves freely; File › Options › Advanced › Editing (`ui.alignmentGuides`) turns them off. Smart guides missing | Word for Mac 16.113.4 shows no guide lines and snaps inconsistently (to the page's left edge, not its top, right or bottom; Word check K); Word for Windows' guides not observed | 75% | 1–2 | | Tables on the page: drag column and row borders, resize handle past the bottom-right corner; select columns, rows and cells; "+" insert buttons; move handle | ✅ resize cursors, dashed guide, one undo step per drag, selection kept; Shift moves one column; Esc cancels (#217); Ctrl shares the change among the columns on the right, the left edge moves a left-aligned table's indent (a centred or right-aligned one keeps its alignment), a border of cells selected across moves only in their rows, Alt shows the column widths on the ruler (#711); double-click a column border to AutoFit it (a nested table's within the cell around it, #971); selection arrows above a column, left of a row and along a cell's left edge (a drag selects more; the cells are shaded and a column is edited cell by cell); "+" left of a row border and above a column border; move handle past the top-left corner (a click selects the table, a drag floats it where it's dropped); both handles also show while the caret is in the table, as in Word (#2428); an ordinary drag, Shift+arrows or Shift+click from one cell into another select the rectangle of whole cells between them, and into or out of a table whole rows, their cells shaded whole (#971). Missing: a single selected cell's border; The Cell Size Height and Width boxes set every selected row and column (#1242). | ✅ | 95% | 1 | @@ -118,6 +119,7 @@ Page Setup's margin, paper-size and document-grid number boxes scroll long text | 2026-10-17 | trivial | Drawing Canvas members are selected with a click and dragged, resized, turned, nudged, formatted, deleted and copied on their own inside the canvas; a click in a text box member's text puts the caret there (#2637) | | 2026-11-05 | trivial | On-canvas objects: dragging an In Line with Text picture, shape or text box shows a bold, solid insertion cursor, twice the caret's width, as in Word; the dashed one was hard to see (#4195) | | 2026-10-28 | trivial | Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged. | +| 2026-11-01 | trivial | Rulers: the spaces between text columns are shaded on the horizontal ruler (Print Layout, in the main text outside tables, with the selection in one section); dragging an edge changes the spacing; equal columns stay equal, as in Word for Mac (#5197) | | 2026-10-31 | trivial | Dialogs are modal (#3859): while one is open, clicks on the ribbon, File or the page, typing and shortcuts do nothing, as in Word. Find and Replace, Symbol, Mark Index Entry, Cross-reference and Insert Merge Field stay modeless, as in Word for Mac. A press beside a modal dialog shakes it a little, or flashes its border with animation effects off, so it is clear why nothing behind it reacts | | 2026-10-17 | trivial | Copy and Cut put RTF beside the text and HTML on the system clipboard, for programs that read RTF rather than HTML (Windows "Rich Text Format", macOS `public.rtf`, Wayland `text/rtf`; an X11 copy stays text and HTML, since arboard owns the selection there; a copy of only pictures or shapes carries no HTML or RTF, so pasting it back keeps every detail); Paste reads another program's RTF on macOS and X11 too, as on Windows and Wayland | | 2026-11-04 | trivial | Table Sort rejects malformed or nonexistent explicit columns before mutation; valid columns, the omitted-column default and history are retained (#5531). Readiness estimates unchanged. |