Add separate control panel #417
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
yarn buildto ensure that the project builds successfully.CHANGELOG.mdwith the necessary changes made in this pull request.Description
This PR replicates the PR I made on my fork of this repo, though with some changes caused by rebasing against the beta branch and removing the settings menu I had added.
The PR adds a secondary "control panel" window. This allows users to control Pattern Projector from a separate screen (like a laptop) while the main window is projected, avoiding the need to interact directly with the projected display.
Replicates most UI functions from the main window to the control panel with the exception of full screen (which had some security issues and didn't work reliably for me).
Has some two new features including:
@courtneypattison Happy to attempt to make any changes you request. Or if you'd like to take this over and make your own changes, that's also cool. I hope it might serve as inspiration for the future even if you decide this PR isn't one you want to merge.
How it works
Inter-window Communication - The control panel and main window communicate via the BroadcastChannel API. A bridge component in the main window listens for actions from the control panel, executes them using the existing transform logic, and broadcasts state updates back. This avoids duplicating any business logic.
Viewport Calculation - The preview needs to know what portion of the PDF is visible. The bridge calculates this by transforming screen corners through the inverse of the combined projection matrices, then extracting the bounding box and rotation.
Thumbnail Generation - The PDF preview is generated by rendering all stitched pages at 3x the target resolution, applying line thickening based on the line thickness setting, then scaling down with a threshold filter. The result is cached so toggling the preview doesn't trigger re-rendering.
File Transfer - Browsers block programmatic file input clicks from other windows, so the control panel reads selected files as ArrayBuffers and transfers them via the broadcast channel. The main window reconstructs the File object and loads it normally.
Other details
Testing
I've been developing on MacOS with Safari and Arc (Chromium based browser) - and it seems to work. Panning can be a bit slow - but I think the main app was already somewhat slow to pan.
As mentioned in #416 this is mostly LLM coded. I've tested manually but whilst I can code I am not familiar with typescript.
I've only got a handful of pattern pdfs to try and it could do with being tested in more. The preview needs to render from the pdf so it would be good to try other versions. I've tested single and multi-layered, and made sure to regenerate when layers are disabled.
I've not explored the stitch menu.
Related Issues
#416 and perhaps #393
TODO
Ideas for the future