feat(slide): rebuild PPT annotator on the pen-first canvas
All checks were successful
CI / Windows build (push) Successful in 14m34s

PPT slides now annotate with the single performant inking engine
(PenCanvas) instead of the old ink_canvas, per "all note features on the
pen-first canvas".

- PenSlideScreen: per-slide normalized strokes over each slide image,
  prev/next + slider nav, undo/redo, shared M3 palette, and the pressure
  curve / eraser size+mode / palm rejection from the shared canvas.
- slide_export: pure, tested export geometry. Because strokes are now
  normalized to the page rect, the PDF exporter maps them straight into
  each slide's draw rect — fixing the old exporter's known ink
  misalignment (it guessed live-widget size).
- Route PPT import + open -> PenSlideScreen; delete the dead old
  ppt_annotator_screen. (ink_canvas/annotation_toolbar remain for
  split_view, the last old-canvas screen.)

Tests: slide_export geometry (4). flutter analyze: 0 issues. Suite: 269/269.
This commit is contained in:
2026-06-23 10:27:09 +08:00
parent dfe5f2a477
commit ffb9e35755
5 changed files with 630 additions and 533 deletions

View File

@@ -0,0 +1,45 @@
// Proves the pen-first slide export geometry: contain-fit centering and the
// normalized->slide point mapping that replaces the old misaligned exporter.
import 'dart:ui' show Rect, Size;
import 'package:flutter_test/flutter_test.dart';
import 'package:badnote/editor/pdf/slide_export.dart';
void main() {
test('wide image is letterboxed top/bottom on a square page', () {
final r = slideDrawRect(const Size(1000, 1000), const Size(1600, 900));
// scale = min(1000/1600, 1000/900) = 0.625 -> 1000 x 562.5, centered.
expect(r.width, closeTo(1000, 1e-6));
expect(r.height, closeTo(562.5, 1e-6));
expect(r.left, closeTo(0, 1e-6));
expect(r.top, closeTo((1000 - 562.5) / 2, 1e-6));
});
test('tall image is pillarboxed left/right', () {
final r = slideDrawRect(const Size(1000, 1000), const Size(900, 1600));
expect(r.height, closeTo(1000, 1e-6));
expect(r.width, closeTo(562.5, 1e-6));
expect(r.top, closeTo(0, 1e-6));
expect(r.left, closeTo((1000 - 562.5) / 2, 1e-6));
});
test('normalized corners map to the draw rect corners', () {
final r = const Rect.fromLTWH(100, 50, 800, 600);
final tl = normToSlide(0, 0, r);
final br = normToSlide(1, 1, r);
final mid = normToSlide(0.5, 0.5, r);
expect(tl.dx, closeTo(100, 1e-9));
expect(tl.dy, closeTo(50, 1e-9));
expect(br.dx, closeTo(900, 1e-9));
expect(br.dy, closeTo(650, 1e-9));
expect(mid.dx, closeTo(500, 1e-9));
expect(mid.dy, closeTo(350, 1e-9));
});
test('stroke width scales with the draw width', () {
final r = const Rect.fromLTWH(0, 0, 800, 600);
expect(slideStrokeWidth(0.01, r), closeTo(8, 1e-9));
});
}