Add Infinite Canvas Support #1629
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements infinite canvas functionality for notes, resolving issue #88. It introduces two new concepts: Infinite Notes and Dynamic Page Expansion.
What's New
1. Infinite Notes
'inf'in the file formatinfinitePatternFactor(default 1.25), persisted as'ipf'2. Dynamic Page Expansion
When drawing in an infinite note, the canvas automatically expands as needed:
Expansion Triggers:
_hasExpandedLeft,_hasExpandedRight,_hasExpandedDown) to prevent multiple expansions during a single strokeSmart Expansion Behavior:
Visual Implementation:
AnimatedSizewithAlignment.topLeftanchor for smooth transitionsFittedBoxfor infinite pages to prevent unwanted zoom changes during expansion3. Whitespace Trimming
Before saving, infinite pages automatically trim unused space:
trimWhitespace()calculates content bounds usinggetContentBounds()4. Page Management
createPagechecksisInfinite)removeExcessPagesreturns early)Technical Details
Key Files Modified
lib/pages/editor/editor.dart- Main expansion logic, gesture handling, animationlib/data/editor/editor_core_info.dart- Persistence ofisInfiniteandinfinitePatternFactorlib/data/editor/page.dart- AddedtrimWhitespace()andgetContentBounds()methodslib/components/canvas/canvas.dart- Conditional rendering for infinite vs normal pageslib/components/canvas/canvas_gesture_detector.dart- Initial zoom handling for infinite noteslib/components/canvas/inner_canvas.dart- Pattern scaling withinfinitePatternFactorlib/components/home/new_note_button.dart- New button to create infinite notesFile Format Changes
Two new optional fields added to the
.sbn2format:'inf'(boolean) - Marks note as infinite canvas'ipf'(double) - Pattern visual scale factor for infinite notesUser Experience
Closes
Fixes #88