Skip to main content
Version: Dev (main)

Custom GUI Panels

Language:

GUI panels let you place your application's 2D interfaces into the shared 3D room: dashboards, settings pages, control surfaces. Panels are shared session state — every peer sees the same panel at the same place, live. A panel shows either web content — a page at a URI, which makes any existing web UI immediately usable in the room, or a page your app serves over the session itself (served panels) — or a video stream from a video sender. Chain one of QarGuiPanelUrlExt, QarGuiPanelServedContentExt or QarGuiPanelStreamIdExt into QarGuiPanelInit to choose a URI, served content or a stream (C#: ContentUri, ServedContent or ContentStreamId); the content type is fixed at creation. The examples on this page use web content.

The concepts (identity by common name, top-edge-midpoint pose, size + content scale, per-peer visibility) are explained in The QAROS World and Coordinate Systems.

Creating a panel (idempotent)​

Panels are identified by a stable common name; get_or_create returns the existing panel or creates it — safe to call on every app start:

:::warning Always set a display name Set both the stable ASCII common name (common_name / CommonName) and a user-facing label (display_name / DisplayName) when creating or reopening a panel. The common name supplies identity; it is not a fallback label. An empty display name is accepted, but the panel then shows no label at all. C# option constructors leave DisplayName null, so set it explicitly in the initializer even though the property is nullable. An already open object may ignore creation options, which can hide an omitted label until a clean install or reopen. :::

