mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-18 00:15:44 +00:00
Header pictures: while editing the header, a click selects its Behind Text picture wherever no header text covers it (#5601)
* Header pictures: while editing the header, a click selects its Behind Text picture wherever no header text covers it Header and footer Behind Text pictures skip the deferred drag-over-text path where the plain hit test picked them with no text under them, and a right-click selects them (and sets the page they were hit on) so Reset Picture and Wrap Text act on them. Tests cover a header and a footer, a drag, and a repeated picture right-clicked on another page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #5601: header Behind Text picture: a left-click selects the copy clicked on a repeated page The press branch of pointer() selected the picture but left page_hint on the page being edited, so on a header picture repeated on page 2 the frame and handles were resolved and drawn on page 1. Set page_hint to the picked object's page, as select_at does for a right-click. Adds a left-click counterpart to the right-click test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #5601: header text hit test checks each line's own extent CodeRabbit: hf_text_at took the whole paragraph's right edge from its last line, so a click on a long first line past a short last line's end counted as clear of text and selected the Behind Text picture under it. Each line now has its own band and extent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #5601: pin that centred and right-aligned header lines cover their whole band Line::left/right are the edges available to a line, not where its ink sits, so a centred or right-aligned header line already covers the Behind Text picture across its band (indent and floats narrow it) plus 40pt. Test pins that, and the parity row now says what counts as covering the picture. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * #5601: pin Line.left/right as band edges in the header band test Assert the band's left edge is the 150pt indent, the centred/right ink starts well inside it, and a click between the indent and the ink is text. Fails if Line.left were the ink extent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bd6f372c5
commit
fe8a8a838c
5 files changed
+325
-56
No files matched your search
@@ -292,9 +292,13 @@ fn hf_text_at(p: &Page, id: u32, x: f32, y: f32) -> bool {
|
||||
_ => None,
|
||||
})
|
||||
.any(|(para, l0, l1, lx, ly)| {
|
||||
let (Some(first), Some(last)) = (para.lines.get(*l0), para.lines.get(l1.checked_sub(1).unwrap_or(0))) else { return false };
|
||||
let bottom = ly + last.top + last.height - first.top;
|
||||
y >= *ly - 2.0 && y <= bottom + 2.0 && x >= *lx - 40.0 && x <= lx + last.right + 40.0
|
||||
let Some(first) = para.lines.get(*l0) else { return false };
|
||||
// Each line has its own band and extent: lines beside a float are shorter than the
|
||||
// ones above them, and a click on a long line past a short one's end is still text.
|
||||
(*l0..*l1).filter_map(|li| para.lines.get(li)).any(|l| {
|
||||
let top = ly + l.top - first.top;
|
||||
y >= top - 2.0 && y <= top + l.height + 2.0 && x >= lx + l.left - 40.0 && x <= lx + l.right + 40.0
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -15444,3 +15444,88 @@ fn turned_cell_float_keeps_its_along_text_offset() {
|
||||
assert!((confined.y - reference.y).abs() < 0.01, "{direction:?}: {confined:?} vs {reference:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A header paragraph beside a Square float on its last lines only: those lines are shorter than
|
||||
/// the first. A click on the first line past the short last line's end is still on the header's
|
||||
/// text, so a Behind Text picture under it is not grabbed there (#5601 review).
|
||||
#[test]
|
||||
fn header_text_covers_the_whole_width_of_a_wrapped_first_line() {
|
||||
use wordcraft_doc::para::{Anchor, Float, Wrap};
|
||||
let text = "Header words that wrap across the whole line and carry on over several lines of the header \
|
||||
paragraph so there are three lines here and the last one is cut short by the float beside it";
|
||||
let mut d = Document::new();
|
||||
let id =
|
||||
d.add_part(wordcraft_doc::PartKind::Header, vec![wordcraft_doc::para_block(wordcraft_doc::Paragraph::with_text(text, Default::default()))]);
|
||||
d.last_section.headers.default = Some(id);
|
||||
let at = |off| Pos::new(wordcraft_doc::StoryRef::Part(id), wordcraft_doc::Path(vec![0]), off);
|
||||
// The Square float narrows the lines below the first two, on the right.
|
||||
let square = Float { wrap: Wrap::Square, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, x: 300.0, y: 30.0, ..Default::default() };
|
||||
d.insert_object(&at(0), rect_shape(160.0, 80.0, square), &Default::default()).unwrap();
|
||||
// The Behind Text picture lies under the first line, past where the last line ends.
|
||||
let behind = Float { wrap: Wrap::BehindText, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, x: 340.0, y: 0.0, ..Default::default() };
|
||||
d.insert_object(&at(0), rect_shape(120.0, 20.0, behind), &Default::default()).unwrap();
|
||||
let l = lay(&d);
|
||||
let page = &l.pages[0];
|
||||
let lines: Vec<_> = page
|
||||
.header
|
||||
.iter()
|
||||
.filter_map(|it| match it {
|
||||
Placed::Lines { para, l0, l1, x, y, .. } => {
|
||||
Some((*x, *y, (*l0..*l1).filter_map(|i| para.lines.get(i)).map(|l| (l.top, l.height, l.right)).collect::<Vec<_>>()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let (x, y, ls) = lines.first().expect("header lines").clone();
|
||||
let (first, last) = (ls.first().expect("first"), ls.last().expect("last"));
|
||||
assert!(last.2 + 40.0 < first.2 - 20.0, "the last line is shorter than the first: {ls:?}");
|
||||
let (px, py) = (x + first.2 - 15.0, y + first.0 + first.1 / 2.0);
|
||||
assert!(l.object_at_in(0, px, py, 0.0, wordcraft_doc::StoryRef::Part(id)).is_none(), "on the first line's text, not the picture: {lines:?}");
|
||||
}
|
||||
|
||||
/// `Line::left`/`right` are the edges available to a line, not where its ink sits: a centred or
|
||||
/// right-aligned header line covers the Behind Text picture across its whole band, so a click in
|
||||
/// the empty space beside its text is still on the header text. Beyond the band (an indent, or
|
||||
/// beside a float) and 40pt of slack the picture is hit (#5601 review).
|
||||
#[test]
|
||||
fn header_text_covers_the_whole_band_of_centred_and_right_lines() {
|
||||
use wordcraft_doc::Align;
|
||||
use wordcraft_doc::para::{Anchor, Float, Wrap};
|
||||
for align in [Align::Center, Align::Right] {
|
||||
let mut d = Document::new();
|
||||
let mut p = wordcraft_doc::Paragraph::with_text("Header", Default::default());
|
||||
p.props.align = Some(align);
|
||||
p.props.indent_left = Some(150.0);
|
||||
let id = d.add_part(wordcraft_doc::PartKind::Header, vec![wordcraft_doc::para_block(p)]);
|
||||
d.last_section.headers.default = Some(id);
|
||||
let story = wordcraft_doc::StoryRef::Part(id);
|
||||
let at = Pos::new(story, wordcraft_doc::Path(vec![0]), 0);
|
||||
// A Behind Text picture across the whole text width, level with the header line.
|
||||
let behind = Float { wrap: Wrap::BehindText, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, x: 0.0, y: 0.0, ..Default::default() };
|
||||
d.insert_object(&at, rect_shape(460.0, 20.0, behind), &Default::default()).unwrap();
|
||||
let l = lay(&d);
|
||||
let (x, y, left, right, height, ink0) = l.pages[0]
|
||||
.header
|
||||
.iter()
|
||||
.find_map(|it| match it {
|
||||
Placed::Lines { para, l0, x, y, .. } => {
|
||||
para.lines.get(*l0).and_then(|ln| Some((*x, *y, ln.left, ln.right, ln.height, *ln.xs.first()?)))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("header line");
|
||||
// `left`/`right` are the band edges available to the line, not the ink extent.
|
||||
assert!((left - 150.0).abs() < 0.5, "{align:?}: the band's left edge is the indent: {left}");
|
||||
assert!(ink0 > left + 100.0, "{align:?}: the ink starts well inside the band: ink {ink0}, band left {left}");
|
||||
let ym = y + height / 2.0;
|
||||
let hit = |px: f32| l.object_at_in(0, px, ym, 0.0, story).is_some();
|
||||
// Inside the band, wherever the centred or right-aligned ink sits: header text.
|
||||
assert!(!hit(x + left + 5.0), "{align:?}: the band's left end is text");
|
||||
assert!(!hit(x + (left + right) / 2.0), "{align:?}: the band's middle is text");
|
||||
// Between the indent and the ink is still the text band, not the picture.
|
||||
assert!(!hit(x + left + 160.0), "{align:?}: between the indent and the ink is text");
|
||||
// Within 40pt of the band's left end is still text; further left the picture is hit.
|
||||
assert!(!hit(x + left - 30.0), "{align:?}: within 40pt left of the band is text");
|
||||
assert!(hit(x + left - 60.0), "{align:?}: beyond 40pt left of the band the picture is hit");
|
||||
}
|
||||
}
|
||||
@@ -635,12 +635,12 @@ fn multi_click_drag_extends_by_units() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let screen = |h: &mut egui_kittest::Harness<'_, WordApp>, pos: Pos| {
|
||||
let screen = |h: &mut H, pos: Pos| {
|
||||
let c = h.state_mut().session.layout().caret(&pos).expect("caret");
|
||||
page_to_screen(h.state_mut(), c.page, c.x + 1.0, c.top + c.height / 2.0).expect("on screen")
|
||||
};
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
let multi_drag = |h: &mut egui_kittest::Harness<'_, WordApp>, from: Pos2, to: Pos2, clicks: usize| {
|
||||
let multi_drag = |h: &mut H, from: Pos2, to: Pos2, clicks: usize| {
|
||||
h.event(Event::PointerMoved(from));
|
||||
for i in 0..clicks {
|
||||
h.event(button(from, true));
|
||||
@@ -871,7 +871,7 @@ fn clicking_vertical_scrollbar_track_advances_one_screen() {
|
||||
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.step();
|
||||
h.event(button(at, true));
|
||||
@@ -939,7 +939,7 @@ fn clicking_vertical_scrollbar_track_advances_one_screen_in_rtl() {
|
||||
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.step();
|
||||
h.event(button(at, true));
|
||||
@@ -1002,7 +1002,7 @@ fn clicking_thin_vertical_scrollbar_track_advances_one_screen() {
|
||||
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.step();
|
||||
h.event(button(at, true));
|
||||
@@ -1195,11 +1195,11 @@ fn ctrl_drag_copies_an_object() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let objects = |h: &mut egui_kittest::Harness<'_, WordApp>| {
|
||||
let objects = |h: &mut H| {
|
||||
let doc = &h.state().session.doc;
|
||||
doc.para(wordcraft_doc::StoryRef::Body, &wordcraft_doc::Path::top(0)).map_or(0, |p| p.objects.len())
|
||||
};
|
||||
let xs = |h: &mut egui_kittest::Harness<'_, WordApp>| {
|
||||
let xs = |h: &mut H| {
|
||||
let mut v: Vec<i32> = Vec::new();
|
||||
for x in (0..600).step_by(50) {
|
||||
if h.state_mut().session.layout().find_object(0, |o| (o.rect.x - x as f32).abs() < 0.5).is_some() {
|
||||
@@ -1208,7 +1208,7 @@ fn ctrl_drag_copies_an_object() {
|
||||
}
|
||||
v
|
||||
};
|
||||
let drag = |h: &mut egui_kittest::Harness<'_, WordApp>, mods: Modifiers| {
|
||||
let drag = |h: &mut H, mods: Modifiers| {
|
||||
let from = page_to_screen(h.state_mut(), 0, 250.0, 330.0).expect("on screen");
|
||||
let to = page_to_screen(h.state_mut(), 0, 400.0, 330.0).expect("on screen");
|
||||
h.event(Event::ModifiersChanged(mods));
|
||||
@@ -1257,19 +1257,19 @@ fn selection_bar_clicks_select_lines() {
|
||||
h.step();
|
||||
}
|
||||
// A point in the left margin beside the line `li` lines below the one holding `pos`.
|
||||
let margin = |h: &mut egui_kittest::Harness<'_, WordApp>, pos: Pos, li: f32| {
|
||||
let margin = |h: &mut H, pos: Pos, li: f32| {
|
||||
let c = h.state_mut().session.layout().caret(&pos).expect("caret");
|
||||
page_to_screen(h.state_mut(), c.page, 30.0, c.top + c.height * (li + 0.5)).expect("on screen")
|
||||
};
|
||||
let line_start = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let line_start = |h: &mut H, at: Pos2| {
|
||||
let (rects, scale) = (h.state().canvas.page_rects.clone(), h.state().canvas.scale);
|
||||
let layout = h.state_mut().session.layout();
|
||||
let (pg, x, y) = page_at(&rects, &layout, scale, at).expect("page");
|
||||
layout.selection_bar_at(pg, x, y).expect("in the selection bar")
|
||||
};
|
||||
let span = |h: &mut egui_kittest::Harness<'_, WordApp>, pos: &Pos| h.state_mut().session.layout().line_span(pos, 0).expect("line");
|
||||
let span = |h: &mut H, pos: &Pos| h.state_mut().session.layout().line_span(pos, 0).expect("line");
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
let clicks_drag = |h: &mut egui_kittest::Harness<'_, WordApp>, from: Pos2, to: Pos2, clicks: usize| {
|
||||
let clicks_drag = |h: &mut H, from: Pos2, to: Pos2, clicks: usize| {
|
||||
h.event(Event::PointerMoved(from));
|
||||
for i in 0..clicks {
|
||||
h.event(button(from, true));
|
||||
@@ -1288,7 +1288,7 @@ fn selection_bar_clicks_select_lines() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let pause = |h: &mut egui_kittest::Harness<'_, WordApp>| {
|
||||
let pause = |h: &mut H| {
|
||||
for _ in 0..40 {
|
||||
h.step();
|
||||
}
|
||||
@@ -1361,7 +1361,7 @@ fn selection_bar_of_a_right_to_left_paragraph_is_on_the_right() {
|
||||
let y = c.top + c.height / 2.0;
|
||||
let right = page_to_screen(h.state_mut(), c.page, (body_x + page_w) / 2.0, y).expect("on screen");
|
||||
let left = page_to_screen(h.state_mut(), c.page, 30.0, y).expect("on screen");
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.step();
|
||||
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
@@ -1408,7 +1408,7 @@ fn an_armed_format_painter_changes_the_pointer() {
|
||||
let c = h.state_mut().session.layout().caret(&Pos::body(0, 6)).expect("caret");
|
||||
let over_text = page_to_screen(h.state_mut(), c.page, c.x, c.top + c.height / 2.0).expect("on screen");
|
||||
let over_bar = page_to_screen(h.state_mut(), c.page, 30.0, c.top + c.height / 2.0).expect("on screen");
|
||||
let pointer_after = |h: &mut egui_kittest::Harness<'_, WordApp>, cmd: Option<&str>| {
|
||||
let pointer_after = |h: &mut H, cmd: Option<&str>| {
|
||||
if let Some(cmd) = cmd {
|
||||
h.state_mut().run(cmd, json!({})).unwrap();
|
||||
}
|
||||
@@ -1493,7 +1493,7 @@ fn an_empty_comment_balloon_deletes() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: egui::Pos2| {
|
||||
let click = |h: &mut H, at: egui::Pos2| {
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
h.step();
|
||||
@@ -2137,7 +2137,7 @@ fn double_click_margin_creates_header_and_footer() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let double_click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let double_click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
for _ in 0..2 {
|
||||
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
@@ -2150,7 +2150,7 @@ fn double_click_margin_creates_header_and_footer() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let kind = |h: &egui_kittest::Harness<'_, WordApp>| part_kind(h.state(), h.state().session.sel.focus.story);
|
||||
let kind = |h: &H| part_kind(h.state(), h.state().session.sel.focus.story);
|
||||
let page = h.state_mut().session.layout().pages[0].clone();
|
||||
assert!(page.header_story.is_none() && page.footer_story.is_none());
|
||||
let (x, top, bottom) = (page.body.x + 20.0, page.body.y / 2.0, (page.body.bottom() + page.h) / 2.0);
|
||||
@@ -2250,7 +2250,7 @@ fn double_click_switches_between_header_and_footer() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let double_click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let double_click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
for _ in 0..2 {
|
||||
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
@@ -2262,7 +2262,7 @@ fn double_click_switches_between_header_and_footer() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let kind = |h: &egui_kittest::Harness<'_, WordApp>| part_kind(h.state(), h.state().session.sel.focus.story);
|
||||
let kind = |h: &H| part_kind(h.state(), h.state().session.sel.focus.story);
|
||||
let page = h.state_mut().session.layout().pages[0].clone();
|
||||
let (x, top, bottom) = (page.body.x + 20.0, page.body.y / 2.0, (page.body.bottom() + page.h) / 2.0);
|
||||
let head_at = page_to_screen(h.state_mut(), 0, x, top).expect("top margin on screen");
|
||||
@@ -2885,7 +2885,7 @@ fn control_click_on_macos_opens_the_context_menu() {
|
||||
h.step();
|
||||
let ctrl = egui::Modifiers { ctrl: true, ..Default::default() };
|
||||
// The events winit delivers for a Control-click, through the app's input hook as eframe runs it.
|
||||
let send = |h: &mut egui_kittest::Harness<'_, WordApp>, events: Vec<egui::Event>| {
|
||||
let send = |h: &mut H, events: Vec<egui::Event>| {
|
||||
let mut raw = egui::RawInput { events, ..Default::default() };
|
||||
let ctx = h.ctx.clone();
|
||||
h.state_mut().raw_input_hook(&ctx, &mut raw);
|
||||
@@ -2973,7 +2973,10 @@ fn drag_floating_picture(wrap: &str, header: bool, preselect: bool) {
|
||||
for _ in 0..3 {
|
||||
h.step();
|
||||
}
|
||||
assert!(wordcraft_engine::cmd::objects::object_selection(&h.state().session).is_none(), "a click still selects text");
|
||||
// In the header the picture lies over the body area, clear of the header's own text, so a
|
||||
// click on it selects it (Word); in the body a click still reaches the text behind it.
|
||||
let picked = wordcraft_engine::cmd::objects::object_selection(&h.state().session).is_some();
|
||||
assert_eq!(picked, header, "a click selects the header's picture, but only edits the body's text");
|
||||
if preselect {
|
||||
let end = Pos { off: pos.off + wordcraft_doc::para::OBJ.len_utf8(), ..pos.clone() };
|
||||
h.state_mut().run("select.range", json!({"anchor": pos, "focus": end})).unwrap();
|
||||
@@ -3138,7 +3141,7 @@ fn right_clicking_a_link_hides_the_hover_tooltip() {
|
||||
let at = screen(&mut h, c.x, c.top + c.height / 2.0);
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
steps(&mut h, 2);
|
||||
let tips = |h: &egui_kittest::Harness<'_, WordApp>| h.query_all_by_label_contains("Click to follow link").count();
|
||||
let tips = |h: &H| h.query_all_by_label_contains("Click to follow link").count();
|
||||
assert!(tips(&h) > 0, "hovering the link shows its target");
|
||||
for pressed in [true, false] {
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: Default::default() });
|
||||
@@ -3171,7 +3174,7 @@ fn a_handled_press_skips_the_link_tooltip() {
|
||||
let at = screen(&mut h, c.x, c.top + c.height / 2.0);
|
||||
h.event(Event::PointerMoved(at));
|
||||
steps(&mut h, 2);
|
||||
let tips = |h: &egui_kittest::Harness<'_, WordApp>| h.query_all_by_label_contains("Click to follow link").count();
|
||||
let tips = |h: &H| h.query_all_by_label_contains("Click to follow link").count();
|
||||
assert!(tips(&h) > 0, "hovering the link shows its target");
|
||||
h.event(Event::ModifiersChanged(Modifiers::COMMAND));
|
||||
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::COMMAND });
|
||||
@@ -4029,13 +4032,13 @@ fn ruler_tab_gestures_are_primary_only_and_cancellable() {
|
||||
h.step();
|
||||
}
|
||||
let area = h.state().canvas.canvas_rect.expect("the canvas is laid out");
|
||||
let ruler_x = |h: &mut egui_kittest::Harness<'_, WordApp>, d: f32| {
|
||||
let ruler_x = |h: &mut H, d: f32| {
|
||||
let body_x = h.state_mut().session.layout().pages[0].body.x;
|
||||
page_to_screen(h.state_mut(), 0, body_x + d, 0.0).expect("on screen").x
|
||||
};
|
||||
let on_ruler = |h: &mut egui_kittest::Harness<'_, WordApp>, d: f32| pos2(ruler_x(h, d), area.min.y - 7.0);
|
||||
let on_ruler = |h: &mut H, d: f32| pos2(ruler_x(h, d), area.min.y - 7.0);
|
||||
let button = |at: Pos2, b: PointerButton, pressed: bool| Event::PointerButton { pos: at, button: b, pressed, modifiers: Default::default() };
|
||||
let drag_events = |h: &mut egui_kittest::Harness<'_, WordApp>, from: Pos2, to: Pos2, b: PointerButton| {
|
||||
let drag_events = |h: &mut H, from: Pos2, to: Pos2, b: PointerButton| {
|
||||
h.event(Event::PointerMoved(from));
|
||||
h.event(button(from, b, true));
|
||||
h.step();
|
||||
@@ -4048,7 +4051,7 @@ fn ruler_tab_gestures_are_primary_only_and_cancellable() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let stops_of = |h: &egui_kittest::Harness<'_, WordApp>, block: usize| {
|
||||
let stops_of = |h: &H, block: usize| {
|
||||
let s = &h.state().session;
|
||||
let para = s.doc.para_at(&Pos::body(block, 0)).expect("a paragraph");
|
||||
s.doc.styles.resolve_para(¶.props).tabs.iter().map(|t| (t.pos, t.align)).collect::<Vec<_>>()
|
||||
@@ -4134,13 +4137,13 @@ fn ruler_tab_stops_are_set_moved_and_cleared_with_the_pointer() {
|
||||
}
|
||||
let area = h.state().canvas.canvas_rect.expect("the canvas is laid out");
|
||||
// The middle of the ruler's strip, over a point `d` points from the paragraph's start.
|
||||
let on_ruler = |h: &mut egui_kittest::Harness<'_, WordApp>, d: f32| {
|
||||
let on_ruler = |h: &mut H, d: f32| {
|
||||
let body_x = h.state_mut().session.layout().pages[0].body.x;
|
||||
let x = page_to_screen(h.state_mut(), 0, body_x + d, 0.0).expect("on screen").x;
|
||||
pos2(x, area.min.y - 7.0)
|
||||
};
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
let click = |h: &mut egui_kittest::Harness<'_, WordApp>, at: Pos2| {
|
||||
let click = |h: &mut H, at: Pos2| {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.event(button(at, true));
|
||||
h.step();
|
||||
@@ -4153,7 +4156,7 @@ fn ruler_tab_stops_are_set_moved_and_cleared_with_the_pointer() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let drag = |h: &mut egui_kittest::Harness<'_, WordApp>, from: Pos2, to: Pos2| {
|
||||
let drag = |h: &mut H, from: Pos2, to: Pos2| {
|
||||
h.event(Event::PointerMoved(from));
|
||||
h.event(button(from, true));
|
||||
h.step();
|
||||
@@ -4166,7 +4169,7 @@ fn ruler_tab_stops_are_set_moved_and_cleared_with_the_pointer() {
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let stops = |h: &egui_kittest::Harness<'_, WordApp>| {
|
||||
let stops = |h: &H| {
|
||||
let s = &h.state().session;
|
||||
let para = s.doc.para_at(&s.sel.focus).expect("a paragraph");
|
||||
s.doc.styles.resolve_para(¶.props).tabs.iter().map(|t| (t.pos, t.align)).collect::<Vec<_>>()
|
||||
@@ -4253,8 +4256,7 @@ fn space_and_enter_on_the_canvas_do_not_interrupt_ime() {
|
||||
}
|
||||
assert!(h.state().canvas.focused, "the canvas takes focus when the window opens");
|
||||
let key = |key| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
|
||||
let ime_interrupted =
|
||||
|h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|ime| ime.should_interrupt_composition);
|
||||
let ime_interrupted = |h: &H| h.output().platform_output.ime.as_ref().map(|ime| ime.should_interrupt_composition);
|
||||
h.event(key(egui::Key::Space));
|
||||
h.event(egui::Event::Text(" ".into()));
|
||||
h.step();
|
||||
@@ -4340,7 +4342,7 @@ fn the_caret_follows_the_input_method_cursor_in_the_composition() {
|
||||
for _ in 0..8 {
|
||||
h.step();
|
||||
}
|
||||
let ime_x = |h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|ime| ime.cursor_rect.min.x);
|
||||
let ime_x = |h: &H| h.output().platform_output.ime.as_ref().map(|ime| ime.cursor_rect.min.x);
|
||||
let start = ime_x(&h).expect("the canvas places the candidate window");
|
||||
let mut compose = |range: Option<std::ops::Range<usize>>| {
|
||||
h.event(egui::Event::Ime(egui::ImeEvent::Preedit { text: "にほん".into(), active_range_chars: range }));
|
||||
@@ -4386,10 +4388,8 @@ fn ime_descriptor_reports_visible_logical_text_and_exact_cause() {
|
||||
}
|
||||
h.state_mut().session.sel = wordcraft_engine::Selection::caret(wordcraft_doc::Pos::body(0, 2));
|
||||
h.step();
|
||||
let text = |h: &egui_kittest::Harness<'_, WordApp>| {
|
||||
h.output().platform_output.ime.as_ref().and_then(|i| i.surrounding_text.available()).map(|p| p.text.clone())
|
||||
};
|
||||
let cause = |h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|i| i.change_cause);
|
||||
let text = |h: &H| h.output().platform_output.ime.as_ref().and_then(|i| i.surrounding_text.available()).map(|p| p.text.clone());
|
||||
let cause = |h: &H| h.output().platform_output.ime.as_ref().map(|i| i.change_cause);
|
||||
assert_eq!(text(&h), Some("ab".into()), "the committed text is available");
|
||||
h.event(egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None }));
|
||||
h.step();
|
||||
@@ -4433,8 +4433,7 @@ fn ime_descriptor_hides_tracked_deletions_and_preserves_reversed_selection() {
|
||||
}
|
||||
h.state_mut().session.sel = wordcraft_engine::Selection { anchor: wordcraft_doc::Pos::body(0, 2), focus: wordcraft_doc::Pos::body(0, 7) };
|
||||
h.step();
|
||||
let payload =
|
||||
|h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().and_then(|i| i.surrounding_text.available()).cloned();
|
||||
let payload = |h: &H| h.output().platform_output.ime.as_ref().and_then(|i| i.surrounding_text.available()).cloned();
|
||||
let p = payload(&h).expect("the visible text is available");
|
||||
assert_eq!(p.text, "abcd");
|
||||
assert_eq!(p.cursor, 4);
|
||||
@@ -4460,10 +4459,10 @@ fn ime_byte_deletion_preserves_the_selection_and_earns_input_method() {
|
||||
}
|
||||
h.state_mut().session.sel = wordcraft_engine::Selection { anchor: wordcraft_doc::Pos::body(0, 3), focus: wordcraft_doc::Pos::body(0, 1) };
|
||||
h.step();
|
||||
let cause = |h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|i| i.change_cause);
|
||||
let cause = |h: &H| h.output().platform_output.ime.as_ref().map(|i| i.change_cause);
|
||||
h.event(egui::Event::Ime(egui::ImeEvent::DeleteSurroundingBytes { before_bytes: 1, after_bytes: 1 }));
|
||||
h.step();
|
||||
let body = |h: &egui_kittest::Harness<'_, WordApp>| h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).trim_end().to_string();
|
||||
let body = |h: &H| h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).trim_end().to_string();
|
||||
assert_eq!(body(&h), "bc", "the selected text is preserved");
|
||||
assert_eq!(h.state().session.sel.anchor.off, 2, "the selection anchor moved with the erased prefix");
|
||||
assert_eq!(h.state().session.sel.focus.off, 0);
|
||||
@@ -4510,7 +4509,7 @@ fn ime_generation_changes_on_document_replacement_but_not_on_caret_motion() {
|
||||
for _ in 0..8 {
|
||||
h.step();
|
||||
}
|
||||
let generation = |h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|i| i.context_generation);
|
||||
let generation = |h: &H| h.output().platform_output.ime.as_ref().map(|i| i.context_generation);
|
||||
let first = generation(&h).expect("an IME context");
|
||||
h.state_mut().run("caret.right", json!({})).unwrap();
|
||||
h.step();
|
||||
@@ -4715,7 +4714,7 @@ fn ime_generation_changes_on_undo_and_version_restore() {
|
||||
for _ in 0..8 {
|
||||
h.step();
|
||||
}
|
||||
let generation = |h: &egui_kittest::Harness<'_, WordApp>| h.output().platform_output.ime.as_ref().map(|i| i.context_generation);
|
||||
let generation = |h: &H| h.output().platform_output.ime.as_ref().map(|i| i.context_generation);
|
||||
let first = generation(&h).expect("an IME context");
|
||||
h.state_mut().run("edit.undo", json!({})).unwrap();
|
||||
h.step();
|
||||
@@ -5014,9 +5013,7 @@ fn ime_equation_byte_delete_drops_only_its_immediate_replacement() {
|
||||
for _ in 0..8 {
|
||||
h.step();
|
||||
}
|
||||
let linear = |h: &mut egui_kittest::Harness<'_, WordApp>| {
|
||||
h.state_mut().run("equation.get", json!({})).unwrap()["linear"].as_str().unwrap_or_default().to_string()
|
||||
};
|
||||
let linear = |h: &mut H| h.state_mut().run("equation.get", json!({})).unwrap()["linear"].as_str().unwrap_or_default().to_string();
|
||||
// Harness::event steps each queued event in a separate frame. Insert the complete
|
||||
// protocol replacement into RawInput to exercise a single native input batch.
|
||||
h.input_mut().events.extend([
|
||||
@@ -5388,6 +5385,176 @@ fn a_long_comment_balloon_paints_only_its_first_ten_rows() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A Behind Text header picture: while editing the header a click on it selects it wherever no
|
||||
/// header text covers it (far down over the body, or in the band clear of the text), as in Word;
|
||||
/// over the header text the click edits the text. From the body a click there is body text.
|
||||
#[test]
|
||||
fn header_picture_clear_of_header_text_is_selected_while_editing_the_header() {
|
||||
// Far down the page, over the body.
|
||||
header_picture_click(false, 200.0, 400.0, Some((300.0, f32::MAX)), true);
|
||||
// In the header band, below the header's text line.
|
||||
header_picture_click(false, 300.0, 56.0, Some((50.0, 72.0)), true);
|
||||
// Over the header's text, at its start: the click goes to the text.
|
||||
header_picture_click(false, 72.0, 36.0, None, false);
|
||||
}
|
||||
|
||||
/// The same for a footer, which is a `StoryRef::Part` like the header.
|
||||
#[test]
|
||||
fn footer_picture_clear_of_footer_text_is_selected_while_editing_the_footer() {
|
||||
header_picture_click(true, 200.0, 400.0, Some((300.0, f32::MAX)), true);
|
||||
}
|
||||
|
||||
/// Dragging a header picture that no header text covers moves it, rather than starting the
|
||||
/// deferred drag-over-text path.
|
||||
#[test]
|
||||
fn dragging_a_header_picture_clear_of_header_text_moves_it() {
|
||||
let (mut h, pos, rect) = header_picture_app(false, 200.0, 400.0, 1);
|
||||
edit_story(&mut h, false, 0);
|
||||
let at = picture_point(&h, 0, rect);
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
h.event(pointer_button(at, egui::PointerButton::Primary, true));
|
||||
h.step();
|
||||
let to = at + egui::vec2(60.0, 30.0);
|
||||
for p in [at + egui::vec2(20.0, 10.0), to] {
|
||||
h.event(egui::Event::PointerMoved(p));
|
||||
h.step();
|
||||
}
|
||||
h.event(pointer_button(to, egui::PointerButton::Primary, false));
|
||||
steps(&mut h, 3);
|
||||
let moved = h.state_mut().session.layout().object(&pos, 0).unwrap().rect;
|
||||
assert!(moved.x > rect.x + 10.0 && moved.y > rect.y + 5.0, "the picture moved with the drag: {rect:?} -> {moved:?}");
|
||||
assert_eq!(wordcraft_engine::cmd::objects::object_selection(&h.state().session).map(|(p, _)| p), Some(pos), "and stays selected");
|
||||
}
|
||||
|
||||
/// A right-click on the header picture repeated on page 2 while editing the header on page 1
|
||||
/// selects that copy: the frame and handles belong on page 2, not the page last edited.
|
||||
#[test]
|
||||
fn right_clicking_a_repeated_header_picture_selects_it_on_its_own_page() {
|
||||
let (mut h, pos, _) = header_picture_app(false, 200.0, 400.0, 2);
|
||||
edit_story(&mut h, false, 0);
|
||||
assert_eq!(h.state().session.page_hint, 0, "editing the header on page 1");
|
||||
let rect = h.state_mut().session.layout().object(&pos, 1).unwrap().rect;
|
||||
assert_eq!(h.state_mut().session.layout().object(&pos, 1).unwrap().page, 1, "the picture is repeated on page 2");
|
||||
let at = picture_point(&h, 1, rect);
|
||||
press(&mut h, at, egui::PointerButton::Secondary);
|
||||
assert_eq!(wordcraft_engine::cmd::objects::object_selection(&h.state().session).map(|(p, _)| p), Some(pos), "the right-click selected it");
|
||||
assert_eq!(h.state().session.page_hint, 1, "its frame is drawn on the page clicked");
|
||||
}
|
||||
|
||||
/// The same for a left-click: it selects the page-2 copy and moves the frame there, not the copy
|
||||
/// on page 1 that was being edited.
|
||||
#[test]
|
||||
fn left_clicking_a_repeated_header_picture_selects_it_on_its_own_page() {
|
||||
let (mut h, pos, _) = header_picture_app(false, 200.0, 400.0, 2);
|
||||
edit_story(&mut h, false, 0);
|
||||
assert_eq!(h.state().session.page_hint, 0, "editing the header on page 1");
|
||||
let rect = h.state_mut().session.layout().object(&pos, 1).unwrap().rect;
|
||||
assert_eq!(h.state_mut().session.layout().object(&pos, 1).unwrap().page, 1, "the picture is repeated on page 2");
|
||||
let at = picture_point(&h, 1, rect);
|
||||
press(&mut h, at, egui::PointerButton::Primary);
|
||||
assert_eq!(wordcraft_engine::cmd::objects::object_selection(&h.state().session).map(|(p, _)| p), Some(pos), "the left-click selected it");
|
||||
assert_eq!(h.state().session.page_hint, 1, "its frame is drawn on the page clicked");
|
||||
}
|
||||
|
||||
fn pointer_button(pos: egui::Pos2, button: egui::PointerButton, pressed: bool) -> egui::Event {
|
||||
egui::Event::PointerButton { pos, button, pressed, modifiers: Default::default() }
|
||||
}
|
||||
|
||||
/// Moves to `at`, presses and releases `button` there and lets the frames settle.
|
||||
fn press(h: &mut H, at: egui::Pos2, button: egui::PointerButton) {
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
h.event(pointer_button(at, button, true));
|
||||
h.step();
|
||||
h.event(pointer_button(at, button, false));
|
||||
steps(h, 3);
|
||||
}
|
||||
|
||||
/// Near the top-left corner of the picture's `rect` on `page`: on the header text line when the
|
||||
/// picture is placed over it.
|
||||
fn picture_point(h: &H, page: usize, rect: wordcraft_geom::Rect) -> egui::Pos2 {
|
||||
let scale = h.state().canvas.scale;
|
||||
crate::frame::to_screen(h.state().canvas.page_rects[page], scale, rect).min + egui::vec2(10.0, 6.0) * scale
|
||||
}
|
||||
|
||||
/// Starts editing the header (or footer) of `page` and lets the frames settle.
|
||||
fn edit_story(h: &mut H, footer: bool, page: usize) {
|
||||
let command = if footer { "insert.editFooter" } else { "insert.editHeader" };
|
||||
h.state_mut().run(command, json!({"page": page})).unwrap();
|
||||
// Entering the footer scrolls the page to it: wait until the page stops moving.
|
||||
let (mut last, mut still) = (h.state().canvas.page_rects[0], 0);
|
||||
for _ in 0..600 {
|
||||
h.step();
|
||||
let now = h.state().canvas.page_rects[0];
|
||||
still = if now == last { still + 1 } else { 0 };
|
||||
last = now;
|
||||
if still >= 10 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A body-mode window on a document of `pages` pages whose header (or footer) holds text and a
|
||||
/// 160pt Behind Text picture at (`x`, `y`) on the page. Returns it, the picture's position and
|
||||
/// its first-page rectangle.
|
||||
fn header_picture_app(footer: bool, x: f32, y: f32, pages: usize) -> (H, Pos, wordcraft_geom::Rect) {
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
for _ in 1..pages {
|
||||
a.run("insert.pageBreak", json!({})).unwrap();
|
||||
}
|
||||
a.run(if footer { "insert.editFooter" } else { "insert.editHeader" }, json!({})).unwrap();
|
||||
a.run("text.insert", json!({"text": if footer { "Footer" } else { "Header" }})).unwrap();
|
||||
let mut png = Vec::new();
|
||||
let img = image::RgbaImage::from_pixel(40, 20, image::Rgba([200, 30, 30, 255]));
|
||||
image::DynamicImage::ImageRgba8(img).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
|
||||
a.run("insert.picture", json!({"data": wordcraft_engine::cmd::insert::base64_encode(&png), "width": 160})).unwrap();
|
||||
let pos = wordcraft_engine::cmd::objects::selected(&a.session).unwrap().0;
|
||||
a.run("arrange.bounds", json!({"x": x, "y": y})).unwrap();
|
||||
a.run("arrange.wrap", json!({"wrap": "behindText"})).unwrap();
|
||||
let rect = a.session.layout().object(&pos, 0).unwrap().rect;
|
||||
a.run("insert.closeHeader", json!({})).unwrap();
|
||||
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
app.logic(&ctx);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
// Zoomed out so the whole page is on screen and entering the footer scrolls nothing.
|
||||
h.state_mut().run("view.zoom", json!({"value": 40})).unwrap();
|
||||
steps(&mut h, 20);
|
||||
(h, pos, rect)
|
||||
}
|
||||
|
||||
/// Puts a Behind Text header (or footer) picture at (`x`, `y`), checks its top lies within `band`
|
||||
/// (when given), clicks near its top-left corner from the body and then while editing, and checks
|
||||
/// the second click selects it (`selects`) or leaves the caret in the text; a right-click picks it
|
||||
/// only where the click does, so the context menu (Reset Picture, Wrap Text) acts on it.
|
||||
fn header_picture_click(footer: bool, x: f32, y: f32, band: Option<(f32, f32)>, selects: bool) {
|
||||
let (mut h, pos, rect) = header_picture_app(footer, x, y, 1);
|
||||
if let Some((lo, hi)) = band {
|
||||
assert!(rect.y >= lo && rect.y < hi, "the picture sits where the case wants it: {rect:?}");
|
||||
}
|
||||
let at = picture_point(&h, 0, rect);
|
||||
let picked = |h: &H| wordcraft_engine::cmd::objects::object_selection(&h.state().session).map(|(p, _)| p);
|
||||
press(&mut h, at, egui::PointerButton::Primary);
|
||||
assert!(picked(&h).is_none(), "from the body the picture isn't selectable");
|
||||
assert_eq!(h.state().session.sel.focus.story, StoryRef::Body);
|
||||
edit_story(&mut h, footer, 0);
|
||||
press(&mut h, at, egui::PointerButton::Primary);
|
||||
if selects {
|
||||
assert_eq!(picked(&h), Some(pos.clone()), "while editing a click on its picture selects it ({x}, {y})");
|
||||
} else {
|
||||
assert_eq!(picked(&h), None, "over the text the click edits the text ({x}, {y})");
|
||||
assert!(matches!(h.state().session.sel.focus.story, StoryRef::Part(_)), "still in the header or footer");
|
||||
}
|
||||
h.state_mut().session.sel = wordcraft_engine::Selection::caret(Pos { off: 0, ..pos.clone() });
|
||||
press(&mut h, at, egui::PointerButton::Secondary);
|
||||
assert_eq!(picked(&h), selects.then(|| pos.clone()), "a right-click picks the picture only where a click does ({x}, {y})");
|
||||
h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() });
|
||||
h.step();
|
||||
}
|
||||
|
||||
/// #1961 review: what a picture draws must be in its page's fingerprint itself. Reset Picture on
|
||||
/// one never edited keeps its media and clears only its corrections and crop, and undo puts them
|
||||
/// back; the anchor paragraph's layout pointer also moves then, but only as long as the old
|
||||
|
||||
@@ -407,7 +407,15 @@ pub fn pointer(app: &mut WordApp, ui: &Ui, resp: &egui::Response, pages: &[Rect]
|
||||
let _ = app.run("select.addObject", json!({"pos": object.pos()}));
|
||||
return true;
|
||||
}
|
||||
if pressed && grab == Grab::Move && object.behind() && behind_draggable(app, &object) {
|
||||
// While editing a header/footer, a click on its Behind Text picture where no header/footer
|
||||
// text covers it (the plain hit test picked it: down over the body, or clear of the text in
|
||||
// the band) selects it, as in Word; only over text does the click defer to that text.
|
||||
// ponytail: headers/footers only; body Behind Text pictures clear of text could do the same.
|
||||
let clear_of_text = matches!(object.story, StoryRef::Part(_))
|
||||
&& crate::canvas::page_at(pages, layout, scale, at)
|
||||
.and_then(|(page, x, y)| layout.object_at_in(page, x, y, EDGE / scale.max(0.01), object.story))
|
||||
.is_some_and(|o| o.pos() == object.pos());
|
||||
if pressed && grab == Grab::Move && object.behind() && !clear_of_text && behind_draggable(app, &object) {
|
||||
let (min, picture) = match app.session.doc.para_at(&object.pos()).and_then(|p| p.object_at(object.pos().off)) {
|
||||
Some(o) => (wordcraft_engine::cmd::objects::min_size(o), matches!(o, InlineObject::Image { .. })),
|
||||
None => return false,
|
||||
@@ -431,6 +439,8 @@ pub fn pointer(app: &mut WordApp, ui: &Ui, resp: &egui::Response, pages: &[Rect]
|
||||
let pos = object.pos();
|
||||
let end = Pos { off: pos.off + OBJ.len_utf8(), ..pos.clone() };
|
||||
let _ = app.run("select.range", json!({"anchor": pos, "focus": end}));
|
||||
// A header/footer picture repeats on every page: select the copy clicked, as `select_at` does.
|
||||
app.session.page_hint = object.page;
|
||||
let (min, picture) = match selected(app) {
|
||||
Some((_, o)) => (wordcraft_engine::cmd::objects::min_size(o), matches!(o, InlineObject::Image { .. })),
|
||||
None => return true,
|
||||
@@ -601,9 +611,8 @@ fn link_click(app: &mut WordApp, layout: &DocLayout, pages: &[Rect], scale: f32,
|
||||
/// Right-click at `at`: the picture, shape or text box under it becomes the selection (as a click
|
||||
/// would, without a drag), so the context menu acts on it. Returns whether there was one.
|
||||
pub fn select_at(app: &mut WordApp, layout: &DocLayout, pages: &[Rect], scale: f32, at: Pos2) -> bool {
|
||||
if crate::canvas::editing_header_footer(app, layout) {
|
||||
return false;
|
||||
}
|
||||
// While editing a header/footer, `grab_at` looks at its own objects, so its picture is picked
|
||||
// too and the menu's Reset Picture or Wrap Text acts on it.
|
||||
let Some((object, _)) = grab_at(app, layout, pages, scale, at) else { return false };
|
||||
let pos = object.pos();
|
||||
// Already selected (alone or among several picked for Group): keep the selection.
|
||||
@@ -611,6 +620,9 @@ pub fn select_at(app: &mut WordApp, layout: &DocLayout, pages: &[Rect], scale: f
|
||||
let end = Pos { off: pos.off + OBJ.len_utf8(), ..pos.clone() };
|
||||
let _ = app.run("select.range", json!({"anchor": pos, "focus": end}));
|
||||
}
|
||||
// A header/footer picture repeats on every page: its frame belongs on the page clicked, not
|
||||
// the one last edited.
|
||||
app.session.page_hint = object.page;
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
# UI parity with Microsoft Word
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** trivial (File › Print opened again no longer shows the last job's "submitted" or failure message when that window already said it; decided per window, the shared message and `ui.printSettings` untouched); previously trivial (Save As and Export offer Browse in WordCraft… on Linux/BSD, as Open does, #3535); previously trivial (Language dialog: whole-document OK sends Do not check only when the box was clicked, so per-run proofing state is not flattened; glossary skipped while Track Formatting is on and reported as `glossarySkipped`, #3518); previously trivial (Language dialog: Apply to the whole document sets the proofing language or no-proof for every story in one undo step, #3518); previously trivial (Ctrl/Cmd+Shift+V pastes the formatting picked up with Ctrl/Cmd+Shift+C or the Format Painter, or text only when none was, as in Word, #1537); previously trivial (Auto interface size capped to the screen, Ctrl+Shift+0 returns to Auto, #4030); previously trivial (clipboard: a copied picture reaches the system clipboard as PNG, with HTML where the host writes it, while a copy of only shapes stays in WordCraft, #6205); previously trivial (Save As on Linux: the desktop portal's Save dialog reports the file type picked, updating the extension so saving as PDF writes a .pdf, #6180); previously trivial (Vertical scrollbar track: clicking above the elevator moves one screen up and clicking below it moves one screen down, as in Word (#5853)); previously trivial (a press the canvas handles, such as Ctrl+click on a link, no longer also shows the link tooltip that frame, #4683); previously trivial (the window moves by its title bar behind a modal dialog, as in Word for Mac, #5124); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux and the BSDs no longer looks semi-bold); previously trivial (the document's scroll bars show wherever the pointer is, not only at the window's edge, #5746); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: Custom Document Properties dialog from File › Info › Properties › Advanced Properties…, #2982; previously trivial: View › Window › New Window opens another window on the document, each with its own caret and view; previously trivial: mail merge: First Record, Last Record and a record number box in Preview Results; Finish & Merge asks which records to merge or print, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: read only and comments-only protection grey out edits; previously trivial: the Font dialog previews "NaN" or "inf" in the Size box at 12 pt, #3663; previously trivial: File › Options disables the User name field while Restrict Editing is active; previously trivial: while editing a header or footer, a click in the other one edits it there without scrolling; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Insert Table of Figures dialog: any caption label, #3013; previously trivial: Home › Underline drop-down shows its lines, #2738; previously trivial: the text context menu includes the formatting mini toolbar, #2959; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: the scrollbar page tip stays on one line as the page number grows, #3341; previously trivial: File › Home and New: templates and recent documents are buttons named for screen readers, #3176; previously trivial: forms protection greys out the Developer tab's control buttons and Properties; previously trivial: AltGr doesn't open KeyTips, #2388; previously trivial: closing the header or footer puts the caret back where it was in the body, #3331; previously trivial: Format Page Numbers dialog: number format and Continue from previous section / Start at, #1113; previously trivial: inline pictures drag to a dashed insertion cursor and stay inline, #2233, #2234; previously trivial: Save Changes prompt: a text file saved over itself closes, #2376; previously trivial: the equation being edited is framed as in Word: an outline as tall as its line, a grip, an options strip that opens its menu, and its current argument shaded; previously trivial: the table handles show while the caret is in the table, #2428; previously trivial: legacy menu keys, #1697; previously trivial: Shape Fill › Gradient and the Format Shape pane, #1500; previously trivial: Focus fills the screen, and Full Screen View shows the pages alone, #1678; previously trivial: the text pointer over the page is drawn black or white on Windows, #1746; previously trivial: a click in the header/footer band from the body no longer scrolls to the bodyLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** trivial (while editing a header or footer, a click on its Behind Text picture selects it wherever no header or footer line's band (plus 40pt) covers it, down over the body or in a clear area inside the band, and a right-click selects it too so Reset Picture and Wrap Text act on it); previously trivial (File › Print opened again no longer shows the last job's "submitted" or failure message when that window already said it; decided per window, the shared message and `ui.printSettings` untouched); previously trivial (Save As and Export offer Browse in WordCraft… on Linux/BSD, as Open does, #3535); previously trivial (Language dialog: whole-document OK sends Do not check only when the box was clicked, so per-run proofing state is not flattened; glossary skipped while Track Formatting is on and reported as `glossarySkipped`, #3518); previously trivial (Language dialog: Apply to the whole document sets the proofing language or no-proof for every story in one undo step, #3518); previously trivial (Ctrl/Cmd+Shift+V pastes the formatting picked up with Ctrl/Cmd+Shift+C or the Format Painter, or text only when none was, as in Word, #1537); previously trivial (Auto interface size capped to the screen, Ctrl+Shift+0 returns to Auto, #4030); previously trivial (clipboard: a copied picture reaches the system clipboard as PNG, with HTML where the host writes it, while a copy of only shapes stays in WordCraft, #6205); previously trivial (Save As on Linux: the desktop portal's Save dialog reports the file type picked, updating the extension so saving as PDF writes a .pdf, #6180); previously trivial (Vertical scrollbar track: clicking above the elevator moves one screen up and clicking below it moves one screen down, as in Word (#5853)); previously trivial (a press the canvas handles, such as Ctrl+click on a link, no longer also shows the link tooltip that frame, #4683); previously trivial (the window moves by its title bar behind a modal dialog, as in Word for Mac, #5124); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux and the BSDs no longer looks semi-bold); previously trivial (the document's scroll bars show wherever the pointer is, not only at the window's edge, #5746); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: Custom Document Properties dialog from File › Info › Properties › Advanced Properties…, #2982; previously trivial: View › Window › New Window opens another window on the document, each with its own caret and view; previously trivial: mail merge: First Record, Last Record and a record number box in Preview Results; Finish & Merge asks which records to merge or print, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: read only and comments-only protection grey out edits; previously trivial: the Font dialog previews "NaN" or "inf" in the Size box at 12 pt, #3663; previously trivial: File › Options disables the User name field while Restrict Editing is active; previously trivial: while editing a header or footer, a click in the other one edits it there without scrolling; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Insert Table of Figures dialog: any caption label, #3013; previously trivial: Home › Underline drop-down shows its lines, #2738; previously trivial: the text context menu includes the formatting mini toolbar, #2959; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: the scrollbar page tip stays on one line as the page number grows, #3341; previously trivial: File › Home and New: templates and recent documents are buttons named for screen readers, #3176; previously trivial: forms protection greys out the Developer tab's control buttons and Properties; previously trivial: AltGr doesn't open KeyTips, #2388; previously trivial: closing the header or footer puts the caret back where it was in the body, #3331; previously trivial: Format Page Numbers dialog: number format and Continue from previous section / Start at, #1113; previously trivial: inline pictures drag to a dashed insertion cursor and stay inline, #2233, #2234; previously trivial: Save Changes prompt: a text file saved over itself closes, #2376; previously trivial: the equation being edited is framed as in Word: an outline as tall as its line, a grip, an options strip that opens its menu, and its current argument shaded; previously trivial: the table handles show while the caret is in the table, #2428; previously trivial: legacy menu keys, #1697; previously trivial: Shape Fill › Gradient and the Format Shape paneLine truncated
|
||||
|
||||
> **Page Setup update:** 2026-11-07 · Page Setup number boxes keep long input inside the field, including accepted margin values after focus leaves (#5650); accepted ranges and readiness estimates are unchanged.
|
||||
|
||||
@@ -128,6 +128,7 @@ Page Setup's margin, paper-size and document-grid number boxes scroll long text
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-15 | trivial | Header/footer pictures: while editing the header or footer, a click on its Behind Text picture selects it wherever no header or footer text covers it: drawn down over the body (anchored in the header, positioned outside the band) or in a clear area inside the band. What counts as header or footer text is each line's own band (the width available to it, so a centred or right-aligned line covers the empty space beside its ink, while an indent or a float beside the line narrows it) plus a 40pt margin either side; a drag there moves it, and a right-click selects it so Reset Picture and Wrap Text act on it. Over header or footer text the click still goes to the text, and from the body a click there is still body text (`canvas::tests::header_picture_clear_of_header_text_is_selected_while_editing_the_header`, `canvas::tests::footer_picture_clear_of_footer_text_is_selected_while_editing_the_footer`, `canvas::tests::right_clicking_a_repeated_header_picture_selects_it_on_its_own_page`, `tests::header_text_covers_the_whole_band_of_centred_and_right_lines`) |
|
||||
| 2026-11-15 | trivial | File › Print opened again no longer shows how the last job went ("Print job submitted…", a failure): that was said once in the status bar. A failure that comes in while the page is open stays, and printer status (finding printers, none found) shows each time. Decided per window: a result a window never said (it arrived under File's other pages, or in another window) still shows there, and the shared message that `ui.printSettings` reports is never cleared |
|
||||
| 2026-11-14 | trivial | Save As and Export (also the formats on the Print page) offer Browse in WordCraft… on Linux/BSD, as Open does; exporting there lists Export's formats as the types, whose extension replaces a known document extension on the name; an export refusal or failure shows on the Export page, as Save As's does (#3535) |
|
||||
| 2026-11-16 | trivial | Language dialog whole-document OK: Do not check sent only when clicked; `review.language` document scope returns the caret result with `scope`; glossary skipped while tracking formatting (result says `glossarySkipped`) (#3518) |
|
||||
|
||||
Reference in new issue
Block a user