| author | |
| committer | |
| log | 29745d45b154e4fdf378bd73d297e5b657c23c5b |
| tree | 32be5c3ef4416303d7931a6ea02b23b98075f118 |
| parent | 73a0686b3eb03e75b195af5554057fd8a3426f51 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Save As and Print passed no focus to the key handling that takes Enter, so Enter did
nothing in them; Properties, Options, Link, the tag editor, Customize Tags, Connect to
Server, password protection and Unpack took it only from a field, so not while the dialog
itself held the focus, as it does when it opens. Each now takes Enter from the dialog as
well. Customize Tags, which took no Enter at all, takes it once a change makes OK
available. The default button is now exposed to assistive technology as the default
button. Escape already closed every dialog. Replays now test Enter and Escape in Save As
and Export as PDF, through a replay answer for the save panel the same as the one #77
adds.
- Enter now chooses the default button in Save As, Print, Export as PDF and every other dialog.
Assisted-by: claude-opus-5.516 files changed, 124 insertions(+), 14 deletions(-)
crates/snowbound/src/link.rs+2-2| ... | @@ -100,9 +100,9 @@ impl State { | ... | @@ -100,9 +100,9 @@ impl State { |
| 100 | } | 100 | } |
| 101 | let theme = ui.theme.clone(); | 101 | let theme = ui.theme.clone(); |
| 102 | let row = theme.font_size * 2.0; | 102 | let row = theme.font_size * 2.0; |
| 103 | let fields = [text_field(), address_field(), search_field()]; | 103 | let owners = [id(), text_field(), address_field()]; |
| 104 | let entered = | 104 | let entered = |
| 105 | ui::popup::navigation(ui, &fields[..2], &[NamedKey::Enter]).contains(&NamedKey::Enter); | 105 | ui::popup::navigation(ui, &owners, &[NamedKey::Enter]).contains(&NamedKey::Enter); |
| 106 | ui.open_as( | 106 | ui.open_as( |
| 107 | id(), | 107 | id(), |
| 108 | Spec { | 108 | Spec { |
crates/snowbound/src/linux.rs+3| ... | @@ -1693,6 +1693,9 @@ pub fn pick_new( | ... | @@ -1693,6 +1693,9 @@ pub fn pick_new( |
| 1693 | folder: Option<&std::path::Path>, | 1693 | folder: Option<&std::path::Path>, |
| 1694 | reply: Reply<PathBuf>, | 1694 | reply: Reply<PathBuf>, |
| 1695 | ) { | 1695 | ) { |
| 1696 | if let Some(path) = crate::replayed_answer() { | ||
| 1697 | return reply.send(path); | ||
| 1698 | } | ||
| 1696 | use std::os::unix::ffi::OsStrExt; | 1699 | use std::os::unix::ffi::OsStrExt; |
| 1697 | let mut options = HashMap::from([ | 1700 | let mut options = HashMap::from([ |
| 1698 | ("current_name", Value::from(name.to_owned())), | 1701 | ("current_name", Value::from(name.to_owned())), |
crates/snowbound/src/macos.rs+3| ... | @@ -888,6 +888,9 @@ pub fn pick_new( | ... | @@ -888,6 +888,9 @@ pub fn pick_new( |
| 888 | folder: Option<&std::path::Path>, | 888 | folder: Option<&std::path::Path>, |
| 889 | reply: Reply<std::path::PathBuf>, | 889 | reply: Reply<std::path::PathBuf>, |
| 890 | ) { | 890 | ) { |
| 891 | if let Some(path) = crate::replayed_answer() { | ||
| 892 | return reply.send(path); | ||
| 893 | } | ||
| 891 | let mtm = MainThreadMarker::new().expect("Panels belong to the main thread"); | 894 | let mtm = MainThreadMarker::new().expect("Panels belong to the main thread"); |
| 892 | unsafe { | 895 | unsafe { |
| 893 | let panel = NSSavePanel::savePanel(mtm); | 896 | let panel = NSSavePanel::savePanel(mtm); |
crates/snowbound/src/main.rs+23| ... | @@ -432,6 +432,9 @@ enum Replay { | ... | @@ -432,6 +432,9 @@ enum Replay { |
| 432 | ClosePane, | 432 | ClosePane, |
| 433 | /// Writes the settings as they would be saved, as a screenshot's replay saves none. | 433 | /// Writes the settings as they would be saved, as a screenshot's replay saves none. |
| 434 | Settings(PathBuf), | 434 | Settings(PathBuf), |
| 435 | /// What the next save panel answers, in place of showing itself. | ||
| 436 | #[cfg(not(target_arch = "wasm32"))] | ||
| 437 | Answer(PathBuf), | ||
| 435 | Quit, | 438 | Quit, |
| 436 | } | 439 | } |
| 437 | 440 | ||
| ... | @@ -452,6 +455,19 @@ fn automated() -> bool { | ... | @@ -452,6 +455,19 @@ fn automated() -> bool { |
| 452 | AUTOMATED.load(Ordering::Relaxed) | 455 | AUTOMATED.load(Ordering::Relaxed) |
| 453 | } | 456 | } |
| 454 | 457 | ||
| 458 | /// What a replay told the next save panel to answer. | ||
| 459 | #[cfg(not(target_arch = "wasm32"))] | ||
| 460 | static ANSWER: Mutex<Option<PathBuf>> = Mutex::new(None); | ||
| 461 | |||
| 462 | /// The answer a replay gave the save panel about to show, taken. | ||
| 463 | #[cfg(not(target_arch = "wasm32"))] | ||
| 464 | fn replayed_answer() -> Option<PathBuf> { | ||
| 465 | ANSWER | ||
| 466 | .lock() | ||
| 467 | .unwrap_or_else(std::sync::PoisonError::into_inner) | ||
| 468 | .take() | ||
| 469 | } | ||
| 470 | |||
| 455 | /// With `SNOWBOUND_PROFILE` set, prints how long a phase of the frame took since `start`. | 471 | /// With `SNOWBOUND_PROFILE` set, prints how long a phase of the frame took since `start`. |
| 456 | fn lap(phase: &str, start: Instant) { | 472 | fn lap(phase: &str, start: Instant) { |
| 457 | static PROFILE: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); | 473 | static PROFILE: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); |
| ... | @@ -6775,6 +6791,12 @@ impl State { | ... | @@ -6775,6 +6791,12 @@ impl State { |
| 6775 | eprintln!("{error}"); | 6791 | eprintln!("{error}"); |
| 6776 | } | 6792 | } |
| 6777 | } | 6793 | } |
| 6794 | #[cfg(not(target_arch = "wasm32"))] | ||
| 6795 | Replay::Answer(path) => { | ||
| 6796 | *ANSWER | ||
| 6797 | .lock() | ||
| 6798 | .unwrap_or_else(std::sync::PoisonError::into_inner) = Some(path) | ||
| 6799 | } | ||
| 6778 | } | 6800 | } |
| 6779 | // A covered window gets no redraws, so each step draws its own frame. | 6801 | // A covered window gets no redraws, so each step draws its own frame. |
| 6780 | if let Err(error) = self.frame() { | 6802 | if let Err(error) = self.frame() { |
| ... | @@ -7272,6 +7294,7 @@ fn replay(script: String, proxy: EventLoopProxy<UserEvent>) -> Result<(), Box<dy | ... | @@ -7272,6 +7294,7 @@ fn replay(script: String, proxy: EventLoopProxy<UserEvent>) -> Result<(), Box<dy |
| 7272 | ))), | 7294 | ))), |
| 7273 | "wait" => Err(std::time::Duration::from_millis(rest.parse()?)), | 7295 | "wait" => Err(std::time::Duration::from_millis(rest.parse()?)), |
| 7274 | "quit" => Ok(Replay::Quit), | 7296 | "quit" => Ok(Replay::Quit), |
| 7297 | "answer" => Ok(Replay::Answer(rest.into())), | ||
| 7275 | "resize" => Ok(Replay::Resize( | 7298 | "resize" => Ok(Replay::Resize( |
| 7276 | numbers()? | 7299 | numbers()? |
| 7277 | .try_into() | 7300 | .try_into() |
crates/snowbound/src/options.rs+1-1| ... | @@ -425,7 +425,7 @@ impl State { | ... | @@ -425,7 +425,7 @@ impl State { |
| 425 | let row = row_height(&theme); | 425 | let row = row_height(&theme); |
| 426 | let ui = &mut self.ui; | 426 | let ui = &mut self.ui; |
| 427 | let column = labels_column(ui); | 427 | let column = labels_column(ui); |
| 428 | let entered = ui::popup::navigation(ui, &[user_name()], &[NamedKey::Enter]) | 428 | let entered = ui::popup::navigation(ui, &[id(), user_name()], &[NamedKey::Enter]) |
| 429 | .contains(&NamedKey::Enter); | 429 | .contains(&NamedKey::Enter); |
| 430 | // As tall as its contents up to the window, which the list then scrolls within. | 430 | // As tall as its contents up to the window, which the list then scrolls within. |
| 431 | let loose = Extent { | 431 | let loose = Extent { |
crates/snowbound/src/print.rs+2-1| ... | @@ -169,7 +169,8 @@ impl State { | ... | @@ -169,7 +169,8 @@ impl State { |
| 169 | session.tabs[session.tab].name.clone() | 169 | session.tabs[session.tab].name.clone() |
| 170 | }); | 170 | }); |
| 171 | let theme = ui.theme.clone(); | 171 | let theme = ui.theme.clone(); |
| 172 | let entered = ui::popup::navigation(ui, &[], &[NamedKey::Enter]).contains(&NamedKey::Enter); | 172 | let entered = |
| 173 | ui::popup::navigation(ui, &[id()], &[NamedKey::Enter]).contains(&NamedKey::Enter); | ||
| 173 | let title = if dialog.export { | 174 | let title = if dialog.export { |
| 174 | "Export as PDF" | 175 | "Export as PDF" |
| 175 | } else { | 176 | } else { |
crates/snowbound/src/properties.rs+1-1| ... | @@ -58,7 +58,7 @@ impl State { | ... | @@ -58,7 +58,7 @@ impl State { |
| 58 | } | 58 | } |
| 59 | let theme = ui.theme.clone(); | 59 | let theme = ui.theme.clone(); |
| 60 | let row = theme.font_size * 2.0; | 60 | let row = theme.font_size * 2.0; |
| 61 | let entered = ui::popup::navigation(ui, &[name_field()], &[NamedKey::Enter]) | 61 | let entered = ui::popup::navigation(ui, &[id(), name_field()], &[NamedKey::Enter]) |
| 62 | .contains(&NamedKey::Enter); | 62 | .contains(&NamedKey::Enter); |
| 63 | ui.open_as( | 63 | ui.open_as( |
| 64 | id(), | 64 | id(), |
crates/snowbound/src/protection.rs+2-1| ... | @@ -388,7 +388,8 @@ impl State { | ... | @@ -388,7 +388,8 @@ impl State { |
| 388 | ui.set_focus(Some(field(0))); | 388 | ui.set_focus(Some(field(0))); |
| 389 | } | 389 | } |
| 390 | let entered = | 390 | let entered = |
| 391 | ui::popup::navigation(ui, &owners, &[NamedKey::Enter]).contains(&NamedKey::Enter); | 391 | ui::popup::navigation(ui, &[&[id()], &owners[..]].concat(), &[NamedKey::Enter]) |
| 392 | .contains(&NamedKey::Enter); | ||
| 392 | let protected = asking.library.protected(&asking.path); | 393 | let protected = asking.library.protected(&asking.path); |
| 393 | let title = match asking.dialog { | 394 | let title = match asking.dialog { |
| 394 | Dialog::Unlock(..) => "Protected Section", | 395 | Dialog::Unlock(..) => "Protected Section", |
crates/snowbound/src/save_as.rs+2-1| ... | @@ -85,7 +85,8 @@ impl State { | ... | @@ -85,7 +85,8 @@ impl State { |
| 85 | } | 85 | } |
| 86 | let theme = ui.theme.clone(); | 86 | let theme = ui.theme.clone(); |
| 87 | let row = theme.font_size * 2.0; | 87 | let row = theme.font_size * 2.0; |
| 88 | let entered = ui::popup::navigation(ui, &[], &[NamedKey::Enter]).contains(&NamedKey::Enter); | 88 | let entered = |
| 89 | ui::popup::navigation(ui, &[id()], &[NamedKey::Enter]).contains(&NamedKey::Enter); | ||
| 89 | ui.open_as( | 90 | ui.open_as( |
| 90 | id(), | 91 | id(), |
| 91 | Spec { | 92 | Spec { |
crates/snowbound/src/server.rs+2-1| ... | @@ -586,8 +586,9 @@ impl State { | ... | @@ -586,8 +586,9 @@ impl State { |
| 586 | Step::SignIn => &[user_field(), password_field(), domain_field()], | 586 | Step::SignIn => &[user_field(), password_field(), domain_field()], |
| 587 | Step::Browse => &[], | 587 | Step::Browse => &[], |
| 588 | }; | 588 | }; |
| 589 | let owners: Vec<Id> = [id()].into_iter().chain(fields.iter().copied()).collect(); | ||
| 589 | let entered = | 590 | let entered = |
| 590 | ui::popup::navigation(ui, fields, &[NamedKey::Enter]).contains(&NamedKey::Enter); | 591 | ui::popup::navigation(ui, &owners, &[NamedKey::Enter]).contains(&NamedKey::Enter); |
| 591 | ui.open_as( | 592 | ui.open_as( |
| 592 | id(), | 593 | id(), |
| 593 | Spec { | 594 | Spec { |
crates/snowbound/src/tags.rs+7-3| ... | @@ -402,6 +402,8 @@ impl State { | ... | @@ -402,6 +402,8 @@ impl State { |
| 402 | return; | 402 | return; |
| 403 | } | 403 | } |
| 404 | let theme = ui.theme.clone(); | 404 | let theme = ui.theme.clone(); |
| 405 | let entered = | ||
| 406 | ui::popup::navigation(ui, &[id()], &[NamedKey::Enter]).contains(&NamedKey::Enter); | ||
| 405 | dialog(ui, id(), "Customize Tags", WIDTH); | 407 | dialog(ui, id(), "Customize Tags", WIDTH); |
| 406 | ui.leaf( | 408 | ui.leaf( |
| 407 | "all", | 409 | "all", |
| ... | @@ -525,7 +527,9 @@ impl State { | ... | @@ -525,7 +527,9 @@ impl State { |
| 525 | }); | 527 | }); |
| 526 | ui.close(); | 528 | ui.close(); |
| 527 | crate::buttons(ui); | 529 | crate::buttons(ui); |
| 528 | let [cancel, ok] = ui::dialog_buttons(ui, "OK", list.tags != self.tags); | 530 | let changed = list.tags != self.tags; |
| 531 | let [cancel, ok] = ui::dialog_buttons(ui, "OK", changed); | ||
| 532 | let ok = ok || entered && changed; | ||
| 529 | ui.close(); | 533 | ui.close(); |
| 530 | if let Some(place) = list.selected { | 534 | if let Some(place) = list.selected { |
| 531 | if up { | 535 | if up { |
| ... | @@ -657,8 +661,8 @@ fn tag_editor( | ... | @@ -657,8 +661,8 @@ fn tag_editor( |
| 657 | } | 661 | } |
| 658 | let (tag, place) = editor.as_mut()?; | 662 | let (tag, place) = editor.as_mut()?; |
| 659 | let theme = ui.theme.clone(); | 663 | let theme = ui.theme.clone(); |
| 660 | let entered = | 664 | let entered = ui::popup::navigation(ui, &[editor_id(), name_field()], &[NamedKey::Enter]) |
| 661 | ui::popup::navigation(ui, &[name_field()], &[NamedKey::Enter]).contains(&NamedKey::Enter); | 665 | .contains(&NamedKey::Enter); |
| 662 | let title = if place.is_some() { | 666 | let title = if place.is_some() { |
| 663 | "Modify Tag" | 667 | "Modify Tag" |
| 664 | } else { | 668 | } else { |
crates/snowbound/src/unpack.rs+1-1| ... | @@ -63,7 +63,7 @@ impl State { | ... | @@ -63,7 +63,7 @@ impl State { |
| 63 | } | 63 | } |
| 64 | let theme = ui.theme.clone(); | 64 | let theme = ui.theme.clone(); |
| 65 | let row = theme.font_size * 2.0; | 65 | let row = theme.font_size * 2.0; |
| 66 | let entered = ui::popup::navigation(ui, &[name_field()], &[NamedKey::Enter]) | 66 | let entered = ui::popup::navigation(ui, &[id(), name_field()], &[NamedKey::Enter]) |
| 67 | .contains(&NamedKey::Enter); | 67 | .contains(&NamedKey::Enter); |
| 68 | ui.open_as( | 68 | ui.open_as( |
| 69 | id(), | 69 | id(), |
crates/snowbound/src/windows.rs+3| ... | @@ -1710,6 +1710,9 @@ pub fn pick_new( | ... | @@ -1710,6 +1710,9 @@ pub fn pick_new( |
| 1710 | folder: Option<&std::path::Path>, | 1710 | folder: Option<&std::path::Path>, |
| 1711 | reply: Reply<PathBuf>, | 1711 | reply: Reply<PathBuf>, |
| 1712 | ) { | 1712 | ) { |
| 1713 | if let Some(path) = crate::replayed_answer() { | ||
| 1714 | return reply.send(path); | ||
| 1715 | } | ||
| 1713 | pick( | 1716 | pick( |
| 1714 | title, | 1717 | title, |
| 1715 | &[("All files", "*.*")], | 1718 | &[("All files", "*.*")], |
crates/snowbound/tests/replay.rs+70| ... | @@ -1793,6 +1793,76 @@ fn closing_split_panes_leaves_the_window_as_it_was() { | ... | @@ -1793,6 +1793,76 @@ fn closing_split_panes_leaves_the_window_as_it_was() { |
| 1793 | ); | 1793 | ); |
| 1794 | } | 1794 | } |
| 1795 | 1795 | ||
| 1796 | /// Opens Save As with its chord. | ||
| 1797 | const SAVE_AS: [&str; 5] = [ | ||
| 1798 | "modifiers shift command", | ||
| 1799 | "key s", | ||
| 1800 | "modifiers", | ||
| 1801 | "settle", | ||
| 1802 | "wait 300", | ||
| 1803 | ]; | ||
| 1804 | |||
| 1805 | /// Enter takes a dialog's default button, which assistive technology is told is the default: | ||
| 1806 | /// Save As saves the page where the save panel answers, and Export as PDF writes the PDF. | ||
| 1807 | #[test] | ||
| 1808 | fn enter_takes_the_default_button_of_save_as_and_export_as_pdf() { | ||
| 1809 | let scratch = Scratch::new("dialog-enter"); | ||
| 1810 | let notebook = | ||
| 1811 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus/cross-container/candidate"); | ||
| 1812 | let (saved, pdf) = (scratch.0.join("Saved.one"), scratch.0.join("Exported.pdf")); | ||
| 1813 | let answer_saved = format!("answer {}", saved.display()); | ||
| 1814 | let answer_pdf = format!("answer {}", pdf.display()); | ||
| 1815 | let mut steps: Vec<&str> = SAVE_AS.to_vec(); | ||
| 1816 | steps.extend([ | ||
| 1817 | "accessibility save-as", | ||
| 1818 | &answer_saved, | ||
| 1819 | "key Enter", | ||
| 1820 | "settle", | ||
| 1821 | "modifiers shift command", | ||
| 1822 | "key p", | ||
| 1823 | "modifiers", | ||
| 1824 | "settle", | ||
| 1825 | "type Export as PDF", | ||
| 1826 | "settle", | ||
| 1827 | "key Enter", | ||
| 1828 | "settle", | ||
| 1829 | "wait 300", | ||
| 1830 | "accessibility export", | ||
| 1831 | &answer_pdf, | ||
| 1832 | "key Enter", | ||
| 1833 | "settle", | ||
| 1834 | "accessibility after", | ||
| 1835 | ]); | ||
| 1836 | let [save_as, export, after] = replay(&scratch, Some(&notebook), &steps) | ||
| 1837 | .try_into() | ||
| 1838 | .unwrap(); | ||
| 1839 | assert!(save_as.contains(r#"DefaultButton "Save As""#), "{save_as}"); | ||
| 1840 | assert!(export.contains(r#"DefaultButton "Export""#), "{export}"); | ||
| 1841 | assert!(!after.contains("Dialog"), "{after}"); | ||
| 1842 | assert!(std::fs::metadata(&saved).is_ok_and(|file| file.len() > 0)); | ||
| 1843 | assert!(std::fs::read(&pdf).is_ok_and(|bytes| bytes.starts_with(b"%PDF"))); | ||
| 1844 | } | ||
| 1845 | |||
| 1846 | /// Escape closes a dialog without doing what it offers. | ||
| 1847 | #[test] | ||
| 1848 | fn escape_closes_save_as() { | ||
| 1849 | let scratch = Scratch::new("dialog-escape"); | ||
| 1850 | let notebook = | ||
| 1851 | Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus/cross-container/candidate"); | ||
| 1852 | let mut steps: Vec<&str> = SAVE_AS.to_vec(); | ||
| 1853 | steps.extend([ | ||
| 1854 | "accessibility open", | ||
| 1855 | "key Escape", | ||
| 1856 | "settle", | ||
| 1857 | "accessibility closed", | ||
| 1858 | ]); | ||
| 1859 | let [open, closed] = replay(&scratch, Some(&notebook), &steps) | ||
| 1860 | .try_into() | ||
| 1861 | .unwrap(); | ||
| 1862 | assert!(open.contains(r#"Dialog "Save As""#), "{open}"); | ||
| 1863 | assert!(!closed.contains(r#"Dialog "Save As""#), "{closed}"); | ||
| 1864 | } | ||
| 1865 | |||
| 1796 | /// A layout of panes as the settings keep it, on pages of `notebook`'s sections: a pane on | 1866 | /// A layout of panes as the settings keep it, on pages of `notebook`'s sections: a pane on |
| 1797 | /// the first, then a part below it, the second above the third. A page of `None` is gone. | 1867 | /// the first, then a part below it, the second above the third. A page of `None` is gone. |
| 1798 | fn layout(notebook: &Path, panes: [(&str, Option<&str>); 3]) -> serde_json::Value { | 1868 | fn layout(notebook: &Path, panes: [(&str, Option<&str>); 3]) -> serde_json::Value { |
crates/ui/src/widgets.rs+1-1| ... | @@ -54,7 +54,7 @@ pub fn dialog_buttons(ui: &mut Ui, text: &str, enabled: bool) -> [bool; 2] { | ... | @@ -54,7 +54,7 @@ pub fn dialog_buttons(ui: &mut Ui, text: &str, enabled: bool) -> [bool; 2] { |
| 54 | radius: 4.0, | 54 | radius: 4.0, |
| 55 | pad: [theme.font_size * 0.75, 0.0], | 55 | pad: [theme.font_size * 0.75, 0.0], |
| 56 | center: true, | 56 | center: true, |
| 57 | role: Some(Role::Button), | 57 | role: Some(Role::DefaultButton), |
| 58 | ..Spec::default() | 58 | ..Spec::default() |
| 59 | }; | 59 | }; |
| 60 | let clicked = ui.leaf("default", spec).clicked; | 60 | let clicked = ui.leaf("default", spec).clicked; |
tools/canvas/README.md+1-1| ... | @@ -56,7 +56,7 @@ As in OneNote 2010, Notebook Recycle Bin (File menu, a notebook's context menu, | ... | @@ -56,7 +56,7 @@ As in OneNote 2010, Notebook Recycle Bin (File menu, a notebook's context menu, |
| 56 | 56 | ||
| 57 | The `ui` crate builds every frame from the application's state. A cache keyed by stable box ids keeps hover, press, focus, scroll and animation values, and the previous frame's layout routes the frame's input before building, so a frame answers input one layout late and paints with its own. Sizes are solved per axis after building: fixed, label-sized, a fraction of an ancestor, or the sum of children, with overflow shared out by each box's strictness. The page is a custom box: `ui` routes it the pointer, wheel, key and input-method events that land on it, in order, and the host hands them to `PageView` and paints the page in a clipped layer of the same frame. Page scrollbars are `ui` widgets over that box; the canvas reports only its scroll bounds. Text fields edit through `draw::edit`, as the page does, so keys, clicks and drags select and move the same way in both. Work the frame asks for (page requests, saving) runs after the frame is painted and requests the frame that shows it. Opening a section or page reads and lays it out on a thread of its own while the current page stays live; the newest replaces the page once the pictures it shows first are drawn, or after 200 ms. Its tab is selected at once, and an open that takes over 80 ms shows a page's outline in place of the page leaving, which takes no input. The pages beside the open one, the sections beside the open section and a hovered page or section tab are read ahead on a thread of their own. A notebook keeps the last three sections left or read ahead open, which `Library::open` hands out, and the last 32 pages shown or read ahead keep their scenes, with up to 128 MiB of decoded pictures, so a page shown again is laid out afresh around pictures already drawn. | 57 | The `ui` crate builds every frame from the application's state. A cache keyed by stable box ids keeps hover, press, focus, scroll and animation values, and the previous frame's layout routes the frame's input before building, so a frame answers input one layout late and paints with its own. Sizes are solved per axis after building: fixed, label-sized, a fraction of an ancestor, or the sum of children, with overflow shared out by each box's strictness. The page is a custom box: `ui` routes it the pointer, wheel, key and input-method events that land on it, in order, and the host hands them to `PageView` and paints the page in a clipped layer of the same frame. Page scrollbars are `ui` widgets over that box; the canvas reports only its scroll bounds. Text fields edit through `draw::edit`, as the page does, so keys, clicks and drags select and move the same way in both. Work the frame asks for (page requests, saving) runs after the frame is painted and requests the frame that shows it. Opening a section or page reads and lays it out on a thread of its own while the current page stays live; the newest replaces the page once the pictures it shows first are drawn, or after 200 ms. Its tab is selected at once, and an open that takes over 80 ms shows a page's outline in place of the page leaving, which takes no input. The pages beside the open one, the sections beside the open section and a hovered page or section tab are read ahead on a thread of their own. A notebook keeps the last three sections left or read ahead open, which `Library::open` hands out, and the last 32 pages shown or read ahead keep their scenes, with up to 128 MiB of decoded pictures, so a page shown again is laid out afresh around pictures already drawn. |
| 58 | 58 | ||
| 59 | A covered window receives no redraws, so interaction can be scripted: `SNOWBOUND_REPLAY` names a file of `move X Y`, `press [right]`, `release [right]`, `wheel DX DY`, `pinch FACTOR`, `key NAME`, `type TEXT`, `modifiers [shift] [command]`, `wait MS`, `snapshot PNG_PATH`, `accessibility TEXT_PATH` (the window's accessibility tree, a node a line, as the platform shows it), `appearance light|dark`, `resize WIDTH HEIGHT`, `renderer NAME` (switches as Options' Renderer does) and `quit` lines in logical pixels, and each step and every 16 ms of a wait draws a frame. With `--screenshot` as well, the window stays hidden and only the replay's snapshots capture it. Snapshots wait for the page's pictures, file icons and background art to finish rasterizing; `SNOWBOUND_FRAMES` frames never wait, so art appears in the first frame drawn after it is ready. Snapshots omit the window's traffic lights, which AppKit draws. Replays edit and save like a user, so point them at a copy of a notebook. Their edits carry the settings' user name, so give fixture runs a `--settings` file holding `{"user_name": "Snowbound Test"}`. A replay or `--screenshot` run never reads the account's own settings or iCloud: without `--settings` it starts from none, and its iCloud folder is only the one `SNOWBOUND_ICLOUD_FOLDER` names. | 59 | A covered window receives no redraws, so interaction can be scripted: `SNOWBOUND_REPLAY` names a file of `move X Y`, `press [right]`, `release [right]`, `wheel DX DY`, `pinch FACTOR`, `key NAME`, `type TEXT`, `modifiers [shift] [command]`, `wait MS`, `snapshot PNG_PATH`, `accessibility TEXT_PATH` (the window's accessibility tree, a node a line, as the platform shows it), `appearance light|dark`, `resize WIDTH HEIGHT`, `renderer NAME` (switches as Options' Renderer does), `answer PATH` (what the next save panel answers, without showing) and `quit` lines in logical pixels, and each step and every 16 ms of a wait draws a frame. With `--screenshot` as well, the window stays hidden and only the replay's snapshots capture it. Snapshots wait for the page's pictures, file icons and background art to finish rasterizing; `SNOWBOUND_FRAMES` frames never wait, so art appears in the first frame drawn after it is ready. Snapshots omit the window's traffic lights, which AppKit draws. Replays edit and save like a user, so point them at a copy of a notebook. Their edits carry the settings' user name, so give fixture runs a `--settings` file holding `{"user_name": "Snowbound Test"}`. A replay or `--screenshot` run never reads the account's own settings or iCloud: without `--settings` it starts from none, and its iCloud folder is only the one `SNOWBOUND_ICLOUD_FOLDER` names. |
| 60 | 60 | ||
| 61 | ```sh | 61 | ```sh |
| 62 | cp -RL SOURCE_NOTEBOOK /tmp/notebook-copy && chmod u+w /tmp/notebook-copy/*.one | 62 | cp -RL SOURCE_NOTEBOOK /tmp/notebook-copy && chmod u+w /tmp/notebook-copy/*.one |