The display name is shown above the panel, so it must fit one line: UTF-8 with emoji, at most 64 characters (Unicode code points, not bytes), no line breaks or other control characters, and no bidirectional formatting characters (U+200E, U+200F, U+202A to U+202E, U+2066 to U+2069). A name that breaks a rule fails the call with QAR_STATUS_GUI_PANEL_DISPLAY_NAME_INVALID; it is never shortened. Rename a panel later with qar_gui_panels_change_display_name (C#: GuiPanelControl.ChangeDisplayName, Rust: GuiPanels::set_display_name).

QarGuiPanelInit init = qar_gui_panel_init_default();
init.common_name = "machine-status.myapp.example.com"; /* stable identity */
init.display_name = "Machine Status";

init.pose = qar_pose_default();
init.pose.position.y = 1.5f; /* top-edge midpoint, room space, meters */
init.pose.position.z = -1.0f;

QarGuiPanelSize size = qar_gui_panel_size_default();
size.width_meters = 0.8f;
size.height_meters = 0.5f;
init.size = size;

QarGuiPanelId panel_id;
QarResult r = qar_gui_panels_get_or_create(session, &init, &panel_id);
qar_result_log_if_error(r);

qar_gui_panels_navigate_to_uri(
session, &panel_id, "https://myapp.local/status-dashboard");
info

The C# snippets on this page are illustrative — they track the Quaternar.Qaros binding surface but are not yet compiled from a published sample project.

:::tip Choosing common names Use a DNS-style, application-scoped name (<panel>.<app>.<org>) and keep it constant across versions. The panel's ID is derived deterministically from it — restarting your app reattaches to the same panel instead of spawning duplicates. :::

  • A restart takes the panel over. get_or_create returns the panel your previous run left, ignores the creation options, and from then on your session carries it into the hub's next session like one it created. One option still counts: a served page from a bundle your session published. The panel then shows it, so after a restart under a new peer id your panel shows your new bundle, not the previous run's.
  • Call it again when the session changes. On a new session id, and after onboarding again on RE_PAIR_REQUIRED, call get_or_create again for every common name your app owns: it returns the same id and re-creates the panel when it is missing. See When the hub's session changes.

Manipulating panels​

All mutations go through the session and the panel ID:

qar_gui_panels_update_pose(session, &panel_id, &new_pose); /* move it */
qar_gui_panels_change_size(session, &panel_id, &new_size); /* resize */
qar_gui_panels_set_state(session, &panel_id, QAR_GUI_PANEL_STATE_MINIMIZED);
qar_gui_panels_navigate_to_uri(session, &panel_id, "https://...");
qar_gui_panels_close_panel(session, &panel_id); /* remove */

Panel states: VISIBLE, MINIMIZED, HIDDEN, CLOSED.

Per-peer visibility​

By default a panel is visible to everyone: an empty visibility set means every peer, never none. Removing the last peer therefore shows the panel to everyone again; to hide it, set its state. A panel meant only for some peers is best created with them in QarGuiPanelInit::visible_to_peers. An existing one is narrowed by editing the set — for example an operator-only control panel:

const QarPeerId* add[] = { &operator_peer_id };
qar_gui_panels_update_visible_to(
session, &panel_id,
add, 1, /* additions */
NULL, 0); /* removals */

Serving panel content from your app​

A served panel shows a web page your application serves over the session itself: no web server, no URL, no video. You publish a folder or a list of files once as a content bundle; every user's mixer loads the page in its own browser and fetches the files from your app over the session, so each user has their own page state, scroll and focus. The page and your app exchange JSON messages.

  • Publishing copies the files. Nothing on disk is read while serving, so a request can reach only a file the bundle lists. To change a file, publish the bundle again: its version goes up and every panel showing it reloads.
  • The content belongs to your app. Only the session that published a bundle may put it on a panel, receives the panels' messages and posts to them (QAR_STATUS_PANEL_CONTENT_NOT_PUBLISHER otherwise). Users and other apps may still move, resize, hide or close the panel.
  • Each message is stamped with the panel and the user (the target peer) it comes from. Treat it as input from that user: check it against what you expect and authorise it per user before acting on it.
  • Pages run sandboxed to their bundle: scripts, styles and assets from the bundle only, no network access. Inline scripts do not run.
  • Rules: relative /-separated paths (no .., backslash, : or %), web file types from a fixed list (html, js, mjs, css, json, svg, png, jpg, gif, webp, ico, fonts, wasm, glb, gltf, bin, audio, video), 16 MiB per file, 64 MiB and 1024 files per bundle, 64 KiB per message. Each refusal has its own QAR_STATUS_PANEL_CONTENT_* code.

In the page:

qaros.panel.onMessage(msg => render(msg)); // from your app
qaros.panel.send({ t: "call", name: "start" }); // to your app

In your app:

QarPanelContentBundleId bundle;
qar_result_log_if_error(qar_panel_content_publish_directory(
session, "ui", "C:/MyApp/panels", &bundle)); /* folder with inspector/index.html */

QarGuiPanelServedContentExt served = qar_gui_panel_served_content_ext_default();
served.bundle = bundle;
served.entry = "inspector/index.html";

QarGuiPanelInit init = qar_gui_panel_init_default();
init.header.next = &served.header;
init.common_name = "inspector.myapp.example.com";
init.display_name = "Inspector";
QarGuiPanelId panel_id;
qar_result_log_if_error(qar_gui_panels_get_or_create(session, &init, &panel_id));

/* Messages from every panel showing the bundle; reply to one panel and user. */
static void on_message(const QarPanelContentMessage* message, void* user_state)
{
/* message->json, message->panel, message->user: valid during the call only */
}
qar_panel_content_subscribe_messages(session, &bundle, on_message, NULL, token);
qar_panel_content_post_message(session, &bundle, &panel_id, NULL, "{\"t\":\"state\"}");

Change the page a panel shows with qar_gui_panels_set_served_content (C# SetServedContent, Rust GuiPanels::set_served_content), and stop serving with qar_panel_content_remove. A website or stream panel cannot become a served panel.

Observing panels​

Your app can react to panels changing — whether changed by another peer, another app, or a user grabbing the panel in the room:

  • qar_gui_panels_subscribe_updates(session, callback, state, token) — all panels,
  • qar_gui_panels_subscribe_panel_updates(session, &panel_id, callback, state, token) — one panel,
  • qar_query_gui_panels_count / qar_query_gui_panels — enumerate current panels (count-then-fetch),
  • per-panel getters: qar_gui_panel_get_display_name, _get_pose, _get_size, _get_state, _get_content_type, _get_content_uri, _get_content_served, _get_content_stream_id, _get_visible_to_peers.

Update callbacks arrive on library threads — see the callback rules.

In Rust, session.gui_panels() lists the panels (list) and subscribes to all of them or to one (subscribe, subscribe_panel), with owned snapshots: GUI Panels.

Integration patterns​

Expose your app's existing web UI. If your application already serves a web frontend (local status page, embedded HTTP server), a panel is a one-call integration: get_or_create + navigate_to_uri pointing at your server. Interaction happens directly in the room.

Drive app state from a panel. Serve the panel's page from your app and handle its messages (served panels), or host a small web page that calls back into your application (REST/WebSocket). The panel is shared, so any user in the room can press the buttons; your app sees the effect and updates its rendered content accordingly.

Attach a panel to your app volume. Panels don't parent to volumes automatically, but you can keep one docked: subscribe to your volume's pose updates and reposition the panel relative to it. Remember the differing conventions — panel pose is the midpoint of its top edge, volume pose is the center.

Compiled tutorial​

This page is backed by the compiled example gui_panel_operations.c, covering panel create, move, navigate, and subscribe: