app red 3 (g7) (swarm/red3); committed by the lead

This commit is contained in:
Dylan M. Taylor
2026-11-18 20:47:43 -05:00
parent 4fbb074b86
commit 78937cea3d
12 changed files with 67 additions and 41 deletions
+2 -8
View File
@@ -152,14 +152,8 @@ impl PdfCraftApp {
}
}
"app.theme" => self.toggle_theme(ctx),
"tools.expand" => {
self.all_tools_full = false;
self.all_tools_expanded = true;
}
"tools.collapse" => {
self.all_tools_full = false;
self.all_tools_expanded = false;
}
"tools.expand" => self.expand_all_tools(ctx),
"tools.collapse" => self.all_tools_full = false,
"tools.all" => {
if let Some(v) = active.and_then(|i| self.views.get_mut(i)) {
v.organize = false;
+3 -2
View File
@@ -19,8 +19,9 @@ const CATALOG_ONLY: &[(&str, &str, &str)] = &[
("app.theme", "Switch theme", "moon"),
("home.unpin_tool", "Unpin tool", "pin-off"),
("form.calculation_order.back", "Back to Prepare a form", "chevron-left"),
("tools.expand", "Expand tools", "chevrons-up-down"),
("tools.collapse", "Collapse tools", "chevrons-down-up"),
// Labels distinct from the Combine grid's Expand and Collapse, which can show beside them.
("tools.expand", "Expand all tools", "maximize-2"),
("tools.collapse", "Collapse all tools", "minimize-2"),
("tools.all", "All tools", "layout-grid"),
("view.dock_side", "Move the side panel to the other side", "arrow-left-right"),
("view.fit_toggle", "Toggle fit", "scan"),
+5
View File
@@ -66,6 +66,11 @@ pub fn ui_fonts(lang: Lang) -> UiFonts<'static> {
.app_face("Inter-SemiBold", own_face(platform, "Inter-SemiBold", INTER_SEMIBOLD), &[FontRef::named(SEMIBOLD)])
.family(Family::named(MEDIUM).weight(500))
.family(Family::named(SEMIBOLD).weight(600))
// egui's own faces, as production's default fonts: the check mark, triangles and other text symbols that
// Inter and JetBrains Mono lack, with no system face.
.egui_face("Hack", &[proportional.clone(), monospace.clone()])
.egui_face("NotoEmoji-Regular", &[proportional.clone(), monospace.clone()])
.egui_face("emoji-icon-font", &[proportional.clone(), monospace.clone()])
.craft_faces(pdfcraft_fonts::CRAFT_FONTS)
.languages(&codes)
.ui_language(lang.code())
+22 -3
View File
@@ -6,12 +6,14 @@
use craft::automation::dock as dock_rpc;
use craft::behavior::dock::{Action, Column, DockEdge, DockPlacement, Group, Layout, Location, Node, Permissions, SplitSize, Target, Workspace};
use craft::behavior::{Axis, DockSide};
use craft::behavior::{Axis, DockSide, IconId};
use craft::keymap::CommandRef;
use craft::ui::buttons::IconButton;
use craft::ui::contract::{Bind, BodyCx};
use craft::ui::docking::{DockConfig, DockPanels, GroupAt, HidePanels, PanelSpec};
use craft::ui::menu::PanelRow;
use craft::ui::patterns::dock::DockArea;
use craft::ui::primitives::IconSpec;
use egui::Ui;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
@@ -306,6 +308,8 @@ impl DockPanels<PanelId> for Panels<'_> {
PanelId::Tools => {
if self.app.left == LeftPanel::CalculationOrder {
crate::calc_order_ui::header(ui);
} else if self.app.left == LeftPanel::AllTools {
IconButton::command(IconSpec::svg(IconId::new("maximize-2")), CommandRef::new("tools.expand")).show(ui);
}
}
PanelId::Bookmarks => super::bookmarks::header(self.app, ui),
@@ -631,6 +635,14 @@ fn find(node: &Value, panel: &str, depth: usize) -> Option<Found> {
None
}
/// Whether `node`'s splits nest deeper than [`find`] walks.
fn too_deep(node: &Value, depth: usize) -> bool {
if depth > MAX_DEPTH {
return true;
}
node.get("Split").is_some_and(|split| ["first", "second"].into_iter().any(|key| split.get(key).is_some_and(|child| too_deep(child, depth + 1))))
}
/// The old layout's saved place of a closed panel: whether it was on the right and its width.
fn hidden_place<'a>(old: &'a Value, panel: &str) -> Option<&'a Value> {
old.get("hidden")?.as_array()?.iter().find_map(|entry| {
@@ -686,7 +698,12 @@ fn read_side_panels(value: &Value) -> Option<Old> {
/// old layout always held.
fn read_docking(saved: &Value) -> Option<Old> {
let old = saved.get("docking")?;
find(old.get("layout")?.get("root")?, "canvas", 0)?;
let root = old.get("layout")?.get("root")?;
// A tree deeper than the walk reads is cut off whole, not read as one that lacks its panels.
if too_deep(root, 0) {
return None;
}
find(root, "canvas", 0)?;
let (tools_right, tools_open, tools_width) = old_panel(old, "tools");
let (_, side_open, side_width) = old_panel(old, "inspector");
Some(Old {
@@ -704,7 +721,9 @@ fn build(old: &Old, right: Option<RightPanel>, widths: bool) -> Option<Workspace
let mut workspace = default_workspace(old.rail);
let apply = |workspace: &mut Workspace<PanelId>, action| workspace.apply(action, false, permissions).ok();
if old.tools_right {
apply(&mut workspace, Action::move_column(PanelId::Tools, Target::new_dock(DockEdge::End)))?;
let moved = workspace.apply(Action::move_column(PanelId::Tools, Target::new_dock(DockEdge::End)), false, permissions);
eprintln!("DIAG an_old_saved_layout_migrates_to_the_dock_workspace: move tools right (widths {widths}): ok {}", moved.is_ok());
moved.ok()?;
}
let side = right.filter(|_| old.side_open).map(PanelId::from);
if let Some(side) = side {
+6
View File
@@ -426,6 +426,12 @@ pub(crate) fn field_press(
let form = doc.form.as_slice();
let Some((f, w)) = form.get(field).and_then(|f| f.widgets.get(wi).map(|w| (f, w))) else { return };
let usable = usable(f, w, allowed);
eprintln!(
"DIAG list_box_clicks_select_directly_and_ctrl_click_toggles_multi: field_press {} widget {wi} usable {usable} down {} release_click {}",
f.name,
matches!(press.phase, PressPhase::Down { .. }),
matches!(press.phase, PressPhase::Release { click: true, .. })
);
match &press.phase {
PressPhase::Down { start, .. } => {
// The press runs the widget's Mouse Down JavaScript, as in Acrobat (#269).
@@ -20,7 +20,7 @@ pub(super) fn calendar(ui: &mut egui::Ui, rect: Rect, text: &str, fmt: &str, ope
let mut picked = before.clone();
CalendarPopover::new("Calendar", Bind::bound(&mut *open), Bind::bound(&mut picked))
.precisions(&[DatePrecision::Day])
.overlay(|overlay| overlay.opener_anchor(Anchor::Rect(rect)))
.overlay(|overlay| overlay.anchor(Anchor::Rect(rect)))
.show(ui, |_, _| {});
if picked == before {
return None;
@@ -52,13 +52,12 @@ pub(super) fn choice_list(ui: &mut egui::Ui, field: &FormField, rect: Rect, zoom
};
let names: Vec<&str> = field.options.iter().map(|(_, shown)| shown.as_str()).collect();
let source = Names(&names);
let shown =
PopupList::new(tl!("Options"), Bind::bound(&mut *open)).overlay(|overlay| overlay.opener_anchor(Anchor::Rect(rect))).show(ui, |ui, _| {
List::<usize>::options(field.name.clone())
.document_rows(DocumentRows::new(FontRef::proportional(), size, align))
.show_items(ui, &source, &mut |key, _| ListRow::new(names.get(*key).copied().unwrap_or_default().to_owned()).option())
.events
});
let shown = PopupList::new(tl!("Options"), Bind::bound(&mut *open)).overlay(|overlay| overlay.anchor(Anchor::Rect(rect))).show(ui, |ui, _| {
List::<usize>::options(field.name.clone())
.document_rows(DocumentRows::new(FontRef::proportional(), size, align))
.show_items(ui, &source, &mut |key, _| ListRow::new(names.get(*key).copied().unwrap_or_default().to_owned()).option())
.events
});
let mut picked = None;
for event in shown.inner.into_iter().flatten() {
if let CollectionEvent::Activate(key) = event {
+6 -6
View File
@@ -255,18 +255,18 @@ fn choose(ui: &mut egui::Ui, d: &mut SignDraft, ids: &[DigitalIdEntry], asked: &
} else {
let source = IdRows(ids);
let mut selection = d.selected.map_or_else(Selection::default, Selection::single);
let out = List::<usize>::new(tl!("Digital IDs")).select(SelectMode::Single).selection(Bind::bound(&mut selection)).show_items(
ui,
&source,
&mut |_, icx| match ids.get(icx.at) {
let out = List::<usize>::new(tl!("Digital IDs"))
.select(SelectMode::Single)
.natural_height(true)
.selection(Bind::bound(&mut selection))
.show_items(ui, &source, &mut |_, icx| match ids.get(icx.at) {
Some(e) => {
let sub = details(e);
// Names are as long as their owners made them: the row cuts them and the tip says them whole.
ListRow::new(e.name.clone()).tooltip(format!("{}\n{sub}", e.name)).below(caption(sub), |_| {})
}
None => ListRow::new(String::new()),
},
);
});
for event in out.events {
match event {
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
+2
View File
@@ -52,6 +52,7 @@ impl<'a> SignAreaTool<'a> {
impl CanvasTool for SignAreaTool<'_> {
fn press(&mut self, pointer: &ToolPointer, _cx: &mut ToolContext<'_>) -> ToolAction {
eprintln!("DIAG ctrl_alt_q_types_an_email_without_quitting: sign press at {:?}, placed {}", pointer.pos, self.placed.len());
match self.placed_at(pointer.pos) {
Some(placed) if self.drag.press(placed, pointer.pos) => ToolAction::Claimed,
_ => ToolAction::Ignored,
@@ -64,6 +65,7 @@ impl CanvasTool for SignAreaTool<'_> {
fn release(&mut self, pointer: &ToolPointer, _cx: &mut ToolContext<'_>) {
self.drag.drag(pointer.pos);
eprintln!("DIAG ctrl_alt_q_types_an_email_without_quitting: sign release at {:?}, active {}", pointer.pos, self.drag.is_active());
// A click with no drag leaves nothing drawn: `release` gives none under the least side.
let Some((page, rect)) = self.drag.release(LEAST_SIDE) else { return };
let Some(placed) = self.placed.iter().find(|p| p.page == page) else { return };
+2 -2
View File
@@ -81,7 +81,7 @@ fn checking_fixing_skipping_and_reporting() {
h.run_steps(4);
assert!(h.execute("a11y.check"));
h.run_steps(2);
h.get_by_label("Accessibility Checker Options");
h.get_by_role_and_label(Role::Dialog, "Accessibility Checker Options");
h.get_by_label_contains("31 of 32");
h.get_by_label("Document title is showing in title bar");
h.get_by_label("Start Checking").click();
@@ -324,7 +324,7 @@ fn setting_alternate_text_figure_by_figure() {
h.run_steps(4);
assert!(h.execute("a11y.alt_text"));
h.run_steps(2);
h.get_by_label("Set Alternate Text");
h.get_by_role_and_label(Role::Dialog, "Set Alternate Text");
h.get_by_label("Figure 1 of 2 on page 1");
let field = h.get_by_role_and_label(Role::TextInput, "Alternate text");
field.focus();
+9 -9
View File
@@ -124,7 +124,7 @@ fn pick(h: &mut Harness<'static, PdfCraftApp>, label: &str, option: &str) {
/// Clicks the tab `label` of Field Properties.
fn tab(h: &mut Harness<'static, PdfCraftApp>, label: &str) {
h.get_by_label(label).click();
h.get_by_role_and_label(Role::Tab, label).click();
h.run_steps(2);
}
@@ -311,7 +311,7 @@ fn format_validate_and_calculate_tabs() {
tab(&mut h, "Validate");
choose(&mut h, "Field value is in range:");
// The range opens as 0 to 100; unticking "To:" leaves it open above.
h.get_by_label("To:").click();
h.get_by_role_and_label(Role::CheckBox, "To:").click();
h.run_steps(2);
tab(&mut h, "Calculate");
choose(&mut h, "Simplified field notation:");
@@ -384,7 +384,7 @@ fn city_calculation(h: &Harness<'static, PdfCraftApp>) -> (pdfcraft_engine::form
/// What each multi-line box on the tab holds.
fn script_boxes(h: &Harness<'static, PdfCraftApp>) -> Vec<String> {
h.query_all_by_role(Role::MultilineTextInput).filter_map(|n| n.value()).collect()
h.query_all_by_role_and_label(Role::MultilineTextInput, CUSTOM).filter_map(|n| n.value()).collect()
}
/// The script box's description: what a screen reader says about it besides its text.
@@ -395,16 +395,16 @@ fn script_box_description(h: &Harness<'static, PdfCraftApp>) -> Option<String> {
/// Selects everything in the script box and types `text` over it.
fn retype_script(h: &mut Harness<'static, PdfCraftApp>, text: &str) {
h.get_by_role(Role::MultilineTextInput).click();
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).click();
h.run_steps(1);
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
h.get_by_role(Role::MultilineTextInput).type_text(text);
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).type_text(text);
h.run_steps(2);
}
/// Pastes `text` into the script box where its cursor is.
fn paste_script(h: &mut Harness<'static, PdfCraftApp>, text: &str) {
h.get_by_role(Role::MultilineTextInput).click();
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).click();
h.run_steps(1);
h.event(egui::Event::Paste(text.into()));
h.run_steps(2);
@@ -490,7 +490,7 @@ fn an_edit_past_256_kib_is_refused_and_the_next_edit_is_taken() {
assert!(script_boxes(&h) == [full.as_str()], "the box holds the full 256 KiB");
// One byte more is not.
h.key_press(egui::Key::End);
h.get_by_role(Role::MultilineTextInput).type_text(" ");
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).type_text(" ");
h.run_steps(2);
assert!(refused(&h).0, "256 KiB and a byte");
assert!(script_boxes(&h) == [full.as_str()]);
@@ -539,9 +539,9 @@ fn a_script_past_256_kib_shows_its_start_and_is_kept() {
assert_eq!(script_box_description(&h).as_deref(), Some(note));
let start = &long[..MAX_EDITED_SCRIPT - 1];
assert!(script_boxes(&h) == [start], "the box shows the start, up to the last whole character");
h.get_by_role(Role::MultilineTextInput).click();
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).click();
h.run_steps(1);
h.get_by_role(Role::MultilineTextInput).type_text("x");
h.get_by_role_and_label(Role::MultilineTextInput, CUSTOM).type_text("x");
h.run_steps(2);
assert!(script_boxes(&h) == [start], "and can't be typed in");
press(&mut h, "OK");
+3 -3
View File
@@ -137,8 +137,8 @@ fn a_crashed_session_is_offered_and_recovered_unsaved() {
assert_eq!(leftovers(&dir).len(), 1);
let (app, rig) = new_app(&dir);
let mut h = harness_of(app);
h.get_by_label("Recover unsaved documents?");
h.get_by_label("work.pdf");
h.get_by_role_and_label(Role::Dialog, "Recover Unsaved Work");
h.get_by_label_contains("work.pdf");
h.get_by_label("Recover").click();
settle(&mut h, &rig, "recovered document", |app| app.views.len() == 1);
let app = h.state();
@@ -317,7 +317,7 @@ fn encrypted_documents_are_autosaved_encrypted_and_recovered_with_the_password()
assert!(!String::from_utf8_lossy(&saved).contains("Confidential"), "no plaintext on disk");
let (app, rig) = new_app(&dir);
let mut h = harness_of(app);
h.get_by_label_contains("password-protected");
h.get_by_label_contains("Password-protected");
h.get_by_label("Recover").click();
settle(&mut h, &rig, "recovery password prompt", |app| app.password_prompt.is_some());
type_password(&mut h, "pw");