Skip to content

Add layer on/off toggle to the .spd viewer - #141

Merged
philips merged 1 commit into
mainfrom
spd-layer-toggle-issue-138
Jul 29, 2026
Merged

Add layer on/off toggle to the .spd viewer#141
philips merged 1 commit into
mainfrom
spd-layer-toggle-issue-138

Conversation

@philips-clanker

@philips-clanker philips-clanker commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Next slice of #138, on top of philips/supernote-typescript#37 (merged, released as v0.5.3): a per-layer show/hide toggle in SupernoteAtelierView.

  • Bumps the supernote-typescript submodule to v0.5.3, which adds an optional visibleSurfaces filter to SupernoteAtelier.toCompositeImage().
  • SupernoteAtelierView now opens the .spd file once (openAtelierFile) and keeps the parsed SupernoteAtelier around, instead of the open-and-flatten-everything helper it used before. A checkbox per layer toggles that layer's surface in/out of a Set, and each toggle re-composites (compositeDataUrl) just the currently-checked surfaces — no re-parsing the sqlite database per click.
  • Layer labels come from SupernoteAtelier.layers (decoded from the ls config) when available; falls back to raw surface_N table names otherwise, same graceful-degradation the parser itself already does.
  • The toggle panel is skipped entirely for single-layer files — nothing to toggle, mirroring how SupernoteEmbed already skips its page-nav toolbar for a single-page .note.
  • SupernoteAtelierEmbed and the .spd export commands (Add .spd export commands (PNG, PDF) #140) are unaffected — they don't need toggle state, so they keep using renderAtelierCompositeDataUrl() (now refactored to share openAtelierFile/compositeDataUrl internally with the view instead of duplicating the wasm-loading boilerplate).

Still open on #138 after this: viewport/zoom, device attach/upload.

Test plan

  • npm run build succeeds
  • npm test — all 95 existing tests still pass
  • npm run lint — no new warnings/errors
  • Verified toCompositeImage(visibleSurfaces) against supernote-typescript/tests/input/real-device.spd outside the plugin (same path the toggle uses): hiding the "Reference Layer" surface leaves only the two sketch layers on a transparent background, and an empty visible set returns null — visually inspected the output
  • Not yet manually verified inside a running Obsidian vault (no automated Electron/GUI harness for this repo yet, same as prior .spd PRs)

Bumps the supernote-typescript submodule to v0.5.3, which adds a
visibleSurfaces filter to SupernoteAtelier.toCompositeImage()
(supernote-typescript#37, fixing #35).

SupernoteAtelierView now opens the .spd file once (openAtelierFile) and
keeps the parsed SupernoteAtelier around instead of always calling the
open-and-flatten-everything helper, so a checkbox toggle re-composites
just the selected layers without re-parsing the sqlite database on every
click. Layer labels come from SupernoteAtelier.layers when the `ls`
config decoded; falls back to raw surface table names otherwise. The
toggle panel is skipped for single-layer files, same "nothing to show
here" logic SupernoteEmbed already uses for single-page .note files.

SupernoteAtelierEmbed and the export commands keep using the simpler
renderAtelierCompositeDataUrl() (open + flatten everything, no toggle
state to manage) — refactored to share openAtelierFile/compositeDataUrl
with the view instead of duplicating the wasm-loading boilerplate.

One more item off #138 (viewport/zoom and device attach/upload still
open).
@philips
philips merged commit 5a0f853 into main Jul 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants