feat(tools): rnote-style toolbar core writing batch
Some checks failed
CI / Windows build (push) Has been cancelled

Replace the ad-hoc tool palette with a shared tool system
(EditorToolKind) across the PDF, note and slide editors, and add
the core writing tools.

- Multiple brushes, each remembering its OWN color (rnote-style):
  selecting a brush restores its color, changing color updates only
  that brush, and each brush button shows its current color.
- Select tool: tap-select a committed stroke, drag to move it,
  delete it — persisted and undoable.
- Shape tool: line / rectangle / ellipse / arrow, drawn with a live
  preview and committed as generated PenStrokes (shape_geometry.dart)
  so they reuse stroke rendering, erase, persistence and undo.
- Highlighter + eraser fold into the same tool system.

Text/bookmark/search+OCR/backgrounds/Windows-Ink are later batches
(TODO). Brush opacity still deferred. analyze clean, 302 tests.
This commit is contained in:
2026-06-24 20:38:18 +08:00
parent fd102b5703
commit 875dabcd89
18 changed files with 2104 additions and 62 deletions

View File

@@ -199,6 +199,52 @@ class EraserPreviewPainter extends CustomPainter {
old.pageSize != pageSize;
}
/// Paints the SELECT tool's selection: a dashed-ish bounding box around the
/// selected stroke(s) so the user sees what is selected and draggable. The box
/// is given in normalized page coords and scaled to pixels at paint time.
class SelectionOverlayPainter extends CustomPainter {
SelectionOverlayPainter({
required this.boundsNorm,
required this.pageSize,
});
/// Selection bounding box in normalized page coords (null = nothing selected).
final Rect? boundsNorm;
final Size pageSize;
@override
void paint(Canvas canvas, Size size) {
final b = boundsNorm;
if (b == null) return;
// Inflate slightly so the box doesn't clip the stroke's rendered width.
const padPx = 6.0;
final rect = Rect.fromLTRB(
b.left * pageSize.width - padPx,
b.top * pageSize.height - padPx,
b.right * pageSize.width + padPx,
b.bottom * pageSize.height + padPx,
);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(4)),
Paint()
..color = const Color(0xFF2962FF).withValues(alpha: 0.12)
..style = PaintingStyle.fill,
);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(4)),
Paint()
..color = const Color(0xFF2962FF)
..style = PaintingStyle.stroke
..strokeWidth = 1.5
..isAntiAlias = true,
);
}
@override
bool shouldRepaint(SelectionOverlayPainter old) =>
old.boundsNorm != boundsNorm || old.pageSize != pageSize;
}
/// Paints just the in-progress stroke (the live layer), kept behind its own
/// RepaintBoundary so committed strokes don't repaint on every move.
class LiveInkPainter extends CustomPainter {