RmlUi¶
RmlUi is a user interface library
that lays out and styles documents the way a web browser does: a document is
written in RML (an HTML-like markup) and styled with RCSS (a CSS-like style
sheet), and the library handles layout, text, scrolling, forms, animations and
events. The acron.rmlui module integrates RmlUi 6 with the engine:
a document is rendered by a RmlRegion, which is an ordinary
DisplayRegion on a window or an off-screen buffer, and is driven
from Python through the element, event and data-binding classes described in
this section.
Use RmlUi when the interface is something a web page would describe well: a menu system, a settings screen, a HUD with panels and lists, an in-world terminal. DirectGUI remains the right tool for widgets that live in the scene graph and move with it.
What the integration provides¶
RmlRegion– the display region that owns an RmlUi context, keeps it sized to the region, feeds it input and renders it every frame. There is no update task to write.RmlContext– loads documents and fonts, owns the data models, answers hit tests.RmlDocumentandRmlElement– the DOM: show and hide documents, find elements, set classes, attributes, inline styles and inner RML, query geometry, build elements programmatically.RmlEvent– delivered to callbacks attached withRmlElement.add_event_listener().RmlDataModel– RmlUi’s data binding, backed by Python callables:{{ name }}expressions,data-forlists,data-ifconditions anddata-event-clickhandlers that call into your code.RmlInputHandler– a data graph node under the mouse watcher that turns the engine’s mouse and keyboard events into RmlUi input.
Documents, style sheets, fonts and images are read through the
VirtualFileSystem and resolved against the model path, like any other
asset.
Building the module¶
The module is built when makeacron is given --use-rmlui together with the
location of an RmlUi 6 build (--rmlui-incdir and --rmlui-libdir). RmlUi
must be built with RMLUI_CUSTOM_RTTI=OFF. On macOS the RmlUi shared
libraries are bundled next to the engine’s own.
The samples/rocket-console sample program shows a loading dialog on the
main window and an interactive terminal rendered into a texture on a 3D model.
The module’s own tests, under tests/rmlui, are short and exercise every
class against an off-screen window.