Skip to content

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

TOC-5: integrate PR #892 section markers on current main

moppeeerff9f482a6edc
diff --cc ROADMAP.md
index 9bd0274ef,4f5bc2614..4b47f97a0
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -408,14 -357,18 +408,15 @@@ Newest first
- **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.
- **2026-10-15** · A story that ends with a return is no longer overset when only its empty last paragraph doesn't fit, as in InDesign (Preflight said "Overset text: 0 characters" for a caption InDesign shows with no errors). No readiness percentage change.
- **2026-10-15** · Flex Layout (InDesign 2026): Object › Flex Layout (Add to, Convert to, Remove) and a Flex Layout panel laid out as InDesign's, also in Properties. A container lays out its objects by direction, wrap, justification, the alignment grid, Fixed/Auto width and height, padding and spacing, after every edit; Add detects aligned objects (direction, Auto size, Space Between at their spacing); resizing a container reflows its objects instead of scaling them; dragging an object in one reorders it. Montilla Design's tutorial replays step for step. No readiness percentage change.
-- **2026-10-14** · Layout › Margins and Columns and Layout › Create Guides are laid out as InDesign's: Margins in Top/Bottom and Inside/Outside pairs with a link button that makes all four the same, Rows and Columns side by side, Fit Guides to Margins or Page, and a Preview checkbox that shows the change on the canvas before OK. A measurement field works out arithmetic when you leave it (`0.4375 in*2` becomes `0.875 in`). No readiness percentage change.
-- **2026-10-14** · The Pathfinder panel is laid out as InDesign's: Paths (Join, Open, Close, Reverse), Pathfinder, Convert Shape and Convert Point, each a row of icon buttons. Join Path closes an open path or joins two at their nearest ends (`path.join`), and Convert Point makes the selected points plain, corner, smooth or symmetrical (`path.convertPoints`). No readiness percentage change.
-- **2026-10-12** · Linked text files (#597): placed Word, RTF and text files can stay linked; the Links panel shows them OK / Modified / Missing, and Update imports the file again into the same frames with the saved style map (the Links panel asks before replacing edits made in the layout). No readiness percentage change.
- **2026-10-15** · IDML: the CJK leading model InDesign writes on [No paragraph style] of every document (Aki Below) only applies when the document uses a Japanese composer, as in InDesign; a Western document's paragraphs after a size change no longer sit lower than in InDesign (Montilla Design's Flex Layout file: its captions came out overset). No readiness percentage change.
-- **2026-10-14** · Type › Fill with Placeholder Text fills a frame with paragraphs of a few sentences, as InDesign does, so one paragraph can be styled on its own (it was one long paragraph, and the filler ran sentences together, "interit.Ovid"). No readiness percentage change.
-- **2026-10-13** · Object › Fitting has InDesign's shortcuts: Fill Frame Proportionally ⌘⌥⇧C, Fit Content Proportionally ⌘⌥⇧E, Fit Frame to Content ⌘⌥C, Fit Content to Frame ⌘⌥E, Center Content ⌘⇧E. No readiness percentage change.
-- **2026-10-13** · Gradients between process colours blend as inks, as InDesign shows them: magenta to cyan passes through C 50 M 50 (a light lilac) on screen instead of the darker RGB mix, and a midpoint between CMYK or grey stops no longer turns the PDF shading RGB. No readiness percentage change.
-- **2026-10-14** · The Swatches panel has InDesign's header: a Fill/Stroke proxy, Formatting Affects Container/Text and the Tint of the colour in front (a tint alone keeps each object's own swatch). Clicking a swatch applies it to the fill or stroke in front (of the text, when formatting affects text), and the bottom row has New Color Group, New Swatch and Delete Swatch. No readiness percentage change.
-- **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule (now with Controlled by Parent) and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
-- **2026-10-14** · On an object-based page the Page tool shows a selected object's liquid pins and resize locks as InDesign does: a click pins a side to the page edge or locks the width or height, with InDesign's tooltips. No readiness percentage change.
+- **2026-10-15** · IDML: linked images in a subfolder beside the package load when the package is opened on another machine (a link to `/images/logo.png` finds `images/logo.png` next to the .idml); they showed as missing. No readiness percentage change.
++- **2026-10-14** · The Pages panel labels spreads as ranges or separate names across a section start, marks each section’s first page with a triangle, and scrolls to the page in view (#892). No readiness percentage change.
+- **2026-10-14** · Overset text is marked on every frame that ends an overset story, selected or not and inside groups too (the red mark at the out port, with frame edges shown); a selected group shows the in/out ports of the text frames inside it. InDesign shows it only on the selected frame, which hides overset labels in grouped objects until Preflight. No readiness percentage change.
+- **2026-10-14** · Load Swatches adds the colors of an `.ase` file that repeat a name or have none: a repeated name gets a number (`Red 2`), and a color without a name is named by its value (`C=0 M=0 Y=0 K=55`). Before, a repeated name kept one of its colors, and only the first unnamed color was added, with an empty name. No readiness percentage change.
+- **2026-10-14** · Objects snap to the bleed guide's four sides while moving, resizing or drawing; snapping and the canvas share one bleed rectangle (`Spread::bleed_rect`). No readiness percentage change.
+- **2026-10-14** · Threading keeps generated and linked stories, text that refers to a story, local IDs and locked frames intact; a colour chosen at a caret waits for the typing, Swap Fill and Stroke on text keeps each run's colours, control-channel input never reads or writes the system clipboard, and IDML frame preferences given as properties import with bounded column counts (#84). No readiness percentage change.
- **2026-10-14** · The Liquid Layout panel follows InDesign's: Liquid Page Rule with the page number, Content › Auto-Fit, and Object Constraints › Resize with Page and Pin for the selected object on an object-based page; Create Alternate Layout moved to the Layout menu. No readiness percentage change.
-- **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule (now with Controlled by Parent) and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
+- **2026-10-14** · On an object-based page the Page tool shows a selected object's liquid pins and resize locks as InDesign does: a click pins a side to the page edge or locks the width or height, with InDesign's tooltips. No readiness percentage change.
- **2026-10-14** · With the Page tool, the Control panel shows the page as InDesign's does: W/H from a reference point, page-size preset (US Business Card added), orientation, Liquid Page Rule and Show Parent Page Overlay, which draws the parent page's size over a resized page. No readiness percentage change.
- **2026-10-14** · The Page tool works as InDesign's: a click selects a page and shows its handles and liquid page rule; dragging a handle previews the rule and springs back, Alt-drag resizes the page from the opposite edge, Shift keeps proportions, with a W/H readout. No readiness percentage change.
- **2026-10-14** · With the Page tool, a guide dragged from a ruler is a liquid guide (dashed), as in InDesign; guide-based pages stretch the objects it crosses. No readiness percentage change.
diff --cc crates/ui-egui/src/panels/pages.rs
index 0562b4eda,c6abc77ea..ef9895373
--- a/crates/ui-egui/src/panels/pages.rs
+++ b/crates/ui-egui/src/panels/pages.rs
@@@ -185,77 -47,46 +185,96 @@@ 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.
+const BADGE: Color32 = Color32::from_rgb(0x2f, 0x73, 0xe0);
+/// Thumbnail height (InDesign: about 28×37 pt for Letter).
+const THUMB_H: f32 = 37.0;
+/// Parent rows.
+const ROW_H: f32 = 29.0;
+
+ /// A spread's label under its thumbnails, as InDesign's: one name for a single page, "2–3" for
+ /// pages numbered on in one section (an en dash), and the names apart ("2, 1", "8, A") when a section starts
+ /// inside the spread.
+ pub(crate) fn spread_label(app: &DesignApp, doc: &designcraft_doc::Document, first: usize, n: usize) -> String {
+ let names: Vec<String> = (first..first + n).map(|abs| app.session.page_label(abs)).collect();
+ let starts = |abs: usize| abs == 0 || doc.sections.iter().any(|s| s.start == abs);
+ match (names.first(), names.last()) {
+ (Some(a), Some(b)) if names.len() > 1 => {
+ if !app.session.prefs.absolute_page_numbers && (first + 1..first + n).any(starts) {
+ names.join(", ")
+ } else {
+ format!("{a}\u{2013}{b}")
+ }
+ }
+ (Some(a), _) => a.clone(),
+ _ => String::new(),
+ }
+ }
+
-/// Selected-page tint (multiplied over the thumbnail).
-const SELECTED_TINT: Color32 = Color32::from_rgb(0x88, 0xc7, 0xfb);
-/// Page-number badge of the selected page.
-const BADGE: Color32 = Color32::from_rgb(0x2f, 0x73, 0xe0);
-/// Thumbnail height (InDesign: about 28×37 pt for Letter).
-const THUMB_H: f32 = 37.0;
-/// Parent rows.
-const ROW_H: f32 = 29.0;
+/// 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,
+ }
+ }
-/// 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, t: &Tokens) {
- let h = 24.0;
- 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);
+ 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 &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);
}
}
@@@ -263,6 -94,6 +282,7 @@@
pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else { return };
++ let uid = st.uid;
let doc = st.doc.clone();
let editing_parents = st.editing_parents;
let aspect = (doc.settings.page_width / doc.settings.page_height.max(1.0)) as f32;
@@@ -396,160 -131,107 +416,147 @@@
// ---- Document spreads.
let cur = crate::canvas::current_page(app).unwrap_or(0);
let cur_spread = doc.page_loc(cur).map(|l| l.0);
+ let followed_id = egui::Id::new("pages_panel_followed");
- 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, row_resp) = ui.allocate_exact_size(vec2(ui.available_width(), 8.0 + row_h + 22.0), Sense::hover());
- let top = row.min.y + 8.0;
- // The panel follows the page in view (InDesign scrolls to the selected page).
- if cur_spread == Some(si) && !editing_parents && ui.data(|d| d.get_temp::<usize>(followed_id)) != Some(cur) {
- row_resp.scroll_to_me(None);
- ui.data_mut(|d| d.insert_temp(followed_id, cur));
- }
- 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(), 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);
- // A section starts here: InDesign's small triangle above the page.
- if abs == 0 || doc.sections.iter().any(|s| s.start == abs) {
- let c = egui::pos2(pr.center().x, row.min.y + 4.0);
- ui.painter().add(egui::Shape::convex_polygon(
- vec![c + vec2(-4.5, -3.0), c + vec2(4.5, -3.0), c + vec2(0.0, 3.0)],
- t.icon,
- Stroke::NONE,
- ));
- }
- resp.widget_info(|| {
- egui::WidgetInfo::labeled(
- egui::WidgetType::Button,
- true,
- format!("{} {}", crate::i18n::tr(&app.ui.language, "Page"), app.session.page_label(abs)),
- )
- });
- // 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();
+ 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,
- ));
++ let key = (uid, cur);
++ if ui.data(|d| d.get_temp::<(u64, usize)>(followed_id)) != Some(key) {
++ ui.scroll_to_rect(row, None);
++ ui.data_mut(|d| d.insert_temp(followed_id, key));
++ }
+ }
- // 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(), 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);
++ if abs == 0 || doc.sections.iter().any(|s| s.start == abs) {
++ let c = egui::pos2(pr.center().x, row.min.y + 4.0);
++ ui.painter().add(egui::Shape::convex_polygon(
++ vec![c + vec2(-4.5, -3.0), c + vec2(4.5, -3.0), c + vec2(0.0, 3.0)],
++ t.icon,
++ Stroke::NONE,
++ ));
++
++ }
+ // 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;
+ }
+ }
+ 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);
++ let label = spread_label(app, &doc, first, sp.pages.len());
++ let g = ui.painter().layout_no_wrap(label.clone(), crate::theme::semibold(11.0), Color32::WHITE);
++ let c = egui::pos2(row.min.x + center, top + row_h + 11.0);
++ let br = egui::Rect::from_center_size(c, vec2(g.size().x + 7.0, 12.5));
++ if cur_spread == Some(si) && !editing_parents {
++ ui.painter().rect_filled(br, 0.0, BADGE);
++ }
++ ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
++ let lr = ui.interact(br, ui.id().with(("spread_label", si)), Sense::click());
++ lr.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &label));
++ if lr.clicked() {
++ crate::canvas::go_to_page(app, first);
+ }
}
- crate::canvas::go_to_page(app, abs);
- }
- resp.context_menu(|ui| page_menu(app, ui, &doc, abs, si));
- }
- // The spread's label under its pages: white on a blue badge when it holds the page in view.
- let label = spread_label(app, &doc, first, sp.pages.len());
- let g = ui.painter().layout_no_wrap(label.clone(), crate::theme::semibold(11.0), Color32::WHITE);
- let c = egui::pos2(row.min.x + center, top + row_h + 11.0);
- let br = egui::Rect::from_center_size(c, vec2(g.size().x.max(7.0) + 7.0, 12.5));
- if cur_spread == Some(si) && !editing_parents {
- ui.painter().rect_filled(br, 0.0, BADGE);
- }
- ui.painter().galley(c - g.size() / 2.0, g, Color32::WHITE);
- let lr = ui.interact(br, ui.id().with(("spread_label", si)), Sense::click());
- lr.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &label));
- if lr.clicked() {
- crate::canvas::go_to_page(app, first);
+ // 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(