Per the full-refactor plan §9 (input-independent half of P0): - engine: canonical EditorStroke (lossless InkStroke round-trip) + stroke_geometry (single getStroke outline) + revision-gated StrokeStore - render: static/live ink painters + ink_picture_cache (revision-keyed) + annotation_layer (RepaintBoundary) - persistence: DB v6 (ink, notebook_pages) + editor_repository diff-write (UPSERT changed / DELETE removed in one txn; id-set after commit) + save_scheduler - pdf_service export now FILLS the getStroke outline (R7 hairline fix) Not yet wired into the live editor (input relocation pending pen-pressure diagnostic). 28 new tests pass.
72 lines
2.0 KiB
Dart
72 lines
2.0 KiB
Dart
// lib/editor/render/annotation_layer.dart
|
|
//
|
|
// Composites the static committed-stroke layer and the live in-progress layer
|
|
// into a single widget. Wrap the page widget with this to get ink rendering.
|
|
//
|
|
// Layout:
|
|
// RepaintBoundary
|
|
// └─ Stack
|
|
// ├─ CustomPaint(StaticInkPainter) ← repaints only on revision bump
|
|
// └─ CustomPaint(LiveInkPainter) ← repaints on every pointer move
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../engine/stroke_model.dart';
|
|
import '../engine/stroke_store.dart';
|
|
import 'ink_picture_cache.dart';
|
|
import 'live_ink_painter.dart';
|
|
import 'static_ink_painter.dart';
|
|
|
|
/// A [StatelessWidget] that renders committed and live ink strokes over a
|
|
/// [pageSize]-sized area.
|
|
///
|
|
/// Place it as an overlay on top of the page content; it is fully transparent
|
|
/// where no strokes are drawn.
|
|
///
|
|
/// [hostId] identifies the ink host (e.g. page id) and is used as the cache
|
|
/// key prefix so multiple pages can share an [InkPictureCache] instance.
|
|
class AnnotationLayer extends StatelessWidget {
|
|
const AnnotationLayer({
|
|
super.key,
|
|
required this.hostId,
|
|
required this.store,
|
|
required this.liveStroke,
|
|
required this.pageSize,
|
|
required this.cache,
|
|
});
|
|
|
|
final String hostId;
|
|
final StrokeStore store;
|
|
|
|
/// The stroke currently being drawn, or null when idle.
|
|
final EditorStroke? liveStroke;
|
|
final Size pageSize;
|
|
final InkPictureCache cache;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return RepaintBoundary(
|
|
child: Stack(
|
|
children: [
|
|
CustomPaint(
|
|
size: pageSize,
|
|
painter: StaticInkPainter(
|
|
hostId: hostId,
|
|
store: store,
|
|
pageSize: pageSize,
|
|
cache: cache,
|
|
),
|
|
),
|
|
CustomPaint(
|
|
size: pageSize,
|
|
painter: LiveInkPainter(
|
|
live: liveStroke,
|
|
pageSize: pageSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|