Skip to content

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

Merge PR #1066 and #1067: Pages panel scroll areas, divider and Panel Options

aionggdbf495bee904
diff --cc ROADMAP.md
index c90b3b272,d1b15c889..95a83f641
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -346,60 -343,16 +346,62 @@@ list) · [roadmap.md](docs/roadmap.md)
## Progress log
-- **2026-10-13** · Switching between document and parent pages refreshes the canvas immediately, preventing black parent pages and stale document objects when the zoom stays the same. Ordinary edits retain partial repainting. No readiness percentage change.
-
Newest first.
-- 2026-10-15: Pages panel › Panel Options…, as InDesign's: page and parent sizes from Extra Small to Jumbo, Show Thumbnails, parents shown vertically or side by side, Pages or Parents on Top, and how the two parts share a resize; in the panel menu, the page menu and the right-click menu on the panel's empty part.
-- 2026-10-15: The Pages panel is laid out as InDesign's: parents and pages scroll on their own, a divider between them shows more or fewer parents, and the footer (page count, Edit page size, Create new page, Delete) stays at the bottom. It scrolled away with the pages.
-- **2026-10-14** · The Type tool draws a new text frame over a locked empty frame, as InDesign does, instead of turning the locked frame into a text frame. No readiness percentage change.
-- **2026-10-14** · 100% black shows as pure black on screen by default, as InDesign's Appearance of Black does out of the box (Display All Blacks as Rich Black); Preferences › Appearance of Black › Display All Blacks Accurately still shows it as the dark grey it prints, and a saved choice is kept. No readiness percentage change.
-- **2026-10-14** · Pathfinder keeps the frontmost object, as InDesign does: a photo placed over shapes and intersected with them shows through the shapes (it was dropped, and the shapes kept their black fill); Add, Exclude Overlap and Minus Back take the front object's fill too, Subtract still keeps the back one. No readiness percentage change.
-- **2026-10-14** · The Color panel's Tint field keeps what is typed while it has focus and applies it on Enter or when it loses focus, clamped to 0–100 %. Typing 60 over 100 % no longer snaps back to 100 after the first digit (10060), and a typed tint is no longer ignored. No readiness percentage change.
+- **2026-10-16** · Threading: the loaded text cursor threads into a text frame inside a group (it hit the group and showed it could not thread); a plain click still selects the group (#1075). Gap 27 closed. No readiness percentage change.
+- **2026-10-16** · A swatch applied to a placed greyscale or bitmap image colours it, as in InDesign: IDML's `<Image FillColor>` is read and written, greyscale pixels become a tint of the swatch on opaque white and a bitmap's white lets the frame show through, on screen and in PDF (spot swatches print on their plate). Colour images keep their colours. Applying the swatch from the Swatches panel comes next. No readiness percentage change.
+- **2026-10-15** · Color Theme: the toolbar tool previews up to five colours from a placed raster and adds them as one undoable swatch group. Local deterministic extraction; transparent padding is ignored. No readiness percentage change.
+- **2026-10-15** · Applying text styles removes matching local formatting so capture sources
+ inherit later edits; real overrides and named character styles remain.
+- **2026-10-15** · Redefine paragraph and character styles from local formatting, including the
+ Styles panel context menu, global updates and one-step undo.
+- **2026-10-15** · Paragraph Styles marks local character overrides and offers Clear Overrides
+ in the style row menu; named character styles and equal local values are not false overrides.
+- **2026-10-15** · Existing paragraph and character styles preview their attribute edits in
+ Style Options; Cancel restores the document and OK records one edit.
+- **2026-10-15** · Paragraph Style Options summarizes captured and pending color, size and
+ paragraph settings relative to the Based On style.
+- **2026-10-15** · Typography uses named panel groups with the Control panel and restores that
+ arrangement on Reset Workspace, leaving the page clear until a panel is opened. No readiness percentage change.
+- **2026-10-15** · Character panel: dragging a variable font axis slider previews on the page and is one undo step when let go (with several axes it piled up an undo step per frame); each axis takes a typed value, and narrow axes (Skia's 0.48–3.2) step by hundredths instead of jumping to whole numbers. The fields line up in two columns, auto leading shows in parentheses, and an axis-set style shows its axes. New `edit.preview` / `edit.commitPreview` / `edit.cancelPreview` commands give panels, the control channel and MCP live previews. No readiness percentage change.
+- **2026-10-15** · Selection tool: once a frame's content is selected (double-click, or the content grabber), the pointer is a hand over it and a drag anywhere on it moves the content inside the frame (Shift keeps one axis), as in InDesign; it moved the frame unless the press was on the grabber. No readiness percentage change.
+- **2026-10-15** · Scaling a text frame (Cmd+Shift-dragging a handle, the Scale tool, Transform panel scale fields) sets its text larger or smaller and leaves the frame at 100%, as InDesign's default When Scaling: Apply to Content does; it used to keep the text's size with the scale on the frame. No readiness percentage change.
+- **2026-10-15** · With nothing selected, the Tools panel's fill and stroke (the Color Picker, swatches, Apply None, Swap, Default) set the colours new shapes are drawn with, as InDesign's document defaults; the proxy shows them. They were refused ("nothing selected").
+- **2026-10-15** · The Eyedropper with text selected picks up the formatting of the text it clicks (character style and overrides, paragraph style and overrides) and applies it to the selection, as InDesign's does; it copied the clicked frame's fill and stroke instead. No readiness percentage change.
+- **2026-10-15** · A0, A1 and A2 poster presets are available in New Document, Document Setup, Properties, the Page tool and the Pages panel's size menu, as well as `file.new` and `layout.pageSize`. No readiness percentage change.
+- **2026-10-15** · Define Lists… is listed under Type › Bulleted & Numbered Lists in command search and Edit › Menus, matching the menu, and the parity doc no longer lists a Type › Paragraph Rules… menu item that does not exist. No readiness percentage change.
+- **2026-10-15** · Pressing Enter in the Layers panel's rename field without typing leaves an unnamed object unnamed, so it keeps following its automatic label instead of taking it as a fixed name. No readiness percentage change.
+- **2026-10-15** · Apply Gradient (.) with the Stroke box in front puts a new default gradient on the stroke in one undo step and leaves the fill's swatch and tint as they were. No readiness percentage change.
+- **2026-10-15** · In a facing-pages document, two odd-numbered pages in a row after a section restart (page 2 starting at 1) each get their own spread and stay right pages, instead of sharing a spread with an odd page on the left. No readiness percentage change.
+- **2026-10-15** · Character formatting set at a caret on a blank line (an empty paragraph) applies to the line's paragraph mark and to the text typed there, also after the caret has left the line and come back; typed text used to take the previous paragraph's format. No readiness percentage change.
+- **2026-10-15** · Very wide effects stay sharp at high zoom: a wide Basic Feather draws the object itself at full resolution, with only the soft mask at a reduced one, and wide inner shadows, inner glows, satin and bevels are clipped to the shape at full resolution, so they no longer blur the object or bleed past its edge. No readiness percentage change.
+- **2026-10-15** · The Typography panel controls every OpenType feature a character format carries: Other Features lists Proportional Metrics, Horizontal Kana, Localized Forms, Mark Positioning, Justification Alternates and Roman Italics. Lining, Oldstyle, Tabular or Proportional chosen alone also sets the other figure axis, so IDML export keeps the figure style instead of writing Default. Standard Ligatures follows and sets Character › Ligatures. No readiness percentage change.
+- **2026-10-15** · Join Path and Convert Point leave a path on a locked layer or inside a locked group unchanged, as the other path edits do. No readiness percentage change.
+- **2026-10-15** · A kerning value chosen in the Character panel or Properties at a caret kerns the pair at the caret (the character before it takes the value, in one undo step), and the field shows that pair's kerning; at the start of a story or paragraph it is kept for the next typing, and a selection is kerned as before (`type.kernPair`). No readiness percentage change.
+- **2026-10-15** · Japanese, Chinese and Korean input methods type into stories with the Type tool: the marked text shows in place, underlined (the clause being converted twice), with the candidate window at the caret, and the commit is one undo step. Keys, shortcuts, the clipboard and Undo wait while the input method composes; a click, a tool switch or another command keeps the marked text as typed. Not yet checked by hand with a system input method. No readiness percentage change.
+- **2026-10-15** · IDML placed PDFs keep their page and Crop to box (`PDFAttribute` `PageNumber` and `PDFCrop`, written for every placed PDF); two crops of one PDF page stay two assets; a page the PDF lacks is left out of PDF export with a warning instead of failing it; `$ID/` font names resolve; the IDML in a package links the images in its Links folder without embedding them. No readiness percentage change.
+- **2026-10-15** · The CJK leading model and character alignment take effect only in paragraphs set with a Japanese composer (`HL Composer J`, `HL Single J`), which IDML import and export keep: Western and Arabic paragraphs set baseline to baseline on the Roman baseline, a paragraph switched to a Japanese composer gets the file's Aki Below spacing, and under Aki Below a line's leading is the space below it. No readiness percentage change.
+- **2026-10-15** · Document pages follow their parent page's margins and columns unless margins were set on the page itself (`Page::local_margins`): applying a different parent gives a page that parent's margins, a page that changes side after an insert takes the other parent page's, and a page given margins equal to its parent's keeps them when the parent changes. IDML import and older files mark pages whose margins differ from their parent as their own. No readiness percentage change.
+- **2026-10-15** · Start-up picks the GPU that drives the display (or the kind `WGPU_POWER_PREF` or the adapter `WGPU_ADAPTER_NAME` names), and when a start-up fails or hangs it restarts on the next adapter, then the next backend, then a software renderer, keeping recovered documents; start-up errors are logged to standard error and the log file (#273, #334). No readiness percentage change.
+- **2026-10-15** · IDML: liquid guides keep their type on document and parent pages instead of reopening as ordinary ruler guides. Positions, orientation, Fit to Page, locks and layers are preserved; object liquid constraints remain unmapped (#872). No readiness percentage change.
+- **2026-10-15** · Table ▸ Convert Rows ▸ To Header / To Body / To Footer, as in InDesign: the selected rows become header rows when they touch the top of the table or its header rows, footer rows when they touch the bottom or its footer rows, and header or footer rows next to the body go back to body rows. The items are greyed out when the rows can't change (a gap, the last body row, a merged cell across the new boundary); one undo step. No readiness percentage change.
+- **2026-10-15** · Table of Contents: each included style can set a character style for its page number and for the text between entry and number, and Sort Entries in Alphabetical Order lists its entries alphabetically among their siblings, each with the entries under it (#1069). Both survive Update Table of Contents, renaming or deleting the character style, and IDML (`PageNumberStyle`, `SeparatorStyle`, `Sort`). No readiness percentage change.
+- **2026-10-15** · Measures in inches show four decimals, as InDesign's fields do (A4 is 8.2677 × 11.6929 in, a 1p0 gutter 0.1667 in); other units keep three.
+- **2026-10-15** · Ruler menus as InDesign's: right-clicking where the rulers meet sets the units of both; each ruler's menu lists InDesign's units and Hide Rulers, the horizontal one Delete All Guides on Spread.
+- **2026-10-15** · Properties › Edit Page works as InDesign's: the Page tool on the page in view, and Properties shows that page alone (Page Size: page, preset, orientation, W/H; Margins and Columns; Quick Actions) with Back. It opened Document Setup, which changes every page.
+- **2026-10-15** · Deleting pages that contain objects asks first, as InDesign does ("The affected page contains objects. Delete the page anyway?", with Don't show again), from the Pages panel, Layout › Pages › Delete Page and Properties.
+- **2026-10-15** · A page scrolled or jumped to shows its paper while its render is on its way, as in InDesign, instead of the black of its shadow.
+- **2026-10-15** · Tab, Shift+Tab and Presentation hide the icon column's panel flyout and the classic floating panels too, as InDesign hides floating panels.
+- **2026-10-15** · Layers panel: an object's row is renamed with a slow double-click (a second click on the selected row), as in InDesign; a quick double-click only selects it.
+- **2026-10-15** · New Workspace is InDesign's: Name, and Capture › Panel Locations and Menu Customization (the items hidden with Edit › Menus), both on by default; a workspace saved without panel locations leaves the panels where they are. No readiness percentage change.
+- **2026-10-15** · Presentation shows one spread at a time, as large as the screen allows; the arrow keys, Page Up/Down, Home, End, a click and Shift-click go through the spreads.
+- **2026-10-15** · Layout › First Page, Previous Page, Next Page, Last Page, Next Spread and Previous Spread, with InDesign's shortcuts (Shift+Page Up/Down, Shift+Cmd+Page Up/Down, Alt+Page Up/Down).
+- **2026-10-15** · A panel tab's context menu (and the end of its panel menu) has InDesign's Close, Close Tab Group, Minimize and Collapse to Icons, before Float Panel and Group with; `window.panel.closeGroup` and `window.collapseToIcons` are commands. No readiness percentage change.
+- **2026-10-15** · Window › Styles › Paragraph Styles (or Character Styles) opens InDesign's floating Character Styles | Paragraph Styles group, which stays open while other panels open; it was a flyout that the next panel replaced. No readiness percentage change.
+- **2026-10-15** · Double-clicking the status bar's preflight count or its light shows the Preflight panel, as in InDesign.
+- **2026-10-15** · A tool group's flyout closes on Esc and on a click anywhere outside it (a panel, the Fill swatch), as InDesign's; it only closed on a click on the canvas.
++- **2026-10-15** · Pages panel › Panel Options…, as InDesign's: page and parent sizes from Extra Small to Jumbo, Show Thumbnails, parents shown vertically or side by side, Pages or Parents on Top, and how the two parts share a resize; in the panel menu, the page menu and the right-click menu on the panel's empty part.
++- **2026-10-15** · The Pages panel is laid out as InDesign's: parents and pages scroll on their own, a divider between them shows more or fewer parents, and the footer (page count, Edit page size, Create new page, Delete) stays at the bottom. It scrolled away with the pages.
- **2026-10-15** · IDML: ruler guides import and export (they were dropped). Each page's guides come in measured from the document's ruler origin (spread, page or spine), with Fit to Page, Locked and their layer, parent pages' included, and go out again under their pages. No readiness percentage change.
- **2026-10-15** · Find Font no longer reports a style missing when it differs from the installed one only in spacing or case (InDesign files can name `Regular ` with a trailing space); the text was already drawn in the right face. No readiness percentage change.
- **2026-10-15** · A line of text is set when its baseline fits in the frame, as in InDesign: descenders may hang below the frame's bottom. A frame sized to the cap height of a big heading (103 pt in a 2.77 cm frame, as Zero2Graphic's magazine tutorial draws them) no longer oversets. No readiness percentage change.
diff --cc crates/ui-egui/src/dialogs.rs
index 656f95d74,a55847685..8fae26cfc
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -2065,7 -1512,7 +2065,8 @@@ pub fn show(app: &mut DesignApp, ctx: &
"userDictionary" => crate::i18n::tr(&app.ui.language, "User Dictionary"),
"newWorkspace" => crate::i18n::tr(&app.ui.language, "New Workspace"),
"closeDocument" => crate::i18n::tr(&app.ui.language, "Unsaved Changes"),
+ "deletePages" => crate::i18n::tr(&app.ui.language, "Warning"),
+ "pagesPanelOptions" => crate::i18n::tr(&app.ui.language, "Panel Options"),
"updateLink" => crate::i18n::tr(&app.ui.language, "Update Link"),
"menus" => crate::i18n::tr(&app.ui.language, "Menu Customization"),
"importOptions" => crate::i18n::tr(&app.ui.language, "Import Options"),
@@@ -2097,10 -1538,8 +2098,10 @@@
let available = (ctx.content_rect().size() - frame_margin - egui::vec2(16.0, 16.0)).max(egui::Vec2::splat(1.0));
let preferred_width: f32 = match d.id.as_str() {
"alert" => 440.0,
- "closeDocument" | "updateLink" | "deletePages" | "newWorkspace" => 380.0,
- "closeDocument" | "updateLink" | "pagesPanelOptions" => 380.0,
- "newDocument" if crate::i18n::is_rtl(&app.ui.language) => 380.0,
++ "closeDocument" | "updateLink" | "deletePages" | "newWorkspace" | "pagesPanelOptions" => 380.0,
+ "newDocument" => 960.0,
+ "numberingSection" => 560.0,
+ crate::effects_dialog::ID => 720.0,
_ => 640.0,
};
let width = preferred_width.min(available.x);
@@@ -2513,136 -1887,132 +2514,172 @@@
}
}
});
- ui.end_row();
- }
- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Intent:"));
- let cur = d.s("intent");
- egui::ComboBox::from_id_salt("ws_intent")
- .selected_text(crate::rtl::widget(
- ui,
- crate::i18n::tr(&app.ui.language, designcraft_color::cms::Intent::parse(&cur).map_or("", |i| i.label())),
- ))
- .show_ui(ui, |ui| {
- for i in designcraft_color::cms::Intent::ALL {
- if ui
- .selectable_label(i.id() == cur, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, i.label())))
- .clicked()
- {
- d.fields.insert("intent".into(), json!(i.id()));
+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Style Mapping")).font(semibold(12.0)));
+ let names: Vec<String> =
+ app.session.active().map(|s| s.doc.styles.paragraph.iter().map(|p| p.name.clone()).collect()).unwrap_or_default();
+ let imported: Vec<String> = d
+ .fields
+ .get("styles")
+ .and_then(Value::as_array)
+ .map(|a| a.iter().filter_map(|v| v.as_str().map(str::to_string)).collect())
+ .unwrap_or_default();
+ egui::ScrollArea::vertical().max_height(180.0).show(ui, |ui| {
+ egui::Grid::new("imp_map").num_columns(2).spacing([8.0, 4.0]).show(ui, |ui| {
+ for w in &imported {
+ ui.label(w);
+ let mapped = d.fields.get("map").and_then(|m| m.get(w)).and_then(Value::as_str).unwrap_or("").to_string();
+ let shown = if mapped.is_empty() {
+ crate::i18n::tr(&app.ui.language, "(import)").to_string()
+ } else {
+ mapped.clone()
+ };
+ egui::ComboBox::from_id_salt(("imp_map", w))
+ .selected_text(crate::rtl::widget(ui, &shown))
+ .width(170.0)
+ .show_ui(ui, |ui| {
+ if ui
+ .selectable_label(
+ mapped.is_empty(),
+ crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "(import)")),
+ )
+ .clicked()
+ && let Some(m) = d.fields.get_mut("map").and_then(Value::as_object_mut)
+ {
+ m.remove(w);
+ }
+ for n in &names {
+ if ui.selectable_label(*n == mapped, n).clicked()
+ && let Some(m) = d.fields.get_mut("map").and_then(Value::as_object_mut)
+ {
+ m.insert(w.clone(), json!(n));
+ }
+ }
+ });
+ ui.end_row();
}
- }
+ });
});
- ui.end_row();
- });
- check(ui, &mut d, "bpc", crate::i18n::tr(&app.ui.language, "Use Black Point Compensation"));
- if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Load Profile…"))).clicked()
- && let Some(path) = app.services.pick_open.as_mut().and_then(|f| f("icc"))
- {
- match app.session.execute("color.loadProfile", &json!({"path": path})) {
- Ok(_) => {
- let f = app.session.execute("color.settings", &json!({})).unwrap_or_default();
- d.fields.insert("profiles".into(), f["profiles"].clone());
- }
- Err(e) => app.status(format!("Color Settings: {e}")),
}
}
- }
- "keyboardShortcuts" => keyboard_shortcuts(app, ui, &mut d),
- "userDictionary" => user_dictionary(app, ui, &mut d),
- "menus" => {
- text_field(ui, &mut d, "query", 260.0);
- let q = d.s("query").to_lowercase();
- egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {
- for (menu, label) in crate::menus::all_menu_items()
- .into_iter()
- .filter(|(m, l)| q.is_empty() || m.to_lowercase().contains(&q) || l.to_lowercase().contains(&q))
- {
- let key = crate::menus::menu_key(&menu, &label);
- let mut visible = !app.ui.hidden_menu_items.contains(&key);
- if ui
- .checkbox(
- &mut visible,
- crate::rtl::widget(
- ui,
- format!("{} › {}", crate::i18n::tr(&app.ui.language, &menu), crate::i18n::tr(&app.ui.language, &label)),
- ),
- )
- .changed()
- {
- let _ = app.run("window.hideMenuItem", json!({"item": key, "hidden": !visible}));
+ "loadStyles" => load_styles(app, ui, &mut d),
+ "closeDocument" => {
+ let text = crate::i18n::tr(&app.ui.language, "“{}” has changes that are not saved. Save them before closing?")
+ .replace("{}", &d.s("title"));
+ crate::rtl::label(ui, text);
+ }
+ "deletePages" => {
+ let several = d.fields.get("pages").and_then(Value::as_array).is_some_and(|p| p.len() > 1);
+ crate::rtl::label(
+ ui,
+ crate::i18n::tr(
+ &app.ui.language,
+ if several {
+ "The affected pages contain objects. Delete the pages anyway?"
+ } else {
+ "The affected page contains objects. Delete the page anyway?"
+ },
+ ),
+ );
+ ui.add_space(8.0);
+ check(ui, &mut d, "dontShowAgain", crate::i18n::tr(&app.ui.language, "Don't show again"));
+ }
++ "pagesPanelOptions" => {
++ // As InDesign's: Pages, Parents, Panel Layout.
++ use crate::panels::pages::{IconSize, PanelResize};
++ let lang = app.ui.language.clone();
++ let sizes: Vec<(&str, &str)> = IconSize::ALL.iter().map(|s| (s.key(), crate::i18n::tr(&lang, s.label()))).collect();
++ let group = |ui: &mut egui::Ui, title: &str| {
++ ui.add_space(4.0);
++ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&lang, title)).strong());
++ };
++ group(ui, "Pages");
++ ui.horizontal(|ui| {
++ crate::rtl::label(ui, crate::i18n::tr(&lang, "Size:"));
++ combo(ui, &mut d, "pageSize", &sizes);
++ });
++ // Extra Small pages have no room for a thumbnail.
++ ui.add_enabled_ui(d.s("pageSize") != "extraSmall", |ui| {
++ check(ui, &mut d, "pageThumbnails", crate::i18n::tr(&lang, "Show Thumbnails"))
++ });
++ group(ui, "Parents");
++ ui.horizontal(|ui| {
++ crate::rtl::label(ui, crate::i18n::tr(&lang, "Size:"));
++ combo(ui, &mut d, "parentSize", &sizes);
++ });
++ check(ui, &mut d, "parentsVertical", crate::i18n::tr(&lang, "Show Vertically"));
++ group(ui, "Panel Layout");
++ for (v, label) in [("pagesOnTop", "Pages on Top"), ("parentsOnTop", "Parents on Top")] {
++ if ui.radio(d.s("layout") == v, crate::rtl::widget(ui, crate::i18n::tr(&lang, label))).clicked() {
++ d.fields.insert("layout".into(), json!(v));
+ }
+ }
- });
- }
- "importOptions" => {
- ui.label(egui::RichText::new(d.s("path")).size(10.5));
- check(ui, &mut d, "removeStyles", crate::i18n::tr(&app.ui.language, "Remove Styles and Formatting from Text and Tables"));
- if !d.b("removeStyles") {
- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Style Name Conflicts")).font(semibold(12.0)));
- let conflicts: Vec<String> = d
- .fields
- .get("conflicts")
- .and_then(Value::as_array)
- .map(|a| a.iter().filter_map(|v| v.as_str().map(str::to_string)).collect())
- .unwrap_or_default();
- ui.label(if conflicts.is_empty() {
- crate::i18n::tr(&app.ui.language, "No conflicts").to_string()
- } else {
- format!("{} conflict(s): {}", conflicts.len(), conflicts.join(", "))
++ let resizes: Vec<(&str, &str)> = PanelResize::ALL.iter().map(|r| (r.key(), crate::i18n::tr(&lang, r.label()))).collect();
++ ui.horizontal(|ui| {
++ crate::rtl::label(ui, crate::i18n::tr(&lang, "Resize:"));
++ combo(ui, &mut d, "resize", &resizes);
+ });
- let cur = d.s("styleConflicts");
++ }
+ "updateLink" => {
+ let text = crate::i18n::tr(
+ &app.ui.language,
+ "“{}” has been edited in this layout. Updating replaces those edits with the text from the file.",
+ )
+ .replace("{}", &d.s("files"));
+ crate::rtl::label(ui, text);
+ }
+ "newWorkspace" => {
ui.horizontal(|ui| {
- for (v, l) in [
- ("useExisting", "Use Document Style Definition"),
- ("redefine", "Redefine Document Style"),
- ("autoRename", "Auto Rename"),
- ] {
- if ui.radio(cur == v, l).clicked() {
- d.fields.insert("styleConflicts".into(), json!(v));
- }
- }
+ crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Name:"));
+ text_field(ui, &mut d, "name", 220.0);
});
- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Style Mapping")).font(semibold(12.0)));
- let names: Vec<String> =
- app.session.active().map(|s| s.doc.styles.paragraph.iter().map(|p| p.name.clone()).collect()).unwrap_or_default();
- let imported: Vec<String> = d
- .fields
- .get("styles")
- .and_then(Value::as_array)
- .map(|a| a.iter().filter_map(|v| v.as_str().map(str::to_string)).collect())
- .unwrap_or_default();
- egui::ScrollArea::vertical().max_height(180.0).show(ui, |ui| {
- egui::Grid::new("imp_map").num_columns(2).spacing([8.0, 4.0]).show(ui, |ui| {
- for w in &imported {
- ui.label(w);
- let mapped = d.fields.get("map").and_then(|m| m.get(w)).and_then(Value::as_str).unwrap_or("").to_string();
- let shown = if mapped.is_empty() { "(import)".to_string() } else { mapped.clone() };
- egui::ComboBox::from_id_salt(("imp_map", w)).selected_text(crate::rtl::widget(ui, &shown)).width(170.0).show_ui(
- ui,
- |ui| {
- if ui
- .selectable_label(
- mapped.is_empty(),
- crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "(import)")),
- )
- .clicked()
- && let Some(m) = d.fields.get_mut("map").and_then(Value::as_object_mut)
- {
- m.remove(w);
- }
- for n in &names {
- if ui.selectable_label(*n == mapped, n).clicked()
- && let Some(m) = d.fields.get_mut("map").and_then(Value::as_object_mut)
- {
- m.insert(w.clone(), json!(n));
- }
- }
- },
- );
+ ui.add_space(6.0);
+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Capture")).font(semibold(12.0)));
+ check(ui, &mut d, "panelLocations", crate::i18n::tr(&app.ui.language, "Panel Locations"));
+ check(ui, &mut d, "menuCustomization", crate::i18n::tr(&app.ui.language, "Menu Customization"));
+ }
+ "fittingOptions" => {
+ check(ui, &mut d, "autoFit", crate::i18n::tr(&app.ui.language, "Auto-Fit"));
+ ui.add_space(4.0);
+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Content Fitting")).font(semibold(12.0)));
+ let cur = d.s("fitting");
+ let label = |v: &str| match v {
+ "fillProportionally" => crate::i18n::tr(&app.ui.language, "Fill Frame Proportionally"),
+ "fitProportionally" => crate::i18n::tr(&app.ui.language, "Fit Content Proportionally"),
+ "fitContentToFrame" => crate::i18n::tr(&app.ui.language, "Fit Content to Frame"),
+ "centerContent" => crate::i18n::tr(&app.ui.language, "Center Content"),
+ _ => crate::i18n::tr(&app.ui.language, "None"),
+ };
+ ui.horizontal(|ui| {
+ crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Fitting:"));
+ egui::ComboBox::from_id_salt("ff_fit").selected_text(crate::rtl::widget(ui, label(&cur))).width(200.0).show_ui(
+ ui,
+ |ui| {
+ for v in ["none", "fillProportionally", "fitProportionally", "fitContentToFrame", "centerContent"] {
+ if ui.selectable_label(cur == v, crate::rtl::widget(ui, label(v))).clicked() {
+ d.fields.insert("fitting".into(), json!(v));
+ }
+ }
+ },
+ );
+ });
+ ui.horizontal(|ui| {
+ crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Align From:"));
+ let a = d.n("align").unwrap_or(4.0) as u8;
+ egui::Grid::new("ff_align").spacing([2.0, 2.0]).show(ui, |ui| {
+ for row in 0..3u8 {
+ for col in 0..3u8 {
+ let i = row * 3 + col;
+ let (r, resp) = ui.allocate_exact_size(egui::vec2(14.0, 14.0), egui::Sense::click());
+ let c = ui.visuals().text_color();
+ if a == i {
+ ui.painter().rect_filled(r.shrink(2.0), 1.0, c);
+ } else {
+ ui.painter().rect_stroke(r.shrink(3.0), 1.0, egui::Stroke::new(1.0, c), egui::StrokeKind::Inside);
+ }
+ if resp.clicked() {
+ d.fields.insert("align".into(), json!(i));
+ }
+ }
ui.end_row();
}
});
@@@ -3399,16 -2672,18 +3436,27 @@@ pub fn confirm(app: &mut DesignApp) ->
doc["glyphFallback"] = json!(d.b("glyphFallback"));
app.run("document.preferences", doc)
}
- "newWorkspace" => app.run("window.newWorkspace", json!({"name": d.s("name")})),
+ "newWorkspace" => app.run(
+ "window.newWorkspace",
+ json!({"name": d.s("name"), "panelLocations": d.b("panelLocations"), "menuCustomization": d.b("menuCustomization")}),
+ ),
+ "deletePages" => {
+ if d.b("dontShowAgain") {
+ app.ui.skip_delete_pages_warning = true;
+ }
+ app.run("layout.pages.delete", json!({"pages": d.fields.get("pages").cloned().unwrap_or_else(|| json!([]))}))
+ }
+ "pagesPanelOptions" => {
+ use crate::panels::pages::{IconSize, PanelResize};
+ let o = &mut app.ui.pages_panel;
+ o.page_size = IconSize::from_key(&d.s("pageSize")).unwrap_or(o.page_size);
+ o.page_thumbnails = d.b("pageThumbnails");
+ o.parent_size = IconSize::from_key(&d.s("parentSize")).unwrap_or(o.parent_size);
+ o.parents_vertical = d.b("parentsVertical");
+ o.pages_on_top = d.s("layout") == "pagesOnTop";
+ o.resize = PanelResize::from_key(&d.s("resize")).unwrap_or(o.resize);
+ Ok(Value::Null)
+ }
"updateLink" => crate::panels::properties::run_update_links(app, d.fields.get("target").cloned().unwrap_or_else(|| json!({}))),
"closeDocument" => {
// The document may have moved in the tab row (or gone) while the dialog was open.
diff --cc crates/ui-egui/src/dock.rs
index 3369ed985,3ab13bf4f..7e7ce2a64
--- a/crates/ui-egui/src/dock.rs
+++ b/crates/ui-egui/src/dock.rs
@@@ -375,16 -365,14 +394,16 @@@ pub fn floating(app: &mut DesignApp, ct
crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Dock panel"));
})
.clicked()
- {
- dock = true;
- }
+ {
+ dock = true;
+ }
+ if docks {
dock_glyph(ui.painter(), dock_r, t.text_dim);
- egui::Frame::NONE.inner_margin(egui::Margin::same(10)).show(ui, |ui| {
- scrolled_body(app, ui, &id, ctx.content_rect().height() - 160.0);
- });
+ }
+ egui::Frame::NONE.inner_margin(egui::Margin::same(10)).show(ui, |ui| {
- egui::ScrollArea::vertical().max_height(ctx.content_rect().height() - 160.0).show(ui, |ui| panel_body(app, ui, &id));
++ scrolled_body(app, ui, &id, ctx.content_rect().height() - 160.0);
});
+ });
// Remember where it was left.
if let Some(r) = r
&& let Some(f) = app.ui.floating.iter_mut().find(|(p, _)| *p == id)
diff --cc crates/ui-egui/src/i18n.rs
index ced4d4738,9577f4977..efe089ef9
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@@ -89,48 -58,27 +89,69 @@@ const TABLE: &[(&str, [&str; 5])] = &
("Cut", ["Ausschneiden", "Couper", "Cortar", "カット", "剪切"]),
("Copy", ["Kopieren", "Copier", "Copiar", "コピー", "复制"]),
("Paste", ["Einfügen", "Coller", "Pegar", "ペースト", "粘贴"]),
+ ("Hide Rulers", ["Lineale ausblenden", "Masquer les règles", "Ocultar reglas", "定規を隠す", "隐藏标尺"]),
+ ("Inches Decimal", ["Zoll dezimal", "Pouces décimaux", "Pulgadas decimales", "インチ(10 進)", "十进制英寸"]),
+ (
+ "Paste Vector Art",
+ ["Vektorgrafik einfügen", "Coller l’illustration vectorielle", "Pegar ilustración vectorial", "ベクトルアートをペースト", "粘贴矢量图稿"],
+ ),
+ ("Back", ["Zurück", "Retour", "Atrás", "戻る", "返回"]),
+ ("Margins and Columns", ["Ränder und Spalten", "Marges et colonnes", "Márgenes y columnas", "マージン・段組", "边距和分栏"]),
+ ("Warning", ["Warnung", "Avertissement", "Advertencia", "警告", "警告"]),
+ ("Don't show again", ["Nicht mehr anzeigen", "Ne plus afficher", "No volver a mostrar", "今後表示しない", "不再显示"]),
+ (
+ "The affected page contains objects. Delete the page anyway?",
+ [
+ "Die betroffene Seite enthält Objekte. Seite trotzdem löschen?",
+ "La page concernée contient des objets. Supprimer quand même la page ?",
+ "La página afectada contiene objetos. ¿Desea eliminarla de todos modos?",
+ "対象のページにはオブジェクトが含まれています。ページを削除しますか?",
+ "受影响的页面包含对象。仍要删除该页面吗?",
+ ],
+ ),
+ (
+ "The affected pages contain objects. Delete the pages anyway?",
+ [
+ "Die betroffenen Seiten enthalten Objekte. Seiten trotzdem löschen?",
+ "Les pages concernées contiennent des objets. Supprimer quand même les pages ?",
+ "Las páginas afectadas contienen objetos. ¿Desea eliminarlas de todos modos?",
+ "対象のページにはオブジェクトが含まれています。ページを削除しますか?",
+ "受影响的页面包含对象。仍要删除这些页面吗?",
+ ],
+ ),
+ ("Capture", ["Erfassen", "Capturer", "Capturar", "取り込み", "捕捉"]),
+ ("Panel Locations", ["Bedienfeldpositionen", "Emplacements des panneaux", "Ubicaciones de paneles", "パネルの位置", "面板位置"]),
+ ("First Page", ["Erste Seite", "Première page", "Primera página", "最初のページ", "第一页"]),
+ ("Previous Page", ["Vorherige Seite", "Page précédente", "Página anterior", "前のページ", "上一页"]),
+ ("Next Page", ["Nächste Seite", "Page suivante", "Página siguiente", "次のページ", "下一页"]),
+ ("Last Page", ["Letzte Seite", "Dernière page", "Última página", "最後のページ", "最后一页"]),
+ (
+ "Close Tab Group",
+ ["Registerkartengruppe schließen", "Fermer le groupe d'onglets", "Cerrar grupo de fichas", "タブグループを閉じる", "关闭选项卡组"],
+ ),
+ ("Minimize", ["Minimieren", "Réduire", "Minimizar", "最小化", "最小化"]),
+ ("Collapse to Icons", ["Auf Symbole minimieren", "Réduire en icônes", "Contraer a iconos", "アイコンパネルに折りたたむ", "折叠为图标"]),
+ ("Panel Options", ["Bedienfeldoptionen", "Options du panneau", "Opciones de panel", "パネルオプション", "面板选项"]),
+ ("Panel Options…", ["Bedienfeldoptionen…", "Options du panneau…", "Opciones de panel…", "パネルオプション…", "面板选项…"]),
+ ("Show Thumbnails", ["Miniaturen anzeigen", "Afficher les vignettes", "Mostrar miniaturas", "サムネールを表示", "显示缩览图"]),
+ ("Show Vertically", ["Vertikal anzeigen", "Afficher verticalement", "Mostrar verticalmente", "縦に表示", "垂直显示"]),
+ ("Panel Layout", ["Bedienfeldlayout", "Disposition du panneau", "Diseño del panel", "パネルレイアウト", "面板版面"]),
+ ("Pages on Top", ["Seiten oben", "Pages en haut", "Páginas en la parte superior", "ページを上に表示", "页面在上"]),
+ (
+ "Parents on Top",
+ ["Übergeordnete Seiten oben", "Parents en haut", "Páginas principales en la parte superior", "親ページを上に表示", "父页面在上"],
+ ),
+ ("Resize:", ["Größe ändern:", "Redimensionner :", "Cambiar tamaño:", "サイズ変更:", "调整大小:"]),
+ ("Extra Small", ["Sehr klein", "Très petite", "Extra pequeño", "極小", "特小"]),
+ ("Small", ["Klein", "Petite", "Pequeño", "小", "小"]),
+ ("Medium", ["Mittel", "Moyenne", "Mediano", "中", "中"]),
+ ("Large", ["Groß", "Grande", "Grande", "大", "大"]),
+ ("Extra Large", ["Sehr groß", "Très grande", "Extra grande", "特大", "特大"]),
+ ("Jumbo", ["Riesig", "Géante", "Gigante", "最大", "巨大"]),
+ ("Proportional", ["Proportional", "Proportionnel", "Proporcional", "比例", "按比例"]),
+ ("Pages Fixed", ["Seiten fixiert", "Pages fixes", "Páginas fijas", "ページを固定", "页面固定"]),
+ ("Parents Fixed", ["Übergeordnete fixiert", "Parents fixes", "Páginas principales fijas", "親ページを固定", "父页面固定"]),
+ ("Parents", ["Übergeordnete Seiten", "Parents", "Páginas principales", "親ページ", "父页面"]),
(
"Bulleted & Numbered Lists",
[
diff --cc crates/ui-egui/src/i18n/ar.rs
index 802e99232,afd80dd21..b050de38b
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@@ -30,33 -30,24 +30,51 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "قص"),
("Copy", "نسخ"),
("Paste", "لصق"),
+ ("Paste Vector Art", "لصق رسم متجه"),
+ ("Baseline Options", "خيارات خط الأساس"),
+ ("Fixed Number", "عدد ثابت"),
+ ("Fixed Width", "عرض ثابت"),
+ ("Gutter:", "الفاصل:"),
+ ("Balance Columns", "موازنة الأعمدة"),
+ ("Inset Spacing", "تباعد الإزاحة الداخلية"),
+ ("Vertical Justification", "الضبط العمودي"),
+ ("Align:", "المحاذاة:"),
+ ("Ignore Text Wrap", "تجاهل التفاف النص"),
+ ("Technique:", "التقنية:"),
+ ("Softer", "أنعم"),
+ ("Precise", "دقيق"),
+ ("Corners:", "الزوايا:"),
+ ("Sharp", "حادة"),
+ ("Diffused", "منتشرة"),
+ ("Inches Decimal", "بوصات عشرية"),
+ ("Back", "رجوع"),
+ ("Warning", "تحذير"),
+ ("Don't show again", "عدم الإظهار مرة أخرى"),
+ ("The affected page contains objects. Delete the page anyway?", "تحتوي الصفحة المعنية على كائنات. هل تريد حذف الصفحة على أي حال؟"),
+ ("The affected pages contain objects. Delete the pages anyway?", "تحتوي الصفحات المعنية على كائنات. هل تريد حذف الصفحات على أي حال؟"),
+ ("Capture", "التقاط"),
+ ("Panel Locations", "مواضع اللوحات"),
+ ("Close Tab Group", "إغلاق مجموعة علامات التبويب"),
+ ("Minimize", "تصغير"),
+ ("Collapse to Icons", "طي إلى أيقونات"),
+ ("Panel Options", "خيارات اللوحة"),
+ ("Panel Options…", "خيارات اللوحة…"),
+ ("Show Thumbnails", "إظهار الصور المصغرة"),
+ ("Show Vertically", "إظهار عموديًا"),
+ ("Panel Layout", "تخطيط اللوحة"),
+ ("Pages on Top", "الصفحات في الأعلى"),
+ ("Parents on Top", "الصفحات الرئيسية في الأعلى"),
+ ("Resize:", "تغيير الحجم:"),
+ ("Extra Small", "صغير جدًا"),
+ ("Small", "صغير"),
+ ("Medium", "متوسط"),
+ ("Large", "كبير"),
+ ("Extra Large", "كبير جدًا"),
+ ("Jumbo", "ضخم"),
+ ("Proportional", "تناسبي"),
+ ("Pages Fixed", "الصفحات ثابتة"),
+ ("Parents Fixed", "الصفحات الرئيسية ثابتة"),
+ ("Parents", "الصفحات الرئيسية"),
("Bulleted & Numbered Lists", "القوائم ذات التعداد النقطي والرقمي"),
("Current Page Number", "رقم الصفحة الحالية"),
("Apply Color (,)", "تطبيق اللون (,)"),
diff --cc crates/ui-egui/src/i18n/de.rs
index b96280e07,87910e7c8..efc128858
--- a/crates/ui-egui/src/i18n/de.rs
+++ b/crates/ui-egui/src/i18n/de.rs
@@@ -31,17 -30,24 +31,35 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Ausschneiden"),
("Copy", "Kopieren"),
("Paste", "Einfügen"),
+ ("Inches Decimal", "Zoll dezimal"),
+ ("Back", "Zurück"),
+ ("Warning", "Warnung"),
+ ("Don't show again", "Nicht mehr anzeigen"),
+ ("The affected page contains objects. Delete the page anyway?", "Die betroffene Seite enthält Objekte. Seite trotzdem löschen?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "Die betroffenen Seiten enthalten Objekte. Seiten trotzdem löschen?"),
+ ("Capture", "Erfassen"),
+ ("Panel Locations", "Bedienfeldpositionen"),
+ ("Close Tab Group", "Registerkartengruppe schließen"),
+ ("Minimize", "Minimieren"),
+ ("Collapse to Icons", "Auf Symbole minimieren"),
+ ("Panel Options", "Bedienfeldoptionen"),
+ ("Panel Options…", "Bedienfeldoptionen…"),
+ ("Show Thumbnails", "Miniaturen anzeigen"),
+ ("Show Vertically", "Vertikal anzeigen"),
+ ("Panel Layout", "Bedienfeldlayout"),
+ ("Pages on Top", "Seiten oben"),
+ ("Parents on Top", "Übergeordnete Seiten oben"),
+ ("Resize:", "Größe ändern:"),
+ ("Extra Small", "Sehr klein"),
+ ("Small", "Klein"),
+ ("Medium", "Mittel"),
+ ("Large", "Groß"),
+ ("Extra Large", "Sehr groß"),
+ ("Jumbo", "Riesig"),
+ ("Proportional", "Proportional"),
+ ("Pages Fixed", "Seiten fixiert"),
+ ("Parents Fixed", "Übergeordnete fixiert"),
+ ("Parents", "Übergeordnete Seiten"),
("Clear", "Löschen"),
("Duplicate", "Duplizieren"),
("Select All", "Alles auswählen"),
diff --cc crates/ui-egui/src/i18n/it.rs
index 6201003dc,6845e97ae..a918a9829
--- a/crates/ui-egui/src/i18n/it.rs
+++ b/crates/ui-egui/src/i18n/it.rs
@@@ -28,34 -28,24 +28,52 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Taglia"),
("Copy", "Copia"),
("Paste", "Incolla"),
+ ("Paste Vector Art", "Incolla grafica vettoriale"),
+ ("Baseline Options", "Opzioni linea di base"),
+ ("Fixed Number", "Numero fisso"),
+ ("Fixed Width", "Larghezza fissa"),
+ ("Gutter:", "Spaziatura:"),
+ ("Balance Columns", "Bilancia colonne"),
+ ("Inset Spacing", "Spaziatura interna"),
+ ("Vertical Justification", "Giustificazione verticale"),
+ ("Align:", "Allinea:"),
+ ("Ignore Text Wrap", "Ignora contorna con testo"),
+ ("Technique:", "Tecnica:"),
+ ("Softer", "Più morbido"),
+ ("Precise", "Preciso"),
+ ("Corners:", "Angoli:"),
+ ("Sharp", "Netti"),
+ ("Diffused", "Diffusi"),
+ ("Inches Decimal", "Pollici decimali"),
+ ("Back", "Indietro"),
+ ("Margins and Columns", "Margini e colonne"),
+ ("Warning", "Avviso"),
+ ("Don't show again", "Non mostrare più"),
+ ("The affected page contains objects. Delete the page anyway?", "La pagina interessata contiene oggetti. Eliminarla comunque?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "Le pagine interessate contengono oggetti. Eliminarle comunque?"),
+ ("Capture", "Acquisisci"),
+ ("Panel Locations", "Posizioni pannelli"),
+ ("Close Tab Group", "Chiudi gruppo schede"),
+ ("Minimize", "Minimizza"),
+ ("Collapse to Icons", "Riduci a icone"),
+ ("Panel Options", "Opzioni pannello"),
+ ("Panel Options…", "Opzioni pannello…"),
+ ("Show Thumbnails", "Mostra miniature"),
+ ("Show Vertically", "Mostra in verticale"),
+ ("Panel Layout", "Layout pannello"),
+ ("Pages on Top", "Pagine in alto"),
+ ("Parents on Top", "Pagine mastro in alto"),
+ ("Resize:", "Ridimensiona:"),
+ ("Extra Small", "Molto piccola"),
+ ("Small", "Piccola"),
+ ("Medium", "Media"),
+ ("Large", "Grande"),
+ ("Extra Large", "Molto grande"),
+ ("Jumbo", "Gigante"),
+ ("Proportional", "Proporzionale"),
+ ("Pages Fixed", "Pagine fisse"),
+ ("Parents Fixed", "Pagine mastro fisse"),
+ ("Parents", "Pagine mastro"),
("Bulleted & Numbered Lists", "Elenchi puntati e numerati"),
("Current Page Number", "Numero di pagina corrente"),
("Apply Color (,)", "Applica colore (,)"),
diff --cc crates/ui-egui/src/i18n/ja.rs
index 5acaa5e34,ac5cc4ab0..5647ca940
--- a/crates/ui-egui/src/i18n/ja.rs
+++ b/crates/ui-egui/src/i18n/ja.rs
@@@ -30,35 -30,24 +30,53 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "カット"),
("Copy", "コピー"),
("Paste", "ペースト"),
+ ("Paste Vector Art", "ベクトルアートをペースト"),
+ ("Baseline Options", "ベースラインオプション"),
+ ("Column Rules", "段落境界線"),
+ ("Insert Column Rule", "段落境界線を挿入"),
+ ("Fixed Number", "固定数"),
+ ("Fixed Width", "固定幅"),
+ ("Gutter:", "間隔:"),
+ ("Balance Columns", "段を均等化"),
+ ("Inset Spacing", "フレーム内マージン"),
+ ("Vertical Justification", "垂直比率"),
+ ("Align:", "整列:"),
+ ("Ignore Text Wrap", "テキストの回り込みを無視"),
+ ("Technique:", "テクニック:"),
+ ("Softer", "さらにソフトに"),
+ ("Precise", "精細"),
+ ("Corners:", "角:"),
+ ("Sharp", "シャープ"),
+ ("Diffused", "拡散"),
+ ("Inches Decimal", "インチ(10 進)"),
+ ("Back", "戻る"),
+ ("Warning", "警告"),
+ ("Don't show again", "今後表示しない"),
+ ("The affected page contains objects. Delete the page anyway?", "対象のページにはオブジェクトが含まれています。ページを削除しますか?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "対象のページにはオブジェクトが含まれています。ページを削除しますか?"),
+ ("Capture", "取り込み"),
+ ("Panel Locations", "パネルの位置"),
+ ("Close Tab Group", "タブグループを閉じる"),
+ ("Minimize", "最小化"),
+ ("Collapse to Icons", "アイコンパネルに折りたたむ"),
+ ("Panel Options", "パネルオプション"),
+ ("Panel Options…", "パネルオプション…"),
+ ("Show Thumbnails", "サムネールを表示"),
+ ("Show Vertically", "縦に表示"),
+ ("Panel Layout", "パネルレイアウト"),
+ ("Pages on Top", "ページを上に表示"),
+ ("Parents on Top", "親ページを上に表示"),
+ ("Resize:", "サイズ変更:"),
+ ("Extra Small", "極小"),
+ ("Small", "小"),
+ ("Medium", "中"),
+ ("Large", "大"),
+ ("Extra Large", "特大"),
+ ("Jumbo", "最大"),
+ ("Proportional", "比例"),
+ ("Pages Fixed", "ページを固定"),
+ ("Parents Fixed", "親ページを固定"),
+ ("Parents", "親ページ"),
("Bulleted & Numbered Lists", "箇条書き"),
("Apply Color (,)", "カラーを適用 (,)"),
("Apply Gradient (.)", "グラデーションを適用 (.)"),
diff --cc crates/ui-egui/src/i18n/ka.rs
index f63f561db,1926691b0..975da9ca1
--- a/crates/ui-egui/src/i18n/ka.rs
+++ b/crates/ui-egui/src/i18n/ka.rs
@@@ -31,17 -31,24 +31,35 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "ამოჭრა"),
("Copy", "კოპირება"),
("Paste", "ჩასმა"),
+ ("Inches Decimal", "ინჩები (ათობითი)"),
+ ("Back", "უკან"),
+ ("Warning", "გაფრთხილება"),
+ ("Don't show again", "აღარ აჩვენო"),
+ ("The affected page contains objects. Delete the page anyway?", "გვერდი შეიცავს ობიექტებს. მაინც წავშალო გვერდი?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "გვერდები შეიცავს ობიექტებს. მაინც წავშალო გვერდები?"),
+ ("Capture", "შენახვა"),
+ ("Panel Locations", "პანელების მდებარეობა"),
+ ("Close Tab Group", "ჩანართების ჯგუფის დახურვა"),
+ ("Minimize", "ჩაკეცვა"),
+ ("Collapse to Icons", "ხატულებად ჩაკეცვა"),
+ ("Panel Options", "პანელის პარამეტრები"),
+ ("Panel Options…", "პანელის პარამეტრები…"),
+ ("Show Thumbnails", "მინიატურების ჩვენება"),
+ ("Show Vertically", "ვერტიკალურად ჩვენება"),
+ ("Panel Layout", "პანელის განლაგება"),
+ ("Pages on Top", "გვერდები ზემოთ"),
+ ("Parents on Top", "მშობლები ზემოთ"),
+ ("Resize:", "ზომის შეცვლა:"),
+ ("Extra Small", "ძალიან პატარა"),
+ ("Small", "პატარა"),
+ ("Medium", "საშუალო"),
+ ("Large", "დიდი"),
+ ("Extra Large", "ძალიან დიდი"),
+ ("Jumbo", "უზარმაზარი"),
+ ("Proportional", "პროპორციული"),
+ ("Pages Fixed", "გვერდები ფიქსირებული"),
+ ("Parents Fixed", "მშობლები ფიქსირებული"),
+ ("Parents", "მშობელი გვერდები"),
("Reverse Path", "ტრაექტორიის შებრუნება"),
("Set Anchor", "საყრდენი წერტილის დაყენება"),
("Clear", "გასუფთავება"),
diff --cc crates/ui-egui/src/i18n/pt_br.rs
index 75e0af3c5,483115fa7..8521de594
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@@ -31,34 -31,24 +31,52 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Recortar"),
("Copy", "Copiar"),
("Paste", "Colar"),
+ ("Paste Vector Art", "Colar arte vetorial"),
+ ("Baseline Options", "Opções de linha de base"),
+ ("Fixed Number", "Número fixo"),
+ ("Fixed Width", "Largura fixa"),
+ ("Gutter:", "Medianiz:"),
+ ("Balance Columns", "Equilibrar colunas"),
+ ("Inset Spacing", "Espaçamento interno"),
+ ("Vertical Justification", "Justificação vertical"),
+ ("Align:", "Alinhar:"),
+ ("Ignore Text Wrap", "Ignorar disposição do texto"),
+ ("Technique:", "Técnica:"),
+ ("Softer", "Mais suave"),
+ ("Precise", "Preciso"),
+ ("Corners:", "Cantos:"),
+ ("Sharp", "Nítidos"),
+ ("Diffused", "Difusos"),
+ ("Inches Decimal", "Polegadas decimais"),
+ ("Back", "Voltar"),
+ ("Margins and Columns", "Margens e colunas"),
+ ("Warning", "Aviso"),
+ ("Don't show again", "Não mostrar novamente"),
+ ("The affected page contains objects. Delete the page anyway?", "A página afetada contém objetos. Excluir a página mesmo assim?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "As páginas afetadas contêm objetos. Excluir as páginas mesmo assim?"),
+ ("Capture", "Capturar"),
+ ("Panel Locations", "Locais dos painéis"),
+ ("Close Tab Group", "Fechar grupo de guias"),
+ ("Minimize", "Minimizar"),
+ ("Collapse to Icons", "Recolher para ícones"),
+ ("Panel Options", "Opções do painel"),
+ ("Panel Options…", "Opções do painel…"),
+ ("Show Thumbnails", "Mostrar miniaturas"),
+ ("Show Vertically", "Mostrar verticalmente"),
+ ("Panel Layout", "Layout do painel"),
+ ("Pages on Top", "Páginas na parte superior"),
+ ("Parents on Top", "Páginas-pai na parte superior"),
+ ("Resize:", "Redimensionar:"),
+ ("Extra Small", "Extra pequeno"),
+ ("Small", "Pequeno"),
+ ("Medium", "Médio"),
+ ("Large", "Grande"),
+ ("Extra Large", "Extra grande"),
+ ("Jumbo", "Gigante"),
+ ("Proportional", "Proporcional"),
+ ("Pages Fixed", "Páginas fixas"),
+ ("Parents Fixed", "Páginas-pai fixas"),
+ ("Parents", "Páginas-pai"),
("Bulleted & Numbered Lists", "Listas com marcadores e numeradas"),
("Show Hidden Characters", "Mostrar caracteres ocultos"),
("Current Page Number", "Número da página atual"),
diff --cc crates/ui-egui/src/i18n/uk.rs
index 6c4cd1ce7,3f2a21cd7..dd4a1434d
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@@ -29,34 -31,24 +29,52 @@@ pub(super) const TABLE: &[(&str, &str)
("Cut", "Вирізати"),
("Copy", "Копіювати"),
("Paste", "Вставити"),
+ ("Paste Vector Art", "Вставити векторну графіку"),
+ ("Baseline Options", "Параметри базової лінії"),
+ ("Fixed Number", "Фіксована кількість"),
+ ("Fixed Width", "Фіксована ширина"),
+ ("Gutter:", "Проміжок:"),
+ ("Balance Columns", "Вирівняти колонки"),
+ ("Inset Spacing", "Внутрішні відступи"),
+ ("Vertical Justification", "Вертикальне вирівнювання"),
+ ("Align:", "Вирівняти:"),
+ ("Ignore Text Wrap", "Ігнорувати обтікання текстом"),
+ ("Technique:", "Техніка:"),
+ ("Softer", "М'якше"),
+ ("Precise", "Точно"),
+ ("Corners:", "Кути:"),
+ ("Sharp", "Гострі"),
+ ("Diffused", "Розсіяні"),
+ ("Inches Decimal", "Дюйми (десяткові)"),
+ ("Back", "Назад"),
+ ("Margins and Columns", "Поля та колонки"),
+ ("Warning", "Попередження"),
+ ("Don't show again", "Більше не показувати"),
+ ("The affected page contains objects. Delete the page anyway?", "Сторінка містить об’єкти. Усе одно видалити сторінку?"),
+ ("The affected pages contain objects. Delete the pages anyway?", "Сторінки містять об’єкти. Усе одно видалити сторінки?"),
+ ("Capture", "Зберегти"),
+ ("Panel Locations", "Розташування панелей"),
+ ("Close Tab Group", "Закрити групу вкладок"),
+ ("Minimize", "Згорнути"),
+ ("Collapse to Icons", "Згорнути до піктограм"),
+ ("Panel Options", "Параметри панелі"),
+ ("Panel Options…", "Параметри панелі…"),
+ ("Show Thumbnails", "Показувати мініатюри"),
+ ("Show Vertically", "Показувати вертикально"),
+ ("Panel Layout", "Компонування панелі"),
+ ("Pages on Top", "Сторінки зверху"),
+ ("Parents on Top", "Батьківські зверху"),
+ ("Resize:", "Зміна розміру:"),
+ ("Extra Small", "Дуже малий"),
+ ("Small", "Малий"),
+ ("Medium", "Середній"),
+ ("Large", "Великий"),
+ ("Extra Large", "Дуже великий"),
+ ("Jumbo", "Величезний"),
+ ("Proportional", "Пропорційно"),
+ ("Pages Fixed", "Сторінки фіксовані"),
+ ("Parents Fixed", "Батьківські фіксовані"),
+ ("Parents", "Батьківські сторінки"),
("Bulleted & Numbered Lists", "Марковані й нумеровані списки"),
("Current Page Number", "Номер поточної сторінки"),
("Apply Color (,)", "Застосувати колір (,)"),
diff --cc crates/ui-egui/src/lib.rs
index e6600890a,57b9a67d5..79eb2c44c
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@@ -213,8 -195,11 +213,13 @@@ pub struct UiState
pub flattener_preview: bool,
/// Tab / Shift+Tab: 1 = every panel hidden, 2 = all but the Tools panel (0 = shown).
pub hidden_panels: u8,
+ /// "Don't show again" in the warning before deleting pages that contain objects.
+ pub skip_delete_pages_warning: bool,
+ /// The Pages panel's parents part as its divider was last dragged, and the height the two
+ /// parts shared then (None: a few rows).
+ pub pages_parents_height: Option<[f32; 2]>,
+ /// The Pages panel's Panel Options.
+ pub pages_panel: panels::pages::PanelOptions,
/// Edit › Color Settings (re-applied at start).
pub color_settings: Option<designcraft_color::cms::ColorSettings>,
/// View › Proof Colors and View › Proof Setup.
@@@ -372,7 -344,8 +377,9 @@@ impl Default for UiState
tag_markers: false,
flattener_preview: false,
hidden_panels: 0,
+ skip_delete_pages_warning: false,
+ pages_parents_height: None,
+ pages_panel: Default::default(),
color_settings: None,
proof_colors: false,
proof_setup: Default::default(),
diff --cc crates/ui-egui/src/panels/pages.rs
index 6c3e0e10c,562006235..3fbb2fd5d
--- a/crates/ui-egui/src/panels/pages.rs
+++ b/crates/ui-egui/src/panels/pages.rs
@@@ -10,54 -9,33 +10,55 @@@ use serde_json::json
use crate::theme::Tokens;
use crate::{DesignApp, icons};
-/// (document uid, revision, page, thumbnail height).
-type ThumbKey = (u64, u64, usize, u32);
+/// What a thumbnail shows: a document page (absolute index) or a whole parent spread.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+enum ThumbOf {
+ Page(usize),
+ Parent(SpreadId),
+}
+
- type ThumbKey = (u64, u64, ThumbOf);
++/// (document uid, revision, page or parent, thumbnail height).
++type ThumbKey = (u64, u64, ThumbOf, u32);
static THUMBS: Mutex<Option<HashMap<ThumbKey, egui::TextureHandle>>> = Mutex::new(None);
-fn thumb(app: &mut DesignApp, ctx: &egui::Context, abs: usize, h: f32) -> Option<egui::TextureHandle> {
+/// Widest parent thumbnail, in pixels (a spread of many pages stays a small texture).
+const MAX_THUMB_W: f64 = 1024.0;
+
+fn thumb(app: &mut DesignApp, ctx: &egui::Context, of: ThumbOf, h: f32) -> Option<egui::TextureHandle> {
let st = app.session.active()?;
- let key = (st.uid, st.revision, of);
- let key = (st.uid, st.revision, abs, h.round() as u32);
++ let key = (st.uid, st.revision, of, h.round() as u32);
let mut g = THUMBS.lock().unwrap_or_else(|e| e.into_inner());
let map = g.get_or_insert_with(HashMap::new);
if let Some(t) = map.get(&key) {
return Some(t.clone());
}
- let page = st.doc.page(abs)?;
- let scale = (h as f64 * ctx.pixels_per_point() as f64) / page.height;
+ let px = h as f64 * ctx.pixels_per_point() as f64;
let mut r = designcraft_render::Renderer::new();
r.threads = 0;
- let img = r.render_page(
- &st.doc,
- &app.session.cache,
- abs,
- scale,
- false,
- &designcraft_render::RenderOptions { printing_only: true, ..Default::default() },
- )?;
+ let opts = designcraft_render::RenderOptions { printing_only: true, ..Default::default() };
+ let (img, name) = match of {
+ ThumbOf::Page(abs) => {
+ let page = st.doc.page(abs)?;
+ let img = r.render_page(&st.doc, &app.session.cache, abs, px / page.height.max(1e-6), false, &opts)?;
+ (img, format!("thumb{abs}"))
+ }
+ ThumbOf::Parent(id) => {
+ let i = st.doc.parent_index(id)?;
+ let b = st.doc.parents.get(i)?.bounds();
+ if !(b.width() > 0.0 && b.height() > 0.0) {
+ return None;
+ }
+ let scale = (px / b.height()).min(MAX_THUMB_W / b.width());
+ let (w, h) = ((b.width() * scale).round().max(1.0) as u32, (b.height() * scale).round().max(1.0) as u32);
+ let view = designcraft_geom::Affine::scale(scale) * designcraft_geom::Affine::translate(-b.origin().to_vec2());
+ let o = designcraft_render::RenderOptions { background: Some([255, 255, 255, 255]), ..opts };
+ let placed = [designcraft_render::Placed { spread: SpreadRef::Parent(i), xf: designcraft_geom::Affine::IDENTITY }];
+ (r.render(&st.doc, &app.session.cache, &placed, w, h, view, &o), format!("thumbp{}", id.0))
+ }
+ };
let ci = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
- let tex = crate::widgets::load_texture(ctx, name, ci, egui::TextureOptions::LINEAR);
- let tex = crate::widgets::load_texture(ctx, format!("thumb{abs}_{}", h.round()), ci, egui::TextureOptions::LINEAR);
++ let tex = crate::widgets::load_texture(ctx, format!("{name}_{}", h.round()), ci, egui::TextureOptions::LINEAR);
// Drop thumbnails of older revisions.
let (uid, rev) = (st.uid, st.revision);
map.retain(|k, _| !(k.0 == uid && k.1 != rev));
@@@ -70,10 -160,16 +183,16 @@@ impl Default for PanelOptions
enum PageDrag {
/// A document page (absolute index).
Page(usize),
- /// A parent (prefix; `None` = [None]).
- Parent(Option<String>),
+ /// A parent (`None` = [None]).
+ Parent(Option<SpreadId>),
}
+ /// The footer: page count and buttons, always at the panel's bottom.
+ const FOOTER_H: f32 = 28.0;
+ /// The draggable rule between the parents and the pages.
+ const DIVIDER_H: f32 = 9.0;
+ /// Parent rows shown at first; the divider shows more.
+ const PARENTS_DEFAULT_ROWS: f32 = 4.5;
/// Selected-page tint (multiplied over the thumbnail).
const SELECTED_TINT: Color32 = Color32::from_rgb(0x88, 0xc7, 0xfb);
/// Page-number badge of the selected page.
@@@ -83,41 -179,13 +202,58 @@@ const THUMB_H: f32 = 37.0
/// Parent rows.
const ROW_H: f32 = 29.0;
- /// Parent icon height.
- const PARENT_THUMB_H: f32 = 24.0;
-
- /// Paint a parent's icon right-aligned at `right`: its rendered spread, or blank pages of `aspect`
- /// for [None] (`parent` = `None`) and when the spread can't be rendered.
- fn parent_icon(app: &mut DesignApp, ui: &egui::Ui, right: egui::Pos2, parent: Option<(usize, SpreadId)>, aspect: f32, t: &Tokens) {
- let h = PARENT_THUMB_H;
- let doc = app.session.active().map(|st| st.doc.clone());
- let spread = parent.and_then(|(i, _)| doc.as_ref()?.parents.get(i).cloned());
- // Page outlines in icon coordinates (left, width), from the spread's own pages.
- let (pages, total): (Vec<(f32, f32)>, f32) = match &spread {
- Some(sp) if sp.bounds().height() > 0.0 => {
- let b = sp.bounds();
- let k = h as f64 / b.height();
-/// Paint a blank page icon of `n` pages (parents list), right-aligned at `right`.
-fn blank_spread(p: &egui::Painter, right: egui::Pos2, n: usize, aspect: f32, h: f32, t: &Tokens) {
- let w = h * aspect;
- let n = n.max(1);
- for k in 0..n {
- let r = egui::Rect::from_min_size(egui::pos2(right.x - w * (n - k) as f32, right.y - h / 2.0), vec2(w, h));
- p.rect_filled(r, 0.0, Color32::WHITE);
++/// A row of the Pages panel's parents list: [None] (`parent` = `None`) or a parent.
++struct ParentRow {
++ label: String,
++ prefix: Option<String>,
++ /// Index in `doc.parents` and id.
++ parent: Option<(usize, SpreadId)>,
++ /// Page outlines (left, width) and the icon's width, for an icon 1 high.
++ pages: Vec<(f32, f32)>,
++ unit_w: f32,
++}
++
++impl ParentRow {
++ /// A parent's row, from the spread's own pages; blank pages of `aspect` when it has no size.
++ fn new(i: usize, sp: &designcraft_doc::Spread, aspect: f32) -> ParentRow {
++ let b = sp.bounds();
++ let (pages, unit_w) = if b.width() > 0.0 && b.height() > 0.0 && b.width().is_finite() && b.height().is_finite() {
++ let k = 1.0 / b.height();
+ (sp.pages.iter().map(|p| (((p.x - b.x0) * k) as f32, (p.width * k) as f32)).collect(), (b.width() * k) as f32)
++ } else {
++ let n = sp.pages.len().max(1);
++ ((0..n).map(|k| (aspect * k as f32, aspect)).collect(), aspect * n as f32)
++ };
++ ParentRow {
++ label: sp.parent.as_ref().map(|i| i.label()).unwrap_or_default(),
++ prefix: sp.parent.as_ref().map(|i| i.prefix.clone()),
++ parent: Some((i, sp.id)),
++ pages,
++ unit_w,
+ }
- _ => {
- let n = spread.as_ref().map_or(1, |sp| sp.pages.len().max(1));
- let w = h * aspect;
- ((0..n).map(|k| (w * k as f32, w)).collect(), w * n as f32)
- }
- };
- let area = egui::Rect::from_min_size(egui::pos2(right.x - total, right.y - h / 2.0), vec2(total, h));
- let tex = parent.and_then(|(_, id)| thumb(app, ui.ctx(), ThumbOf::Parent(id), h));
++ }
++
++ fn none(aspect: f32) -> ParentRow {
++ ParentRow { label: "[None]".into(), prefix: None, parent: None, pages: vec![(0.0, aspect)], unit_w: aspect }
++ }
++}
++
++/// Paint a parent's icon `h` high, right-aligned at `right`: its rendered spread (when
++/// `thumbnails`), or blank pages for [None] and when the spread can't be rendered.
++fn parent_icon(app: &mut DesignApp, ui: &egui::Ui, right: egui::Pos2, row: &ParentRow, h: f32, thumbnails: bool, t: &Tokens) {
++ let area = egui::Rect::from_min_size(egui::pos2(right.x - row.unit_w * h, right.y - h / 2.0), vec2(row.unit_w * h, h));
++ let tex = if thumbnails { row.parent.and_then(|(_, id)| thumb(app, ui.ctx(), ThumbOf::Parent(id), h)) } else { None };
+ let p = ui.painter();
+ match tex {
+ Some(tex) => {
+ p.image(tex.id(), area, egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), Color32::WHITE);
+ }
+ None => {
+ p.rect_filled(area, 0.0, Color32::WHITE);
+ }
+ }
- for (x, w) in pages {
- let r = egui::Rect::from_min_size(egui::pos2(area.min.x + x, area.min.y), vec2(w, h));
++ for (x, w) in &row.pages {
++ let r = egui::Rect::from_min_size(egui::pos2(area.min.x + x * h, area.min.y), vec2(w * h, h));
p.rect_stroke(r, 0.0, Stroke::new(0.5, t.border), StrokeKind::Inside);
}
}
@@@ -130,132 -198,272 +266,286 @@@ pub fn show(app: &mut DesignApp, ui: &m
let aspect = (doc.settings.page_width / doc.settings.page_height.max(1.0)) as f32;
let mut drop: Option<(PageDrag, usize)> = None;
ui.spacing_mut().item_spacing.y = 0.0;
- // ---- Parents: [None] and each parent, 29 pt rows with the parent's thumbnail at the right.
- // ---- Parents: [None] and each parent, 29 pt rows with a blank thumbnail at the right.
- let mut rows: Vec<(String, Option<String>, usize)> = vec![("[None]".into(), None, 1)];
- for p in &doc.parents {
- let label = p.parent.as_ref().map(|i| i.label()).unwrap_or_default();
- rows.push((label, p.parent.as_ref().map(|i| i.prefix.clone()), p.pages.len()));
- }
++ // ---- Parents: [None] and each parent, rows with the parent's thumbnail at the right.
+ // While parents are edited, the row of the parent the canvas shows is selected.
+ let cur_parent = if editing_parents {
+ let layout = designcraft_tools::CanvasLayout::new(&doc, true);
+ crate::canvas::current_slot(app, &layout).and_then(|i| layout.slots.get(i)).and_then(|s| match s.spread {
+ SpreadRef::Parent(i) => Some(i),
+ SpreadRef::Doc(_) => None,
+ })
+ } else {
+ None
+ };
- let mut rows: Vec<(String, Option<(usize, SpreadId)>)> = vec![("[None]".into(), None)];
- for (i, p) in doc.parents.iter().enumerate() {
- let label = p.parent.as_ref().map(|i| i.label()).unwrap_or_default();
- rows.push((label, Some((i, p.id))));
- }
- for (label, parent) in rows {
- let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), ROW_H), Sense::click_and_drag());
- let active = parent.is_some_and(|(i, _)| cur_parent == Some(i));
- resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, true, active, &label));
- if active {
- ui.painter().rect_filled(r, 0.0, t.row_selected);
- } else if resp.hovered() {
- ui.painter().rect_filled(r, 0.0, t.hover);
- }
- ui.painter().text(r.left_center() + vec2(3.0, 0.0), egui::Align2::LEFT_CENTER, &label, egui::FontId::proportional(11.5), t.text_strong);
- parent_icon(app, ui, egui::pos2(r.max.x - 10.0, r.center().y), parent, aspect, &t);
- resp.dnd_set_drag_payload(PageDrag::Parent(parent.map(|(_, id)| id)));
- if resp.double_clicked()
- && let Some((_, id)) = parent
- {
- let _ = app.run("layout.parents.edit", json!({"on": true, "parent": id.0}));
- }
- if resp.dragged() {
- drag_ghost(ui, &label, &t);
++ let mut rows = vec![ParentRow::none(aspect)];
++ rows.extend(doc.parents.iter().enumerate().map(|(i, p)| ParentRow::new(i, p, aspect)));
+ // As in InDesign: parents and pages each scroll on their own (parents on top unless Panel
+ // Options says pages), a divider between them resizes them, the footer stays at the bottom.
+ let opts = app.ui.pages_panel.clone();
+ let total = {
+ let h = ui.available_height();
+ if h.is_finite() && h < 4000.0 { h } else { 480.0 }
+ }
+ .max(160.0);
+ let row_h = opts.parent_size.row_h();
+ let icon_h = row_h - 5.0;
++ // Extra Small has no room for a thumbnail.
++ let parent_thumbnails = opts.parent_size != IconSize::ExtraSmall;
+ // Parents side by side (Show Vertically off): tiles of the icon and the prefix, wrapping.
- let tile_w = |n: usize| (icon_h * aspect * n.max(1) as f32 + 16.0).max(44.0);
++ let tile_w = |unit_w: f32| (icon_h * unit_w + 16.0).max(44.0);
+ let natural = if opts.parents_vertical {
+ rows.len() as f32 * row_h
+ } else {
+ let width = (ui.available_width() - 4.0).max(1.0);
+ let (mut lines, mut x) = (1.0_f32, 0.0_f32);
- for (_, _, n) in &rows {
- let w = tile_w(*n) + 6.0;
++ for row in &rows {
++ let w = tile_w(row.unit_w) + 6.0;
+ if x > 0.0 && x + w > width {
+ lines += 1.0;
+ x = 0.0;
+ }
+ x += w;
}
+ lines * (icon_h + 22.0)
+ };
+ let space = (total - FOOTER_H - DIVIDER_H).max(2.0 * ROW_H);
+ let parents_max = (space - 2.0 * ROW_H).max(ROW_H);
+ let parents_min = row_h.min(natural);
+ // The divider's place as last dragged, and how a change of the panel's height is shared.
+ let parents_h = match app.ui.pages_parents_height {
+ None => natural.min(PARENTS_DEFAULT_ROWS * ROW_H),
+ Some([h, at]) => match opts.resize {
+ PanelResize::ParentsFixed => h,
+ PanelResize::PagesFixed => h + (space - at),
+ PanelResize::Proportional => h * space / at.max(1.0),
+ },
}
- ui.add_space(4.0);
- let r = ui.available_rect_before_wrap();
- ui.painter().rect_filled(egui::Rect::from_min_size(egui::pos2(r.min.x - 10.0, r.min.y), vec2(r.width() + 20.0, 1.5)), 0.0, t.section_divider);
- ui.add_space(12.0);
+ .clamp(parents_min, parents_max)
+ .min(natural);
+ let pages_h = (space - parents_h).max(ROW_H);
+ let parents_part = |app: &mut DesignApp, ui: &mut egui::Ui| {
+ egui::ScrollArea::vertical().id_salt("pages_parents").max_height(parents_h).min_scrolled_height(parents_h).auto_shrink([false, true]).show(
+ ui,
+ |ui| {
+ ui.spacing_mut().item_spacing = vec2(6.0, 0.0);
- let each = |app: &mut DesignApp, ui: &mut egui::Ui, label: &str, prefix: &Option<String>, n: usize| {
++ let each = |app: &mut DesignApp, ui: &mut egui::Ui, row: &ParentRow| {
++ let label = row.label.as_str();
+ let (r, resp) = if opts.parents_vertical {
+ ui.allocate_exact_size(vec2(ui.available_width(), row_h), Sense::click_and_drag())
+ } else {
- ui.allocate_exact_size(vec2(tile_w(n), icon_h + 22.0), Sense::click_and_drag())
++ ui.allocate_exact_size(vec2(tile_w(row.unit_w), icon_h + 22.0), Sense::click_and_drag())
+ };
- let active = editing_parents && prefix.is_some();
++ let active = row.parent.is_some_and(|(i, _)| cur_parent == Some(i));
+ if active {
+ ui.painter().rect_filled(r, 0.0, t.row_selected);
+ } else if resp.hovered() {
+ ui.painter().rect_filled(r, 0.0, t.hover);
+ }
+ if opts.parents_vertical {
+ ui.painter().text(
+ r.left_center() + vec2(3.0, 0.0),
+ egui::Align2::LEFT_CENTER,
+ label,
+ egui::FontId::proportional(11.5),
+ t.text_strong,
+ );
- blank_spread(ui.painter(), egui::pos2(r.max.x - 10.0, r.center().y), n, aspect, icon_h, &t);
++ parent_icon(app, ui, egui::pos2(r.max.x - 10.0, r.center().y), row, icon_h, parent_thumbnails, &t);
+ } else {
- let w = icon_h * aspect * n.max(1) as f32;
- blank_spread(ui.painter(), egui::pos2(r.center().x + w / 2.0, r.min.y + 3.0 + icon_h / 2.0), n, aspect, icon_h, &t);
- let short = prefix.clone().unwrap_or_else(|| label.to_string());
++ let w = icon_h * row.unit_w;
++ parent_icon(app, ui, egui::pos2(r.center().x + w / 2.0, r.min.y + 3.0 + icon_h / 2.0), row, icon_h, parent_thumbnails, &t);
++ let short = row.prefix.clone().unwrap_or_else(|| label.to_string());
+ ui.painter().text(
+ egui::pos2(r.center().x, r.max.y - 9.0),
+ egui::Align2::CENTER_CENTER,
+ short,
+ egui::FontId::proportional(11.0),
+ t.text_strong,
+ );
+ }
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label));
++ resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, true, active, label));
+ let resp = if opts.parents_vertical { resp } else { resp.on_hover_text(label) };
- resp.dnd_set_drag_payload(PageDrag::Parent(prefix.clone()));
- if resp.double_clicked() && prefix.is_some() {
- let _ = app.run("layout.parents.edit", json!({"on": true}));
- app.views.clear();
++ resp.dnd_set_drag_payload(PageDrag::Parent(row.parent.map(|(_, id)| id)));
++ if resp.double_clicked()
++ && let Some((_, id)) = row.parent
++ {
++ let _ = app.run("layout.parents.edit", json!({"on": true, "parent": id.0}));
+ }
+ if resp.dragged() {
+ drag_ghost(ui, label, &t);
+ }
+ };
+ if opts.parents_vertical {
- for (label, prefix, n) in &rows {
- each(app, ui, label, prefix, *n);
++ for row in &rows {
++ each(app, ui, row);
+ }
+ } else {
+ ui.horizontal_wrapped(|ui| {
+ ui.spacing_mut().item_spacing = vec2(6.0, 0.0);
- for (label, prefix, n) in &rows {
- each(app, ui, label, prefix, *n);
++ for row in &rows {
++ each(app, ui, row);
+ }
+ });
+ }
+ },
+ );
+ };
// ---- Document spreads.
let cur = crate::canvas::current_page(app).unwrap_or(0);
let cur_spread = doc.page_loc(cur).map(|l| l.0);
- let center = ui.available_width() / 2.0;
let dragging = egui::DragAndDrop::has_any_payload(ui.ctx());
let tallest = doc.spreads.iter().flat_map(|sp| sp.pages.iter().map(|p| p.height)).fold(doc.settings.page_height, f64::max).max(1.0);
- for (si, sp) in doc.spreads.iter().enumerate() {
- let first = doc.first_page_of_spread(si);
- // One scale for the whole document (pages of their own size show in proportion): the
- // document's page size at the usual height, unless a taller page would pass 1.8 times it.
- // Each row is as tall as its spread's tallest page.
- let scale = (THUMB_H / doc.settings.page_height.max(1.0) as f32).min(1.8 * THUMB_H / tallest as f32);
- let row_h = sp.pages.iter().map(|p| p.height as f32 * scale).fold(0.0, f32::max).max(THUMB_H * 0.25);
- let spine = sp.spine_x() as f32;
- let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 8.0 + row_h + 22.0), Sense::hover());
- let top = row.min.y + 8.0;
- // Marker above the current spread.
- if cur_spread == Some(si) && !editing_parents {
- let c = egui::pos2(row.min.x + center, row.min.y + 3.5);
- ui.painter().add(egui::Shape::convex_polygon(vec![c + vec2(-5.0, -3.0), c + vec2(5.0, -3.0), c + vec2(0.0, 3.0)], t.icon, Stroke::NONE));
- }
- for (pi, p) in sp.pages.iter().enumerate() {
- let abs = first + pi;
- let x0 = row.min.x + center + (p.x as f32 - spine) * scale;
- let pr = egui::Rect::from_min_size(egui::pos2(x0, top), vec2(p.width as f32 * scale, p.height as f32 * scale));
- let resp = ui.interact(pr, ui.id().with(("page", abs)), Sense::click_and_drag());
- let selected = abs == cur && !editing_parents;
- let tint = if selected { SELECTED_TINT } else { Color32::WHITE };
- if let Some(tex) = thumb(app, ui.ctx(), ThumbOf::Page(abs), THUMB_H) {
- ui.painter().image(tex.id(), pr, egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), tint);
- } else {
- ui.painter().rect_filled(pr, 0.0, tint);
- }
- ui.painter().rect_stroke(pr, 0.0, Stroke::new(0.5, Color32::from_gray(0x4a)), StrokeKind::Outside);
- // Parent prefix in the outer top corner (black on white).
- if let Some(pid) = p.parent
- && let Some(pp) = doc.parents.iter().find(|x| x.id == pid)
- {
- let prefix = pp.parent.as_ref().map(|i| i.prefix.clone()).unwrap_or_default();
- let g = ui.painter().layout_no_wrap(prefix, crate::theme::semibold(9.5), Color32::BLACK);
- let w = g.size().x + 2.0;
- let br = if p.side == designcraft_doc::PageSide::Left {
- egui::Rect::from_min_size(pr.left_top(), vec2(w, 10.0))
- } else {
- egui::Rect::from_min_size(pr.right_top() - vec2(w, 0.0), vec2(w, 10.0))
- };
- ui.painter().rect_filled(br, 0.0, Color32::WHITE);
- ui.painter().galley(br.min + vec2(1.0, -0.5), g, Color32::BLACK);
- }
- // Drag and drop: pages reorder, parents apply.
- resp.dnd_set_drag_payload(PageDrag::Page(abs));
- if resp.dragged() {
- drag_ghost(ui, &app.session.page_label(abs), &t);
- }
- if dragging && resp.contains_pointer() {
- ui.painter().rect_stroke(pr.expand(1.5), 0.0, Stroke::new(2.0, BADGE), StrokeKind::Outside);
- }
- if let Some(payload) = resp.dnd_release_payload::<PageDrag>() {
- drop = Some(((*payload).clone(), abs));
- }
- if resp.clicked() || resp.double_clicked() {
- if editing_parents {
- let _ = app.run("layout.parents.edit", json!({"on": false}));
- // The canvas refits to the page's spread once it is centred.
- if let Some(v) = app.view_mut() {
- v.fitted = false;
+ let th = opts.page_size.page_h();
+ // Extra Small has no room for a thumbnail; Show Thumbnails off draws blank pages.
+ let thumbnails = opts.page_thumbnails && opts.page_size != IconSize::ExtraSmall;
+ let mut pages_part = |app: &mut DesignApp, ui: &mut egui::Ui| {
+ let center = ui.available_width() / 2.0;
+ egui::ScrollArea::vertical().id_salt("pages_spreads").max_height(pages_h).min_scrolled_height(pages_h).auto_shrink([false, false]).show(
+ ui,
+ |ui| {
+ ui.add_space(4.0);
+ for (si, sp) in doc.spreads.iter().enumerate() {
+ let first = doc.first_page_of_spread(si);
+ // One scale for the whole document (pages of their own size show in proportion): the
+ // document's page size at the panel's size, unless a taller page would pass 1.8 times it.
+ // Each row is as tall as its spread's tallest page.
+ let scale = (th / doc.settings.page_height.max(1.0) as f32).min(1.8 * th / tallest as f32);
+ let row_h = sp.pages.iter().map(|p| p.height as f32 * scale).fold(0.0, f32::max).max(th * 0.25);
+ let spine = sp.spine_x() as f32;
+ let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 8.0 + row_h + 22.0), Sense::hover());
+ let top = row.min.y + 8.0;
+ // Marker above the current spread.
+ if cur_spread == Some(si) && !editing_parents {
+ let c = egui::pos2(row.min.x + center, row.min.y + 3.5);
+ ui.painter().add(egui::Shape::convex_polygon(
+ vec![c + vec2(-5.0, -3.0), c + vec2(5.0, -3.0), c + vec2(0.0, 3.0)],
+ t.icon,
+ Stroke::NONE,
+ ));
+ }
+ // Pages narrower than their numbers ("10" under an Extra Small page) are labelled
+ // once for the spread.
+ let narrow = sp.pages.len() > 1
+ && (first..first + sp.pages.len()).zip(&sp.pages).any(|(abs, p)| {
+ let w = ui.painter().layout_no_wrap(app.session.page_label(abs), crate::theme::semibold(11.0), Color32::WHITE).size().x;
+ (p.width as f32 * scale) < w + 6.0
+ });
+ for (pi, p) in sp.pages.iter().enumerate() {
+ let abs = first + pi;
+ let x0 = row.min.x + center + (p.x as f32 - spine) * scale;
+ let pr = egui::Rect::from_min_size(egui::pos2(x0, top), vec2(p.width as f32 * scale, p.height as f32 * scale));
+ let resp = ui.interact(pr, ui.id().with(("page", abs)), Sense::click_and_drag());
+ let selected = abs == cur && !editing_parents;
+ // Screen readers hear "Page 3".
+ resp.widget_info(|| {
+ egui::WidgetInfo::selected(egui::WidgetType::Button, true, selected, format!("Page {}", app.session.page_label(abs)))
+ });
+ let tint = if selected { SELECTED_TINT } else { Color32::WHITE };
- match thumbnails.then(|| thumb(app, ui.ctx(), abs, th)).flatten() {
++ match thumbnails.then(|| thumb(app, ui.ctx(), ThumbOf::Page(abs), th)).flatten() {
+ Some(tex) => {
+ ui.painter().image(tex.id(), pr, egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), tint);
+ }
+ None => {
+ ui.painter().rect_filled(pr, 0.0, tint);
+ }
+ }
+ ui.painter().rect_stroke(pr, 0.0, Stroke::new(0.5, Color32::from_gray(0x4a)), StrokeKind::Outside);
+ // Parent prefix in the outer top corner (black on white).
+ if let Some(pid) = p.parent
+ && let Some(pp) = doc.parents.iter().find(|x| x.id == pid)
+ {
+ let prefix = pp.parent.as_ref().map(|i| i.prefix.clone()).unwrap_or_default();
+ let g = ui.painter().layout_no_wrap(prefix, crate::theme::semibold(9.5), Color32::BLACK);
+ let w = g.size().x + 2.0;
+ let br = if p.side == designcraft_doc::PageSide::Left {
+ egui::Rect::from_min_size(pr.left_top(), vec2(w, 10.0))
+ } else {
+ egui::Rect::from_min_size(pr.right_top() - vec2(w, 0.0), vec2(w, 10.0))
+ };
+ ui.painter().rect_filled(br, 0.0, Color32::WHITE);
+ ui.painter().galley(br.min + vec2(1.0, -0.5), g, Color32::BLACK);
+ }
+ // Drag and drop: pages reorder, parents apply.
+ resp.dnd_set_drag_payload(PageDrag::Page(abs));
+ if resp.dragged() {
+ drag_ghost(ui, &app.session.page_label(abs), &t);
+ }
+ if dragging && resp.contains_pointer() {
+ ui.painter().rect_stroke(pr.expand(1.5), 0.0, Stroke::new(2.0, BADGE), StrokeKind::Outside);
+ }
+ if let Some(payload) = resp.dnd_release_payload::<PageDrag>() {
+ drop = Some(((*payload).clone(), abs));
+ }
+ if resp.clicked() || resp.double_clicked() {
+ if editing_parents {
+ let _ = app.run("layout.parents.edit", json!({"on": false}));
- app.views.clear();
++ // The canvas refits to the page's spread once it is centred.
++ if let Some(v) = app.view_mut() {
++ v.fitted = false;
++ }
+ }
+ crate::canvas::go_to_page(app, abs);
+ }
+ resp.context_menu(|ui| page_menu(app, ui, &doc, abs, si));
+ // Page number under the page: white on a blue badge when selected. Pages too
+ // narrow for their numbers share one label under the spread (below).
+ if narrow {
+ continue;
+ }
+ let name = app.session.page_label(abs);
+ let g = ui.painter().layout_no_wrap(name, crate::theme::semibold(11.0), Color32::WHITE);
+ let c = egui::pos2(pr.center().x, pr.max.y + 11.0);
+ if selected {
+ let br = egui::Rect::from_center_size(c, vec2(g.size().x.max(7.0) + 7.0, 12.5));
+ ui.painter().rect_filled(br, 0.0, BADGE);
+ }
+ ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
+ }
+ if narrow {
+ let names: Vec<String> = (first..first + sp.pages.len()).map(|abs| app.session.page_label(abs)).collect();
+ let label = match (names.first(), names.last()) {
+ (Some(a), Some(b)) if names.len() > 1 => format!("{a}\u{2013}{b}"),
+ (Some(a), _) => a.clone(),
+ _ => String::new(),
+ };
+ let g = ui.painter().layout_no_wrap(label, crate::theme::semibold(11.0), Color32::WHITE);
+ let c = egui::pos2(row.min.x + center, top + row_h + 11.0);
+ if cur_spread == Some(si) && !editing_parents {
+ ui.painter().rect_filled(egui::Rect::from_center_size(c, vec2(g.size().x + 7.0, 12.5)), 0.0, BADGE);
+ }
+ ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
}
}
- crate::canvas::go_to_page(app, abs);
- }
- resp.context_menu(|ui| page_menu(app, ui, &doc, abs, si));
- // Page number under the page: white on a blue badge when selected.
- let name = app.session.page_label(abs);
- let g = ui.painter().layout_no_wrap(name, crate::theme::semibold(11.0), Color32::WHITE);
- let c = egui::pos2(pr.center().x, pr.max.y + 11.0);
- if selected {
- let br = egui::Rect::from_center_size(c, vec2(g.size().x.max(7.0) + 7.0, 12.5));
- ui.painter().rect_filled(br, 0.0, BADGE);
- }
- ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
+ // Right-click on the empty part of the panel: the short menu.
+ let rest = ui.available_rect_before_wrap();
+ let (_, empty) = ui.allocate_exact_size(vec2(ui.available_width(), rest.height().max(8.0)), Sense::click());
+ empty.context_menu(|ui| empty_menu(app, ui));
+ },
+ );
+ };
+ // The divider: drag it to show more or fewer parents.
+ let divider = |app: &mut DesignApp, ui: &mut egui::Ui| {
+ let (dr, dresp) = ui.allocate_exact_size(vec2(ui.available_width(), DIVIDER_H), Sense::drag());
+ let line = egui::Rect::from_center_size(dr.center(), vec2(dr.width() + 20.0, 1.5));
+ ui.painter().rect_filled(line, 0.0, if dresp.hovered() || dresp.dragged() { t.text_dim } else { t.section_divider });
+ let dresp = dresp.on_hover_cursor(egui::CursorIcon::ResizeVertical);
+ if dresp.dragged() {
+ let dy = dresp.drag_delta().y * if opts.pages_on_top { -1.0 } else { 1.0 };
+ app.ui.pages_parents_height = Some([(parents_h + dy).clamp(parents_min, parents_max), space]);
}
+ dresp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, true, "Parents and pages divider"));
+ };
+ if opts.pages_on_top {
+ pages_part(app, ui);
+ divider(app, ui);
+ parents_part(app, ui);
+ } else {
+ parents_part(app, ui);
+ divider(app, ui);
+ pages_part(app, ui);
}
- ui.add_space(6.0);
ui.spacing_mut().item_spacing.y = 4.0;
ui.horizontal(|ui| {
+ ui.set_min_height(FOOTER_H - 4.0);
crate::rtl::label(
ui,
egui::RichText::new(
@@@ -544,62 -749,96 +872,152 @@@ mod tests
assert_eq!(h.state().session.doc().unwrap().doc.page_count(), 4, "only the clicked page");
}
+ /// As in InDesign: deleting a page with objects asks first; an empty page goes at once, and
+ /// "Don't show again" stops the question.
+ #[test]
+ fn deleting_a_page_with_objects_asks_first() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"pages": 5, "facingPages": true})).unwrap();
+ let doc = app.session.doc().unwrap().doc.clone();
+ let (si, pi) = doc.page_loc(2).unwrap();
+ let x = doc.spreads[si].pages[pi].x;
+ app.run("frame.create", json!({"spread": si, "rect": [x + 36.0, 36.0, x + 200.0, 200.0]})).unwrap();
+ let count = |h: &Harness<'_, DesignApp>| h.state().session.doc().unwrap().doc.page_count();
+ let mut h = menu_harness(app, 2, si);
+ h.get_by_label("Delete Page").click();
+ h.run_steps(3);
+ assert_eq!(count(&h), 5, "nothing deleted yet");
+ let d = h.state().ui.dialog.clone().unwrap();
+ assert_eq!((d.id.as_str(), d.fields["pages"].clone()), ("deletePages", json!([2])));
+ // Cancel keeps the page.
+ crate::dialogs::cancel(h.state_mut());
+ assert_eq!(count(&h), 5);
+ // The whole spread: one question for both pages.
+ h.get_by_label("Delete Spread").click();
+ h.run_steps(3);
+ assert_eq!(h.state().ui.dialog.as_ref().unwrap().fields["pages"], json!([1, 2]));
+ crate::dialogs::cancel(h.state_mut());
+ // OK deletes it.
+ h.get_by_label("Delete Page").click();
+ h.run_steps(3);
+ crate::dialogs::confirm(h.state_mut()).unwrap();
+ assert_eq!(count(&h), 4);
+ assert!(!h.state().ui.skip_delete_pages_warning);
+ // An empty page goes without a question.
+ let app = h.state_mut();
+ crate::dialogs::delete_pages(app, vec![0]).unwrap();
+ assert!(app.ui.dialog.is_none());
+ assert_eq!(app.session.doc().unwrap().doc.page_count(), 3);
+ // "Don't show again".
+ let doc = app.session.doc().unwrap().doc.clone();
+ let (si, pi) = doc.page_loc(1).unwrap();
+ let x = doc.spreads[si].pages[pi].x;
+ app.run("frame.create", json!({"spread": si, "rect": [x + 36.0, 36.0, x + 200.0, 200.0]})).unwrap();
+ app.run("frame.create", json!({"spread": si, "rect": [x + 36.0, 300.0, x + 200.0, 400.0]})).unwrap();
+ crate::dialogs::delete_pages(app, vec![1]).unwrap();
+ app.ui.dialog.as_mut().unwrap().fields.insert("dontShowAgain".into(), json!(true));
+ crate::dialogs::confirm(app).unwrap();
+ assert!(app.ui.skip_delete_pages_warning);
+ assert_eq!(app.session.doc().unwrap().doc.page_count(), 2);
+ let doc = app.session.doc().unwrap().doc.clone();
+ let (si, pi) = doc.page_loc(0).unwrap();
+ let x = doc.spreads[si].pages[pi].x;
+ app.run("frame.create", json!({"spread": si, "rect": [x + 36.0, 36.0, x + 200.0, 200.0]})).unwrap();
+ crate::dialogs::delete_pages(app, vec![0]).unwrap();
+ assert!(app.ui.dialog.is_none(), "no more questions");
+ assert_eq!(app.session.doc().unwrap().doc.page_count(), 1);
+ }
+
+ /// As InDesign's: the footer stays at the bottom however many pages there are, and the
+ /// divider between parents and pages shows more or fewer parents.
+ #[test]
+ fn the_footer_stays_put_and_the_divider_resizes_the_parents() {
+ use egui::{Event, Modifiers, PointerButton};
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"pages": 60, "facingPages": true})).unwrap();
+ for prefix in ["B", "C", "D", "E", "F", "G"] {
+ app.run("layout.parents.new", json!({"prefix": prefix})).unwrap();
+ }
+ app.ui.dock_tab = "pages".into();
+ let mut h = crate::test_window::open(app, vec2(1400.0, 900.0));
+ let window = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1400.0, 900.0));
+ for label in ["60 Pages in 31 Spreads", "Create new page", "Delete selected pages"] {
+ assert!(window.contains_rect(h.get_by_label(label).rect()), "{label} is on screen");
+ }
+ // Seven parent rows: four and a half show at first; the rest scroll.
+ let divider = h.get_by_label("Parents and pages divider").rect();
+ let before = divider.center().y;
+ assert!(h.query_by_label("G-Parent").is_none_or(|n| n.rect().top() > divider.top()), "the last parent is scrolled away");
+ let (a, b) = (divider.center(), divider.center() + vec2(0.0, 80.0));
+ h.input_mut().events.push(Event::PointerMoved(a));
+ h.input_mut().events.push(Event::PointerButton { pos: a, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
+ h.step();
+ for k in 1..=4 {
+ h.input_mut().events.push(Event::PointerMoved(a + (b - a) * (k as f32 / 4.0)));
+ h.step();
+ }
+ h.input_mut().events.push(Event::PointerButton { pos: b, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });
+ h.run_steps(3);
+ let after = h.get_by_label("Parents and pages divider").rect().center().y;
+ assert!(after > before + 40.0, "the divider moved down: {before} → {after}");
+ assert!(h.state().app.ui.pages_parents_height.is_some());
+ assert!(window.contains_rect(h.get_by_label("Create new page").rect()), "the footer is still there");
+ }
+
+ /// InDesign's Panel Options: thumbnail sizes, blank pages without thumbnails, parents side by
+ /// side, pages on top.
+ #[test]
+ fn panel_options_size_and_arrange_the_panel() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"pages": 6, "facingPages": true})).unwrap();
+ app.run("layout.parents.new", json!({"prefix": "B"})).unwrap();
+ app.ui.dock_tab = "pages".into();
+ let mut h = crate::test_window::open(app, vec2(1400.0, 900.0));
+ let page = |h: &Harness<'_, crate::test_window::Window>| h.get_by_label("Page 1").rect();
+ let medium = page(&h).height();
+ // The right-click menu on the panel's empty part leads to Panel Options.
+ let empty = h.get_by_label("Create new page").rect().center() - vec2(0.0, 60.0);
+ h.input_mut().events.push(egui::Event::PointerMoved(empty));
+ for pressed in [true, false] {
+ h.input_mut().events.push(egui::Event::PointerButton {
+ pos: empty,
+ button: egui::PointerButton::Secondary,
+ pressed,
+ modifiers: egui::Modifiers::NONE,
+ });
+ }
+ h.run_steps(3);
+ h.get_by_label("Panel Options…").click();
+ h.run_steps(3);
+ let d = h.state().app.ui.dialog.clone().unwrap();
+ assert_eq!(
+ (d.id.as_str(), d.fields["pageSize"].clone(), d.fields["parentSize"].clone(), d.fields["layout"].clone()),
+ ("pagesPanelOptions", json!("medium"), json!("small"), json!("parentsOnTop"))
+ );
+ // Jumbo pages, parents side by side, pages on top.
+ let set = |h: &mut Harness<'_, crate::test_window::Window>, k: &str, v: serde_json::Value| {
+ h.state_mut().app.ui.dialog.as_mut().unwrap().fields.insert(k.into(), v);
+ };
+ set(&mut h, "pageSize", json!("jumbo"));
+ set(&mut h, "parentsVertical", json!(false));
+ set(&mut h, "layout", json!("pagesOnTop"));
+ crate::dialogs::confirm(&mut h.state_mut().app).unwrap();
+ h.run_steps(4);
+ assert!(page(&h).height() > 2.5 * medium, "Jumbo: {} vs {medium}", page(&h).height());
+ let o = &h.state().app.ui.pages_panel;
+ assert_eq!((o.page_size, o.parents_vertical, o.pages_on_top), (IconSize::Jumbo, false, true));
+ // Pages on top: the parents come after the pages; side by side: [None] and A sit in one row.
+ let (none, a) = (h.get_by_label("[None]").rect(), h.get_by_label("A-Parent").rect());
+ assert!(none.top() > page(&h).top(), "parents below the pages");
+ assert!((none.top() - a.top()).abs() < 1.0 && a.left() > none.right(), "side by side");
+ // Extra Small: no thumbnails, just pages.
+ crate::panels::pages::open_panel_options(&mut h.state_mut().app);
+ set(&mut h, "pageSize", json!("extraSmall"));
+ crate::dialogs::confirm(&mut h.state_mut().app).unwrap();
+ h.run_steps(4);
+ assert!(page(&h).height() < 0.5 * medium);
+ }
+
#[test]
fn the_panel_menu_follows_indesigns_order() {
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());