Classes | |
| struct | CommandHandler |
| struct | StartScript |
| One –script argument. More... | |
Public Member Functions | |
| ApplicationPlugin (const score::GUIApplicationContext &ctx) | |
| void | on_createdDocument (score::Document &doc) override |
| on_createdDocument Will be called after either on_newDocument or on_loadedDocument was called on every plug-in. | |
| void | initialize () override |
| initialize | |
| void | afterStartup () override |
| afterStartup Called after all the documents have been created / loaded | |
| void | runStartScripts () |
| void | on_newDocument (score::Document &doc) override |
| on_newDocument Will be called only when a new, empty document is created; classes inheriting from SerializableDocumentPlugin should be instantiated and added to the document at this point. | |
| void | registerCommandHandler (const QString &name, const QJSValue &fn, QJSEngine *engine) |
engine is the one fn belongs to; the payload is built there. | |
| void | callCommandHandler (const QString &name, const QByteArray &payload) |
Public Member Functions inherited from score::GUIApplicationPlugin | |
| GUIApplicationPlugin (const score::GUIApplicationContext &presenter) | |
| virtual GUIElements | makeGUIElements () |
| makeGUIElements | |
| Document * | currentDocument () const |
| currentDocument | |
| virtual bool | handleLoading () |
| afterStartup Returns true if the start-up was handled by this plug-in. | |
| virtual void | on_initDocument (score::Document &doc) |
| on_initDocument Will be called after the document has been created, for new, load, and restore, and before anything is loaded. | |
| virtual void | on_closeDocument (score::Document &doc) |
| on_closeDocument Will be called before closing the document. | |
| virtual void | on_documentSaveAs (score::Document &doc, const QString &newFileName) |
on_documentSaveAs Called just before a document is written to newFileName, while it still knows where it used to live. | |
| virtual void | on_loadedDocument (score::Document &doc) |
| on_loadedDocument Will be called only after a document has been loaded | |
| virtual void | prepareNewDocument () |
| prepareNewDocument Will be called just before a document switch. It is possible to check if we are in the process of document switching via DocumentManager::preparingNewDocument. | |
| virtual void | on_documentChanged (score::Document *olddoc, score::Document *newdoc) |
| on_documentChanged Will be called after a document switch. If newdoc isn't null, it means that it is currently being focused by score. | |
| virtual void | on_activeWindowChanged () |
| on_activeWindowChanged Can be used to check if the focus moves out of the main window. | |
| virtual void | on_keyPressEvent (QKeyEvent &event) |
| on_keyPressEvent Called with key events in the main document view. | |
| virtual void | on_keyReleaseEvent (QKeyEvent &event) |
| on_keyPressEvent Called with key events in the main document view. | |
Static Public Member Functions | |
| static QJSValue | importModule (QQmlEngine &engine, const QString &path) |
Public Attributes | |
| QQmlEngine | m_consoleEngine |
| QQmlEngine | m_scriptProcessUIEngine |
| QQmlComponent * | m_comp {} |
| QQuickWindow * | m_window {} |
| std::atomic_bool | m_processMessages {} |
| std::thread | m_asioThread |
| ossia::net::network_context_ptr | m_asioContext |
| std::vector< StartScript > | m_start_scripts |
| bool | m_start_script_failed {} |
| QHash< QString, CommandHandler > | m_commandHandlers |
| QSet< QString > | m_reportedMissingHandlers |
Public Attributes inherited from score::GUIApplicationPlugin | |
| const GUIApplicationContext & | context |
Additional Inherited Members | |
Public Types inherited from score::GUIApplicationPlugin | |
| using | GUIElements = score::GUIElements |
Member Function Documentation
◆ afterStartup()
|
overridevirtual |
afterStartup Called after all the documents have been created / loaded
Reimplemented from score::GUIApplicationPlugin.
◆ importModule()
|
static |
Load an ES module and give it a chance to set itself up.
ES modules cannot go through QJSEngine::evaluate, which parses its input as a script: a top-level export is a syntax error there. They must be imported, which is why loading one is a function of its own.
The module's initialize() is called if it has one, and the module is left on the global object under its base name so that whatever runs next – another –script, the console, a menu action – can call into it.
Returns the module, or the error value the caller should report: either the import failing, or initialize() throwing.
◆ initialize()
|
overridevirtual |
initialize
This method will be called once every class has been loaded from every plug-in.
Reimplemented from score::GUIApplicationPlugin.
◆ on_createdDocument()
|
overridevirtual |
on_createdDocument Will be called after either on_newDocument or on_loadedDocument was called on every plug-in.
Reimplemented from score::GUIApplicationPlugin.
◆ on_newDocument()
|
overridevirtual |
on_newDocument Will be called only when a new, empty document is created; classes inheriting from SerializableDocumentPlugin should be instantiated and added to the document at this point.
Reimplemented from score::GUIApplicationPlugin.
◆ registerCommandHandler()
| void JS::ApplicationPlugin::registerCommandHandler | ( | const QString & | name, |
| const QJSValue & | fn, | ||
| QJSEngine * | engine | ||
| ) |
engine is the one fn belongs to; the payload is built there.
Handlers for JS::ScriptCommand, by name.
A script registers one with Score.registerCommandHandler() and then pushes edits against it with Score.pushCommand(); the command stores only the name and the payloads, so it stays serializable. Registering a name twice replaces the handler - reloading a script must not leave the old one behind.
Member Data Documentation
◆ m_start_scripts
| std::vector<StartScript> JS::ApplicationPlugin::m_start_scripts |
–script may be repeated; entries run in order. That is what lets a run load a module and then drive it: --script mod.mjs --script "mod.go()".
The documentation for this class was generated from the following files:
- score-plugin-js/JS/ApplicationPlugin.hpp
- score-plugin-js/JS/ApplicationPlugin.cpp
Public Member Functions inherited from