Merge red5/g7 (page tools keep the caret snap)

This commit is contained in:
Dylan M. Taylor
2026-11-18 23:06:47 -05:00
6 changed files with 30 additions and 10 deletions
+7 -1
View File
@@ -968,7 +968,13 @@ fn pressed_by(phase: &PressPhase, button: PointerButton) -> bool {
fn route_press(ui: &egui::Ui, session: &mut PageSession, press: &PagePress, cx: &PageBodyCx<'_>, body: &PageBody<'_>, out: &mut BodyOut) {
let geo = cx.geometry(body);
if pressed_by(&press.phase, PointerButton::Secondary) {
// The page's menu reads what the secondary press went to.
// The page's menu reads what the secondary press went to; a comment is selected for its menu, as a comment's
// menu acts on the selection.
if let Owner::Comment { index } = press.owner
&& !session.comments.is_selected((press.page, index))
{
session.comments.select(Some((press.page, index)));
}
session.menu_for = Some((press.page, press.owner.clone()));
return;
}
+15 -1
View File
@@ -293,7 +293,21 @@ impl CanvasTool for CommentsTool<'_> {
if self.paste.is_some() && cx.pointer.is_some_and(|p| self.page_under(p.pos).is_some()) {
return Cursor::System(CursorIcon::Grabbing);
}
self.annotate.cursor(cx)
let own = self.annotate.cursor(cx);
if self.annotating() {
return own;
}
// Where no comment takes the press, it goes on to the text (`press`): its cursor shows there. A markup tool's
// crosshair is the annotation tool's idle face; the drag selects text, so the text's cursor shows over it.
let idle = match own {
Cursor::System(CursorIcon::Default) => true,
Cursor::System(CursorIcon::Crosshair) => matches!(self.quick, QuickTool::Comment(_)),
_ => false,
};
match self.text.as_ref().map(|text| text.cursor(cx)) {
Some(text) if idle && !matches!(text, Cursor::System(CursorIcon::Default)) => text,
_ => own,
}
}
fn access(&self, cx: &ToolContext<'_>) -> Option<ToolAccess> {
+2 -2
View File
@@ -109,7 +109,7 @@ fn number_pages_dialog_labels_the_selected_pages() {
h.state_mut().views[0].select_pages(&[0, 1]);
assert!(h.execute("page.number"));
h.run_steps(3);
h.get_by_label("Number pages");
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "Number pages");
h.get_by_value("1, 2, 3").click(); // the style menu
h.run_steps(2);
h.get_by_label("i, ii, iii").click();
@@ -274,7 +274,7 @@ fn new_bookmarks_from_text_styles_from_the_bookmark_options() {
};
open(&mut h);
assert!(crate::support::dialog_open(&h), "the dialog opens");
h.get_by_label("New bookmarks from text styles");
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "New bookmarks from text styles");
assert_eq!(h.state().text_style_draft.levels, [Some(0), None, None, None], "the largest style is offered for level 1");
// Cancel: nothing made.
h.get_by_label("Cancel").click();
+3 -3
View File
@@ -64,7 +64,7 @@ fn console_runs_scripts_against_the_document() {
let mut h = harness();
assert!(h.execute("tools.js_console"));
h.run_steps(2);
h.get_by_label("JavaScript Console");
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "JavaScript Console");
h.state_mut().js_console.input = "getField('greeting').value = 'typed'; console.println(numFields); 6 * 7".into();
h.get_by_label("Run").click();
h.run_steps(2);
@@ -219,7 +219,7 @@ fn document_scripts_and_preferences() {
let mut h = harness();
assert!(h.execute("tools.document_js"));
h.run_steps(2);
h.get_by_label("Document JavaScripts");
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "Document JavaScripts");
match h.state_mut().js_dialog.as_mut() {
Some(JsDialog::DocumentScripts(draft)) => {
draft.name = "init".into();
@@ -335,7 +335,7 @@ fn native_script_prompts_show_an_app_owned_caption() {
let id = h.state().active_ids().unwrap().1;
h.run_button_script(id, "hello", script);
wait_for(&mut h, body);
assert!(h.query_by_label("This document's script is asking").is_some(), "{script}");
assert!(h.query_by_role_and_label(egui::accesskit::Role::Dialog, "This document's script is asking").is_some(), "{script}");
assert_eq!(
h.query_by_label("This request comes from the document, not PdfCraft. Only enter a password if you trust this document.").is_some(),
script.contains("bPassword:true"),
+2 -2
View File
@@ -777,7 +777,7 @@ fn a_drag_with_the_link_tool_from_a_link_draws_a_new_link() {
link_tool(&mut h);
let on_link = at(&h, 150.0, 325.0);
mouse_drag(&mut h, on_link, egui::vec2(80.0, 120.0));
assert!(h.query_by_label("Create Link").is_some(), "Link Properties opens for a new link");
assert!(h.query_by_role_and_label(egui::accesskit::Role::Dialog, "Create Link").is_some(), "Link Properties opens for a new link");
assert_eq!(confirm_new_link(&mut h), [0, 0], "after OK the page holds its link and the new one");
}
@@ -1066,7 +1066,7 @@ fn a_redaction_box_dragged_off_its_page_is_drawn_on_it() {
#[test]
fn a_link_rectangle_dragged_off_its_page_is_drawn_on_it() {
let mut h = drag_seen_only_past_page_ones_edge(|app| app.quick_tool = QuickTool::Link);
assert!(h.query_by_label("Create Link").is_some(), "Link Properties opens for a new link");
assert!(h.query_by_role_and_label(egui::accesskit::Role::Dialog, "Create Link").is_some(), "Link Properties opens for a new link");
assert_eq!(confirm_new_link(&mut h), [0], "after OK the new link is on page 1");
}
+1 -1
View File
@@ -262,7 +262,7 @@ fn placing_moving_editing_and_deleting_a_field() {
// Field Properties: rename and make it required (one undo step).
h.execute("form.field.properties");
h.run_steps(2);
h.get_by_label("Text Field Properties");
h.get_by_role_and_label(Role::Dialog, "Text Field Properties");
assert!(props_open(&h));
retype(&mut h, "Name:", "email");
h.get_by_label("Required").click();