feat: endless canvas grows only to the right and down (Issue #30)

The view stops 10 mm left of and above the start frame, or above and left
of content that lies further out in notebooks from 0.29/0.30, so a new
endless notebook starts at the top left like a sheet of paper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
haraldandClaude Opus 5.5 committed 2026-10-21 11:57:26 +02:00
1 parent 08a5b014e0
commit 630fe31b76
8 files changed
+96 -3

No files matched your search

+33
View File
@@ -833,6 +833,15 @@ impl Page {
page
}
/// Endless page: the view never shows anything left of or above this point – the start
/// frame or the content, whichever reaches further, with a 10 mm margin. The canvas
/// therefore only grows to the right and down (Issue #30).
pub fn endless_scroll_limit(&self) -> glam::Vec2 {
let top_left = Self::selection_aabb(&self.strokes)
.map_or(ENDLESS_HOME, |content| content.min.min(ENDLESS_HOME));
(top_left - ENDLESS_EXPORT_MARGIN).max(glam::Vec2::ZERO)
}
/// Exportausschnitt einer endlosen Seite: der Inhalt mit 10 mm Rand (leer: der
/// Startausschnitt). Die linke obere Ecke liegt auf dem Musterraster.
pub fn endless_export_bounds(&self) -> (glam::Vec2, glam::Vec2) {
@@ -2800,6 +2809,30 @@ mod tests {
assert!(endless.screen_to_page(-5000.0, -5000.0).is_some());
}
#[test]
fn test_endless_scroll_limit_includes_content_left_of_the_start() {
let mut page = Page::new(1, PageBackground::Grid5mm).with_size(ENDLESS_PAGE_SIZE);
assert_eq!(
page.endless_scroll_limit(),
ENDLESS_HOME - ENDLESS_EXPORT_MARGIN
);
// Content right of and below the start frame does not move the limit
page.add_stroke(line(1, ENDLESS_HOME + 500.0, ENDLESS_HOME + 900.0));
assert_eq!(
page.endless_scroll_limit(),
ENDLESS_HOME - ENDLESS_EXPORT_MARGIN
);
// Older notebooks may have content further up and left: it stays reachable
let from = glam::Vec2::new(30_000.0, 40_000.0);
page.add_stroke(line(2, from, ENDLESS_HOME));
let limit = page.endless_scroll_limit();
assert!(limit.cmple(from - ENDLESS_EXPORT_MARGIN).all(), "{limit:?}");
assert!(
limit.cmpgt(from - 2.0 * ENDLESS_EXPORT_MARGIN).all(),
"{limit:?}"
);
}
#[test]
fn test_endless_export_bounds_follow_content() {
let mut page = Page::new(1, PageBackground::Grid5mm).with_size(ENDLESS_PAGE_SIZE);