WrenSupport

WrenSupport manages interaction between Wren and the plugin. Such an object is created/destroyed/accessed with enableWrenSupport(), disableWrenSupport(), and wrenSupport(). It is held, as all GUI globals in the UIContext.

Constructors

this
this(IUIContext uiContext)

Constructor. Use context.enableWrenSupport() instead.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

addModuleFileWatch
void addModuleFileWatch(const(char)[] moduleName, const(char)[] wrenFilePath)

Add a dynamic reloadable .wren source file. The module is reloaded and compared when reloadScriptsThatChanged() is called. Development purpose. For a release plug-in, you want to use addModuleSource instead.

addModuleSource
void addModuleSource(const(char)[] moduleName, const(char)[] moduleSource)

Add a read-only Wren module source code, to be loaded once and never changed. Release purpose. When in developement, you might prefer a reloadable file, with addModuleFileWatch.

callCreateUI
bool callCreateUI()

To call in your UI's constructor. This call the Plugin.createUI Wren method, in module "plugin".

callPluginMethod
bool callPluginMethod(const(char)* methodName)

Call Plugin.<methodName>, a static method without arguments in Wren. For advanced users only.

callReflow
bool callReflow()

To call in your UI's reflow() method. This call the Plugin.reflow Wren method, in module "plugin".

callReflowWhenScriptsChange
bool callReflowWhenScriptsChange(double dt)

Call this in your onAnimate callback. This polls script regularly and force a full redraw.

getScriptProperty
ScriptPropertyDesc* getScriptProperty(int nthClass, int nthProp)
Undocumented in source. Be warned that the author may not have intended to support it.
interpret
bool interpret(const(char)* source)

Interpret arbitrary code. For advanced users only.

interpret
bool interpret(const(char)* path, const(char)* source)

Interpret arbitrary code. For advanced users only.

registerScriptExports
void registerScriptExports()

Instantiate that with your main UI widget to register widgets classes. Foreach member variable of GUIClass with the @ScriptExport attribute, this registers a Wren class The right Wren class can then be returned by the $ operator and UI.getElementById methods.

registerUIElementClass
void registerUIElementClass()

Add a UIElement derivative class into the set of known classes in Wren, and all its parent up to UIElement It is recommended that you use @ScriptExport on your fields and registerScriptExports instead, but this can be used to register classes manually.

reloadScriptsThatChanged
bool reloadScriptsThatChanged()

Read live-reload .wren files and restart the Wren VM if they have changed. Check the registered .wren file and check if they have changed. Since it (re)starts the Wren VM, it cannot be called from Wren.

uiContext
IUIContext uiContext()
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

// Inside your UI constructor
mixin(fieldIdentifiersAreIDs!DistortGUI);
context.enableWrenSupport();
debug
    context.wrenSupport.addModuleFileWatch("plugin", `/absolute/path/to/my/plugin.wren`); // Live-reload
else
    context.wrenSupport.addModuleSource("plugin", import("plugin.wren"));                 // Final release has static scripts
context.wrenSupport.registerScriptExports!DistortGUI;
context.wrenSupport.callCreateUI();

// Inside your UI destructor
context.disableWrenSupport();

See Also

enableWrenSupport(), disableWrenSupport()

Meta