The application side

Hello world

The smallest AURA program lives in examples/hello/ and builds only against aura-*:

cmake
add_executable(aura-hello main.cpp)
aura_add_ui(aura-hello FILES hello.aura)    # default context
target_link_libraries(aura-hello PRIVATE aura::ui)
cpp
#include <aura.h>
#include "aura_ui.h"	// generated from hello.aura

int main()
{
	AuraApplication app({.title = "Hello"});
	if (!app.init()) {
		return 1;
	}
	AuraBasicContext<> ctx(app);
	auto ui = views::Hello::build(app.addFrame(), ctx);
	return app.run();
}

aura-hello --render file.png draws without a window (ctest aura_hello). Without registered fonts, Text uses the default font (via fontconfig on Linux).

aura.h: AURA without namespaces

#include <aura.h> (in aura-core) provides all public classes with the Aura prefix, similar to Qt's Q: AuraApplication, AuraTextNode, AuraImage, AuraTaskRunner, AuraWebApp, AuraScriptContext, AuraRemoteController, ... Only modules that the program links against are included (__has_include). Rules:

The context

The context type (CONTEXT_TYPE) derives from aura::ui::Context (AuraContext) (aura/ui/context.h). Both modes call the same names:

Context AURA Default in Context
width, height screen.width, screen.height 0
animator animate:, enter:, exit:, spin:, Rive none: values jump
tr(id, text) tr("id", "Text") text
fontSize(px) font:, fit:, fontSize() px
image(name), svg(name) source: file(name) via Resources
file(name) source: on Rive first file in assetDirs
propertyBool/Number/String(id) props.bool/int/string("ID") false, 0, ""
themeValue(name) theme.<name> (loaded only) unknown
theme (application member) theme.<name> (compiled) –
cpp
static const aura::ui::ThemeTable<Theme> table{
	{"mainColor", &Theme::mainColor},	// color
	{"textFont", &Theme::textFont},		// font
	{"largeRadius", Theme::largeRadius},	// constant
};

New theme values go into Theme and into this table. If the table entry is missing, the loader reports “unknown theme value” and uses the compiled version. The VS Code extension gets completion names from the running preview (Host::themeValues()).

Without a custom context: aura_add_ui without CONTEXT_INCLUDE uses aura::ui::BasicContext<> (aura/ui/basic_context.h): size and animator from the Application, images from assetDirs, and a theme of the template argument's type (BasicContext<MyTheme> with themeTable).

cpp
aura::ui::BasicContext<> ctx(app);
ctx.assetDirs = {"assets"};

Data from background work

Slow operations (networking, decoding) run on an application-owned aura::TaskRunner; the result arrives on the UI thread and enters the UI through a setter. For tasks where only the latest result matters, use latest():

cpp
// _orderLookup (aura::Latest): a new request stops the old one
_tasks.latest(_orderLookup,
	// in the pool
	[url](std::stop_token stop) { return fetchHtml(url, stop); },
	// on the UI thread, latest result only
	[this](const std::string& html) { _ui->setResult(html); });

A “still loading” indicator is simply state (property bool waiting, if waiting { … }). A setter with an unchanged value does nothing, so the application does not need to compare values itself.

Runtime: timers, processes, time, devices

aura-core building blocks without graphics (also available in aura.h as AuraTimer, AuraProcess, AuraTime, …):

Observable models

A model keeps data observed in multiple places observable (aura/core/observable.h, without graphics):

cpp
// Application data and generated UI setters stay separate.
aura::List<std::string> items;
aura::Subscription changed = items.observe([&](const auto& values) {
    ui->setItems(values); // generated for: property strings items
});
items.erase(index);

What belongs in AURA and what belongs in C++

AURA C++ (application)
Structure, appearance, text, positioning, layouts Data sources and what signals do
State through properties (selected, pressed, error) Flow (workflows and sessions)
Lists through records, application images (image) Custom drawing (cropped photos) in named slots
Dialog and flyout frames as components, animations (animate, enter, loop, Ripple) Multistage transitions, video, scroll handle

Lists: application lists are records with repeat in AURA; the application supplies data and responds to signals with an index or an action:

Aligned columns without a table layout: the price list measures column headings invisibly (Text titleProbe { visible: false }) and makes each cell that width; a Row with spacing produces the columns.

Documentation source: docs/aura.md · Download Markdown

Search for topics, widgets or APIs.