Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge remote-tracking branch 'origin/main' into codex/new-document-dialog

moppeeerf4dffb061d60
diff --cc crates/ui-egui/src/dialogs.rs
index ae6c101df,a721fdd11..b852bbad6
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -4032,20 -4150,24 +4087,36 @@@ mod tests
assert!(app.ui.dialog.as_ref().unwrap().b("absolutePageNumbers"));
}
+ /// Scroll the dialog body down at `at` until `text` is painted unclipped on screen.
+ fn scroll_to_label(app: &mut DesignApp, ctx: &egui::Context, screen: egui::Rect, at: egui::Pos2, text: &str) -> egui::Rect {
+ for _ in 0..40 {
+ let labels = dialog_frame(app, ctx, screen, vec![]);
+ if let Some((_, rect, _)) = labels.iter().find(|(t, r, clip)| t.trim() == text && screen.contains_rect(*r) && clip.contains_rect(*r)) {
+ return *rect;
+ }
+ scroll_dialog(app, ctx, screen, at, egui::vec2(0.0, -60.0));
+ }
+ panic!("{text} never scrolled into view");
+ }
+
+ #[test]
+ fn preferences_ok_saves_a_story_editor_size_that_loads_back() {
+ // `ui.dialog.set` takes any value; a size that isn't finite is saved as `null`.
+ let sizes = [(json!("nan"), 20.0), (json!("inf"), 20.0), (json!(null), 20.0), (json!(1e39), 36.0), (json!(3), 8.0), (json!(11), 11.0)];
+ for (size, want) in sizes {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ app.ui.story_editor_size = 20.0;
+ app.run("app.preferences", json!({})).unwrap();
+ app.ui.dialog.as_mut().unwrap().fields.insert("storyEditorSize".into(), size);
+ confirm(&mut app).unwrap();
+ let saved = serde_json::to_vec(&app.ui).unwrap();
+ assert_eq!(crate::UiState::from_preferences_json(&saved).unwrap().story_editor_size, want);
+ }
+ }
+
#[test]
- fn new_document_vertical_scroll_reaches_last_field() {
+ fn new_document_vertical_scroll_reaches_every_field_and_preset() {
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
app.run("app.newDocumentDialog", json!({})).unwrap();
let ctx = dialog_context("en");