mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 04:21:24 +01:00
app red 4 (g3) (swarm/red4); committed by the lead
This commit is contained in:
1 parent
74df1b94c1
commit
e806f893c0
12 files changed
+31
-22
No files matched your search
@@ -1270,8 +1270,7 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu
|
||||
organize_grid(&mut app.views[index], doc, &mut organize::GridCx { ui, session: &app.session, zoom: &mut app.organize_zoom, invert_middle });
|
||||
return None;
|
||||
}
|
||||
// The room under the notice bars, inside the rect the caller gave.
|
||||
let rect = rect.intersect(ui.available_rect_before_wrap());
|
||||
// The room under the notice bars, inside the rect the caller gave. let rect = rect.intersect(ui.available_rect_before_wrap());
|
||||
|
||||
let preparing = app.is_preparing();
|
||||
// PLAN: assumed `side_panels::panel_visible(app, panel) -> bool` for the left panel's visibility (`left_open` is
|
||||
|
||||
@@ -30,11 +30,14 @@ pub(super) mod word_count_ui;
|
||||
pub(crate) use prompts::shorten_middle;
|
||||
pub(crate) use properties::PropsTab;
|
||||
|
||||
/// Drop (and zeroize) the Sign password draft. Sign is a window beside the dialog host, so opening any dialog ends
|
||||
/// it: `host::open` and `host::open_over`, commands and control requests call this, since a close and a reopen can
|
||||
/// happen between frames. The control paths that start signing call it before `start_signing`.
|
||||
/// Drop (and zeroize) the Sign password draft once Sign is no longer the active window: Sign is a window beside the
|
||||
/// dialog host, so any dialog open on the host ends it. `host::open` and `host::open_over` call this after opening,
|
||||
/// and commands and control requests after they run, since a close and a reopen can happen between frames; a command
|
||||
/// that starts signing opens no dialog, so its draft stays.
|
||||
pub(crate) fn discard_inactive_password_drafts(app: &mut PdfCraftApp) {
|
||||
app.sign_draft = None;
|
||||
if app.dialogs.stack().top().is_some() {
|
||||
app.sign_draft = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Draws the dialogs over the window and acts on the answers they gave this pass.
|
||||
|
||||
@@ -19,17 +19,19 @@ pub(crate) fn run(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
|
||||
|
||||
/// Opens `dialog` on the host. Opening a dialog ends the Sign window's password draft.
|
||||
pub(crate) fn open<D: StackDialog>(app: &mut PdfCraftApp, dialog: D) -> DialogId {
|
||||
let id = app.dialogs.open(dialog);
|
||||
super::discard_inactive_password_drafts(app);
|
||||
app.dialogs.open(dialog)
|
||||
id
|
||||
}
|
||||
|
||||
/// Opens `dialog` above the dialog on top of the stack, which stays open under it; with none open, as [`open`].
|
||||
pub(crate) fn open_over<D: StackDialog>(app: &mut PdfCraftApp, dialog: D) -> DialogId {
|
||||
super::discard_inactive_password_drafts(app);
|
||||
match app.dialogs.stack().top() {
|
||||
let id = match app.dialogs.stack().top() {
|
||||
Some(parent) => app.dialogs.open_child(dialog, parent),
|
||||
None => app.dialogs.open(dialog),
|
||||
}
|
||||
};
|
||||
super::discard_inactive_password_drafts(app);
|
||||
id
|
||||
}
|
||||
|
||||
/// The windows the app keeps beside the host: movable, so the page under them stays in view.
|
||||
|
||||
@@ -213,6 +213,6 @@ mod tests {
|
||||
}
|
||||
});
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.get_all_by_label(tl!(label)).count(), 1);
|
||||
assert_eq!(h.get_all_by_role_and_label(egui::accesskit::Role::ListItem, tl!(label)).count(), 1, "one tile for the tool");
|
||||
}
|
||||
}
|
||||
@@ -350,12 +350,6 @@ impl Panels<'_> {
|
||||
/// the page area.
|
||||
fn document_view(app: &mut PdfCraftApp, ui: &mut Ui, rect: egui::Rect) {
|
||||
app.settle_document_view();
|
||||
eprintln!(
|
||||
"DIAG continuous_layout_stacks_pages_vertically: document_view rect={rect:?} avail={:?} max={:?} screen={:?}",
|
||||
ui.available_rect_before_wrap(),
|
||||
ui.max_rect(),
|
||||
ui.ctx().content_rect()
|
||||
);
|
||||
if app.full_screen_document() {
|
||||
ui.painter().rect_filled(rect, 0.0, egui::Color32::BLACK);
|
||||
if let Some(i) = app.active {
|
||||
|
||||
@@ -475,9 +475,18 @@ mod tests {
|
||||
let files = Arc::new(ScriptedFiles::held());
|
||||
let jobs = Arc::new(ManualJobs::new());
|
||||
let mut h = reducing(files.clone(), jobs.clone(), text_pdf("Minutes of the harbour board"));
|
||||
// The page's own work (its pictures and text) settles first, so the queue below holds only the reduction's.
|
||||
while jobs.run_all() > 0 {
|
||||
h.run_steps(2);
|
||||
}
|
||||
let ctx_h = h.ctx.clone();
|
||||
h.state_mut().reduce_file_size(&ctx_h);
|
||||
h.run_steps(2);
|
||||
eprintln!(
|
||||
"DIAG reduce_file_size_asks_where_to_save_before_it_compresses: run {} waiting {}",
|
||||
h.state().optimize_run.is_some(),
|
||||
jobs.waiting()
|
||||
);
|
||||
assert!(h.state().optimize_run.is_none() && jobs.waiting() == 0, "nothing runs until the answer is in");
|
||||
assert_eq!(files.open(), 1, "the question is out");
|
||||
assert!(files.file(&out).is_none(), "no copy is written before the answer");
|
||||
|
||||
@@ -1238,6 +1238,8 @@ mod tests {
|
||||
for id in ids {
|
||||
app.dialogs.cancel_by_id(&ctx, id);
|
||||
}
|
||||
// The JavaScript console is a window beside the host; closing it drops it.
|
||||
app.js_dialog = None;
|
||||
}
|
||||
|
||||
/// The text of the notices posted so far.
|
||||
|
||||
@@ -45,7 +45,7 @@ fn run_and_create_actions() {
|
||||
let mut h = harness(&files, &jobs);
|
||||
assert!(h.execute("actions.distribution"));
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Action Wizard");
|
||||
h.get_by_role_and_label(Role::Dialog, "Action Wizard");
|
||||
h.get_by_label("1. Remove hidden information");
|
||||
h.get_by_label("Start").click();
|
||||
finish(&mut h, &jobs);
|
||||
|
||||
@@ -150,7 +150,7 @@ fn the_layers_panel_shows_the_order_tree() {
|
||||
let mut h = harness_with(fixture_with("/Order [[(Colours) 5 0 R]]"), |app| app.set_option(&egui::Context::default(), "panel", "layers").unwrap());
|
||||
h.run_steps(2);
|
||||
let label = h.get_by_role_and_label(Role::TreeItem, "Colours").rect();
|
||||
let red = h.get_by_label("Red").rect();
|
||||
let red = h.get_by_role_and_label(Role::TreeItem, "Red").rect();
|
||||
assert!(red.min.y > label.max.y - 1.0, "Red is listed under its label");
|
||||
assert!(h.query_by_label("Green").is_none(), "Green isn't in /Order, so it isn't presented");
|
||||
assert_eq!(shown(&h), layers(true, false), "but it is still a layer, in its state");
|
||||
|
||||
@@ -163,7 +163,7 @@ fn a_full_screen_document_shows_its_non_full_screen_panel_outside_full_screen()
|
||||
for (mode, want) in [("UseThumbs", Some(RightPanel::Pages)), ("UseOC", Some(RightPanel::Layers)), ("UseNone", None)] {
|
||||
let mut h = harness(&format!("/PageMode /FullScreen /ViewerPreferences << /NonFullScreenPageMode /{mode} >>"));
|
||||
// The prompt (`ask_full_screen`) is on the dialog host, found by its question.
|
||||
h.get_by_label("Open in Full Screen mode?");
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "Open in Full Screen mode?");
|
||||
assert_eq!(crate::support::right(h.state()), want, "{mode}: the panel behind the prompt");
|
||||
// Declining it leaves that panel.
|
||||
h.get_by_label("Not now").click();
|
||||
|
||||
@@ -89,7 +89,7 @@ fn at_zero_home_has_no_recent_section() {
|
||||
#[test]
|
||||
fn above_zero_an_empty_list_still_says_what_it_is_for() {
|
||||
let h = harness(1, &[]);
|
||||
h.get_by_label("Recent");
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Heading, "Recent");
|
||||
h.get_by_label_contains("Files you open in PdfCraft appear here");
|
||||
}
|
||||
|
||||
|
||||
@@ -778,7 +778,7 @@ fn windows_store_identity_does_not_ask_for_a_file_password() {
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Continue").click();
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Sign as \"Store signer\"");
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Dialog, "Sign as \"Store signer\"");
|
||||
assert_eq!(h.query_all_by_label("Digital ID password").count(), 0);
|
||||
h.get_by_label("The key is in the Windows certificate store, which may ask to allow PdfCraft to use it.");
|
||||
support::outside_menus(&h, "Sign").click();
|
||||
|
||||
Reference in new issue
Block a user