Add annotation layer (laser, pen, highlighter) over slides
Draw on slides while presenting, kept as a layer fully separate from the
Marp content so the deck stays pure, portable Marp.
Presenter tools (D pen, T highlighter, E eraser, X laser, C clear, Esc
puts the tool away) with a small floating colour/tool bar shown only when
a tool is active. Strokes use coordinates normalized to the 16:9 slide so
they render identically on the laptop and the beamer; in dual-screen mode
the ink and the laser are mirrored live to the audience window.
Persistence (decoupled from the .md):
- In memory the layer is keyed by Slide.id (stable within a session).
- On disk it lives in a sidecar <name>.ink.json next to the deck and as a
separate entry inside the .ocideck package; the markdown is untouched.
- Because slide ids are regenerated on load, the sidecar anchors strokes
by order + a content fingerprint, re-attaching them after reordering and
dropping them when a slide's content changed.
- Deck.annotations carries the layer in memory but is never serialized to
markdown; deckProvider.setAnnotations keeps it out of undo/redo.
flutter analyze is clean, all tests pass (incl. new stroke/codec tests),
and the macOS debug build compiles. Drawing and live beamer sync still
need verification on real hardware.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 11:14:51 +02:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
import 'package:ocideck/models/annotation.dart';
|
|
|
|
|
import 'package:ocideck/models/slide.dart';
|
|
|
|
|
import 'package:ocideck/services/annotation_codec.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
group('InkStroke JSON', () {
|
|
|
|
|
test('round-trips tool, color, width and points', () {
|
|
|
|
|
const stroke = InkStroke(
|
|
|
|
|
tool: InkTool.highlighter,
|
|
|
|
|
color: 0xFF22C55E,
|
|
|
|
|
width: 0.022,
|
|
|
|
|
points: [Offset(0.1, 0.2), Offset(0.3, 0.45)],
|
|
|
|
|
);
|
|
|
|
|
final back = InkStroke.fromJson(stroke.toJson());
|
|
|
|
|
expect(back.tool, InkTool.highlighter);
|
|
|
|
|
expect(back.color, 0xFF22C55E);
|
|
|
|
|
expect(back.width, closeTo(0.022, 1e-9));
|
|
|
|
|
expect(back.points.length, 2);
|
|
|
|
|
expect(back.points[1].dx, closeTo(0.3, 1e-4));
|
|
|
|
|
expect(back.points[1].dy, closeTo(0.45, 1e-4));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('AnnotationCodec', () {
|
|
|
|
|
InkStroke stroke() => const InkStroke(
|
|
|
|
|
tool: InkTool.pen,
|
|
|
|
|
color: 0xFFEF4444,
|
|
|
|
|
width: 0.004,
|
|
|
|
|
points: [Offset(0.1, 0.1), Offset(0.2, 0.2)],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
test('encodes nothing when there are no strokes', () {
|
|
|
|
|
final slides = [Slide.create(SlideType.bullets)];
|
|
|
|
|
expect(AnnotationCodec.encode(slides, {}), isNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('round-trips strokes for the same deck', () {
|
|
|
|
|
final slides = [
|
|
|
|
|
Slide.create(SlideType.bullets).copyWith(title: 'A'),
|
|
|
|
|
Slide.create(SlideType.bullets).copyWith(title: 'B'),
|
|
|
|
|
];
|
|
|
|
|
final ann = {
|
|
|
|
|
slides[1].id: [stroke()],
|
|
|
|
|
};
|
|
|
|
|
final json = AnnotationCodec.encode(slides, ann)!;
|
|
|
|
|
final back = AnnotationCodec.decode(json, slides);
|
|
|
|
|
expect(back.keys, [slides[1].id]);
|
|
|
|
|
expect(back[slides[1].id]!.single.points.length, 2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('re-anchors strokes to the matching slide after reordering', () {
|
|
|
|
|
final a = Slide.create(SlideType.bullets).copyWith(title: 'A');
|
|
|
|
|
final b = Slide.create(SlideType.bullets).copyWith(title: 'B');
|
Add project docs, EUPL licence, and open-source licence check
Documentation & licensing:
- Add the EUPL-1.2 licence (LICENSE.md) and set the project licence; refresh
the README (name origin wink, updated feature list, documentation index).
- Add CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CHANGELOG, AUTHORS, and
THIRD_PARTY_NOTICES, plus docs/ (ARCHITECTURE, BUILD, USER_GUIDE, SHORTCUTS,
LICENSE_COMPLIANCE) and .github/ (CI workflow, issue/PR templates).
- Bring docs/FILE_FORMAT.md in line with current behaviour (code & chart
slides, per-slide TLP comment, annotation .ink.json sidecar, chart data/ CSVs).
Open-source compliance:
- Add tool/check_licenses.dart and a `make licenses` target (wired into
check-full and CI) that verifies every resolved dependency uses a recognised
open-source licence. A scan of all 151 packages and bundled assets found only
OSI-approved licences.
Charts (Fase 1.1):
- Replace the chart CSV textarea with an in-app editable data grid (editable
series/labels/values, add/remove row & column, read-only when linked).
- Centralize the linked-CSV directory name (`data/`) in a shared constant.
Also normalize formatting repo-wide with `dart format` and fix one
curly-braces lint, so `make check` and CI are green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 12:19:56 +02:00
|
|
|
final json = AnnotationCodec.encode(
|
|
|
|
|
[a, b],
|
|
|
|
|
{
|
|
|
|
|
a.id: [stroke()],
|
|
|
|
|
},
|
|
|
|
|
)!;
|
Add annotation layer (laser, pen, highlighter) over slides
Draw on slides while presenting, kept as a layer fully separate from the
Marp content so the deck stays pure, portable Marp.
Presenter tools (D pen, T highlighter, E eraser, X laser, C clear, Esc
puts the tool away) with a small floating colour/tool bar shown only when
a tool is active. Strokes use coordinates normalized to the 16:9 slide so
they render identically on the laptop and the beamer; in dual-screen mode
the ink and the laser are mirrored live to the audience window.
Persistence (decoupled from the .md):
- In memory the layer is keyed by Slide.id (stable within a session).
- On disk it lives in a sidecar <name>.ink.json next to the deck and as a
separate entry inside the .ocideck package; the markdown is untouched.
- Because slide ids are regenerated on load, the sidecar anchors strokes
by order + a content fingerprint, re-attaching them after reordering and
dropping them when a slide's content changed.
- Deck.annotations carries the layer in memory but is never serialized to
markdown; deckProvider.setAnnotations keeps it out of undo/redo.
flutter analyze is clean, all tests pass (incl. new stroke/codec tests),
and the macOS debug build compiles. Drawing and live beamer sync still
need verification on real hardware.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 11:14:51 +02:00
|
|
|
|
|
|
|
|
// Reload parses fresh slides with NEW ids but identical content, in a
|
|
|
|
|
// different order.
|
|
|
|
|
final a2 = Slide.create(SlideType.bullets).copyWith(title: 'A');
|
|
|
|
|
final b2 = Slide.create(SlideType.bullets).copyWith(title: 'B');
|
|
|
|
|
final back = AnnotationCodec.decode(json, [b2, a2]);
|
|
|
|
|
expect(back.containsKey(a2.id), isTrue);
|
|
|
|
|
expect(back.containsKey(b2.id), isFalse);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('drops strokes when the slide content changed', () {
|
|
|
|
|
final a = Slide.create(SlideType.bullets).copyWith(title: 'A');
|
Add project docs, EUPL licence, and open-source licence check
Documentation & licensing:
- Add the EUPL-1.2 licence (LICENSE.md) and set the project licence; refresh
the README (name origin wink, updated feature list, documentation index).
- Add CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CHANGELOG, AUTHORS, and
THIRD_PARTY_NOTICES, plus docs/ (ARCHITECTURE, BUILD, USER_GUIDE, SHORTCUTS,
LICENSE_COMPLIANCE) and .github/ (CI workflow, issue/PR templates).
- Bring docs/FILE_FORMAT.md in line with current behaviour (code & chart
slides, per-slide TLP comment, annotation .ink.json sidecar, chart data/ CSVs).
Open-source compliance:
- Add tool/check_licenses.dart and a `make licenses` target (wired into
check-full and CI) that verifies every resolved dependency uses a recognised
open-source licence. A scan of all 151 packages and bundled assets found only
OSI-approved licences.
Charts (Fase 1.1):
- Replace the chart CSV textarea with an in-app editable data grid (editable
series/labels/values, add/remove row & column, read-only when linked).
- Centralize the linked-CSV directory name (`data/`) in a shared constant.
Also normalize formatting repo-wide with `dart format` and fix one
curly-braces lint, so `make check` and CI are green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 12:19:56 +02:00
|
|
|
final json = AnnotationCodec.encode(
|
|
|
|
|
[a],
|
|
|
|
|
{
|
|
|
|
|
a.id: [stroke()],
|
|
|
|
|
},
|
|
|
|
|
)!;
|
Add annotation layer (laser, pen, highlighter) over slides
Draw on slides while presenting, kept as a layer fully separate from the
Marp content so the deck stays pure, portable Marp.
Presenter tools (D pen, T highlighter, E eraser, X laser, C clear, Esc
puts the tool away) with a small floating colour/tool bar shown only when
a tool is active. Strokes use coordinates normalized to the 16:9 slide so
they render identically on the laptop and the beamer; in dual-screen mode
the ink and the laser are mirrored live to the audience window.
Persistence (decoupled from the .md):
- In memory the layer is keyed by Slide.id (stable within a session).
- On disk it lives in a sidecar <name>.ink.json next to the deck and as a
separate entry inside the .ocideck package; the markdown is untouched.
- Because slide ids are regenerated on load, the sidecar anchors strokes
by order + a content fingerprint, re-attaching them after reordering and
dropping them when a slide's content changed.
- Deck.annotations carries the layer in memory but is never serialized to
markdown; deckProvider.setAnnotations keeps it out of undo/redo.
flutter analyze is clean, all tests pass (incl. new stroke/codec tests),
and the macOS debug build compiles. Drawing and live beamer sync still
need verification on real hardware.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 11:14:51 +02:00
|
|
|
final edited = Slide.create(
|
|
|
|
|
SlideType.bullets,
|
|
|
|
|
).copyWith(title: 'A (changed)');
|
|
|
|
|
final back = AnnotationCodec.decode(json, [edited]);
|
|
|
|
|
expect(back, isEmpty);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|