feat(js): add View JS object for main-view automation + screenshots#2100
Open
edumeneses wants to merge 1 commit into
Open
feat(js): add View JS object for main-view automation + screenshots#2100edumeneses wants to merge 1 commit into
edumeneses wants to merge 1 commit into
Conversation
Expose the main scenario view to JavaScript automation through a new `View` object (JsViewContext), registered on the console and script-UI engines. Enables scripting the editor for e.g. documentation captures. API (all no-op when there is no GUI, e.g. --no-gui): - grabScene/grabMainWindow/grabScreen: SVG (scene) and raster screenshots - zoom/scroll/setZoomRatio: viewport control - centerOn(process): focus the view on a given ProcessModel, resolving its on-screen item in both nodal (NodeItem) and temporal (layer) modes - goToInterval/fit/recenter: navigation - setNodal/isNodal: switch between temporal and dataflow modes SnapshotAction: extract the scene->SVG logic into a reusable, exported renderSceneToSvg() so F10 and View.grabScene() share one code path. ScenarioDocumentPresenter: add public setNodalMode()/recenter() wrappers so the view-control functionality is reachable from the JS object. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a new
ViewJavaScript object (JsViewContext) that exposes the mainscenario view to scripting — enabling automation of the editor for tasks like
generating documentation screenshots. It is a sibling of the existing
Score(EditContext) and
Utilobjects.API (all methods no-op when there is no GUI, e.g.
--no-gui)Screenshots
View.grabScene(path)— render the scenario scene to SVG (vector), reusing the F10 snapshot code pathView.grabMainWindow(path)— grab the main window (with chrome) → raster (PNG by extension)View.grabScreen(path)— grab the whole screen, all windows → rasterViewport / navigation
View.zoom(zx, zy),View.scroll(dx, dy),View.setZoomRatio(r)View.centerOn(process)— focus the view on a givenProcessModel, resolving its on-screen item in both nodal (NodeItem) and temporal (layer) modesView.goToInterval(interval),View.fit(),View.recenter()Mode
View.setNodal(bool)/View.isNodal()— switch between temporal and dataflow modeszoom/scrollare also kept onScoreas aliases (non-breaking).How
SnapshotAction: the scene→SVG logic is extracted into an exported, reusableScenario::renderSceneToSvg(scene, path, rect)so the F10 action andView.grabScene()share one code path (F10 behavior unchanged).ScenarioDocumentPresenter: adds publicsetNodalMode()/recenter()wrappers so the view-control functionality is reachable from the JS object.
Mode switching routes through the toolbar action so its checked state stays in sync.
JsViewContextreaches the document/view/presenter viaGUIAppContext().currentDocument(), aviewDelegate()cast, andIDocument::try_presenterDelegate<ScenarioDocumentPresenter>()(returns nullheadless → methods no-op). Registered as
Viewon the console and script-UI engines.Testing
View.grabScene()produced a valid 79 KB SVG,View.grabMainWindow()a 1882×2085 PNG, andView.isNodal()returned theexpected value.
🤖 Generated with Claude Code