|
Nebula
|
The RmlUi addon as a C boundary for the managed runtime (nsharp).
The C# side is Nebula.Ui in the NebulaUi assembly.
Documents and elements cross the boundary as 64 bit handles: a slot index and a generation. A handle to an element RmlUi has destroyed reads as invalid instead of pointing at freed memory, so a script can hold on to an element across frames. Check it with RmlUiElementIsValid, every other call asserts on a destroyed element.
Strings go in as UTF-8. Functions that return a string write it into a caller buffer and return the length it needs without the terminator, so the caller can retry with a larger buffer.
Event listeners and data events call back into managed code through a function pointer and an opaque user value (a GCHandle on the managed side). The release callback is called once RmlUi drops the listener, which is when the managed side frees its handle.
#include "nsharp/nsconfig.h"Go to the source code of this file.
Namespaces | |
| namespace | RmlUi |
| namespace | RmlUi::Api |
Typedefs | |
| typedef void(*) | RmlUi::Api::EventCallback(intptr_t userData, uint64_t currentElement, uint64_t targetElement) |
| called for an event, with the element the listener is on and the element the event started at | |
| typedef void(*) | RmlUi::Api::ReleaseCallback(intptr_t userData) |
| called once RmlUi drops a listener | |
Functions | |
| bool | RmlUi::Api::RmlUiLoadFontFace (const char *path, bool fallback) |
| load a font face (ttf, otf...) | |
| uint64_t | RmlUi::Api::RmlUiLoadDocument (const char *path) |
| load a document, hidden until shown, returns 0 on failure | |
| void | RmlUi::Api::RmlUiDocumentShow (uint64_t document) |
| show a document | |
| void | RmlUi::Api::RmlUiDocumentHide (uint64_t document) |
| hide a document | |
| void | RmlUi::Api::RmlUiDocumentClose (uint64_t document) |
| close a document, its elements become invalid | |
| bool | RmlUi::Api::RmlUiIsActive () |
| check if RmlUi is running. At shutdown it stops before scripts unload | |
| void | RmlUi::Api::RmlUiSetDebuggerVisible (bool visible) |
| show or hide the RmlUi debugger | |
| bool | RmlUi::Api::RmlUiElementIsValid (uint64_t element) |
| check if a handle still refers to a live element | |
| uint64_t | RmlUi::Api::RmlUiElementGetElementById (uint64_t element, const char *id) |
| find an element by id in the subtree of an element (or document), returns 0 if there is none | |
| uint64_t | RmlUi::Api::RmlUiElementGetDocument (uint64_t element) |
| get the document an element is in | |
| int | RmlUi::Api::RmlUiElementGetInnerRml (uint64_t element, char *buffer, int bufferSize) |
| get the element's inner RML | |
| void | RmlUi::Api::RmlUiElementSetInnerRml (uint64_t element, const char *rml) |
| replace the element's content with RML | |
| int | RmlUi::Api::RmlUiElementGetAttribute (uint64_t element, const char *name, char *buffer, int bufferSize) |
| get an attribute as a string | |
| void | RmlUi::Api::RmlUiElementSetAttribute (uint64_t element, const char *name, const char *value) |
| set an attribute | |
| void | RmlUi::Api::RmlUiElementRemoveAttribute (uint64_t element, const char *name) |
| remove an attribute | |
| void | RmlUi::Api::RmlUiElementSetClass (uint64_t element, const char *name, bool active) |
| set or clear a class | |
| bool | RmlUi::Api::RmlUiElementIsClassSet (uint64_t element, const char *name) |
| check for a class | |
| bool | RmlUi::Api::RmlUiElementSetProperty (uint64_t element, const char *name, const char *value) |
| set an RCSS property from its string form, returns false if it doesn't parse | |
| void | RmlUi::Api::RmlUiElementRemoveProperty (uint64_t element, const char *name) |
| remove a local RCSS property | |
| int | RmlUi::Api::RmlUiElementGetValue (uint64_t element, char *buffer, int bufferSize) |
| get the value of a form control (input, select, textarea) | |
| void | RmlUi::Api::RmlUiElementSetValue (uint64_t element, const char *value) |
| set the value of a form control | |
| bool | RmlUi::Api::RmlUiElementFocus (uint64_t element) |
| focus an element | |
| uint64_t | RmlUi::Api::RmlUiElementAddEventListener (uint64_t element, const char *event, EventCallback callback, ReleaseCallback release, intptr_t userData) |
| add a listener for an event ("click", "change", "mouseover"...) | |
| void | RmlUi::Api::RmlUiRemoveEventListener (uint64_t listenerId) |
| A listener whose element has been destroyed is already gone, removing it again does nothing. | |
| void | RmlUi::Api::RmlUiCreateDataModel (const char *model) |
| create a data model, bind its variables before loading documents that use it | |
| void | RmlUi::Api::RmlUiRemoveDataModel (const char *model) |
| remove a data model and its component bindings | |
| void | RmlUi::Api::RmlUiBindComponent (const char *model, const char *name, uint64_t entity, uint32_t component) |
| bind a component of an entity as a variable of a data model | |
| void | RmlUi::Api::RmlUiBindDataEvent (const char *model, const char *name, EventCallback callback, intptr_t userData) |
| bind a data event (data-event-click="name"), the callback gets the element the event is on | |
| void | RmlUi::Api::RmlUiDirtyVariable (const char *model, const char *name) |
| mark a data model variable dirty so views update | |
| void | RmlUi::Api::DiscardHandles () |
| drop all handles and listeners, called when RmlUi shuts down | |