A window, or any part of one, can be written in XML. The XML only
builds the tree of widgets: once loaded, every element is an ordinary
widget, found with Rwidget_find and driven with the C API. Everything the XML
says can also be said from C, and the other way round.
This page lists 44 tags of the library, 194 attributes of their own, and 102 attributes every widget can take. The tables come from the library itself
(Rxml_get_attribute_info), so they are exactly what the loader understands.
Rid window = Rwindow_create_from_xml_file("editor.xml"); /* the root is <Window> */
Rid panel = Rwidget_create_from_xml(text, strlen(text)); /* any widget as the root */
Rid other = Rwindow_create_from_xml(text, strlen(text)); /* a <Window> given as text */
Rid save = Rwidget_find(window, "save"); /* Name="save" */
Rbutton_set_text(save, "Save all");
Rwidget_set_attribute(save, "Style", "Primary"); /* any attribute, as text */
A document read from a file is watched: when it is saved, the window
follows (see Files that are loaded again). A text given
from memory is not. Paths written in a document given as text are relative
to Rxml_set_base_path.
A complete small window:
<Window Title="Tool" Width="800" Height="500">
<Shortcut Keys="Ctrl+S" Action="file.save"/>
<VBox Spacing="8" Slot.Padding="12">
<Label TextSize="18">Settings</Label>
<HBox Spacing="8">
<TextInput Name="path" Placeholder="Folder..." Slot.Fill="1"/>
<Button Text="Save" Style="Primary" OnClicked="file.save"/>
</HBox>
<ListView Name="files" Slot.Fill="1"/>
</VBox>
</Window>
& < > " ') and numeric character references are understood. Files are UTF-8. There is no DTD and no namespace.< and & are written < and &: If="{Count < 3}".Text attribute: <Label>Hello</Label> is <Label Text="Hello"/>.Selected="1" or ActiveTab="2" can refer to children.R_ERROR_XML, with its line and column) and loading goes on.Source, Font, Background...) are relative to the file, and a file is loaded once and shared by every widget that names it.| Kind | Written |
|---|---|
| text | anything; a text that starts with @ is a key of the translations (section 11) |
| number | 12, 0.5, -3: always with a dot, whatever the language of the system |
| boolean | true / false, yes / no, 1 / 0 |
| color | #RGB, #RGBA, #RRGGBB, #RRGGBBAA, or transparent white black red green blue yellow orange cyan magenta gray |
| numbers | separated by commas. A margin: 8 (all sides), 8,4 (horizontal, vertical), 1,2,3,4 (left, top, right, bottom) |
| list | texts separated by |: Items="One|Two|Three" |
| choice | one of the words given in the tables |
| file path | relative to the document |
| action name | any text: file.save (see actions); {name} in a compiled file (XMLC) calls a function |
| shortcut | Ctrl+S, Ctrl+Shift+Z, F5, Alt+Enter. Modifiers Ctrl Shift Alt Super; keys: a letter, a digit, F1..F12, Space Escape Enter Tab Backspace Insert Delete Left Right Up Down PageUp PageDown Home End |
A widget has one action, the name of what its main event does. Action,
OnClicked, OnChanged, OnCommitted and OnActivated are five spellings
of it, kept for readability.
| Widget | The action fires when |
|---|---|
| Button, MenuItem | it is clicked |
| Checkbox, Slider, SpinBox, ComboBox, TabView, Expander, ColorPicker, Timeline, NodeGraph | its value changes |
| TextInput | Enter is pressed |
| ListView, TreeView, TileView | a row is activated (double click or Enter) |
static void on_save(Rid sender, const char* action, void* user_data) {
/* sender: the widget, action: "file.save" */
}
Raction_bind("file.save", on_save, NULL);
Raction_set_default_handler(on_any_action, NULL); /* everything that has no binding of its own */
Raction_fire("file.save", R_INVALID_ID); /* as if a widget had fired it */
The typed callbacks of the C API (Rbutton_set_clicked_callback,
Rtext_input_set_changed_callback for every keystroke,
Rlist_view_set_selection_changed_callback...) work beside actions and cover
the other events.
Every tag below also takes these. The slot attributes are read by the
parent: each panel uses those that make sense for it (a VBox reads
Slot.Fill and Slot.HAlign, a Grid reads Slot.Column...). The color and
metric attributes override the theme for the widget and what it contains;
with a glass theme, the alpha of a color is the strength of the tint of the
glass (Color.Control="#FF375F60" is a pink glass button).
| Attribute | Value | Meaning |
|---|---|---|
Name | text | Name of the widget, for Rwidget_find. |
Width | number | Fixed width; a negative value lets the content decide. |
Height | number | Fixed height; a negative value lets the content decide. |
MinWidth | number | The width never goes below this. |
MinHeight | number | The height never goes below this. |
MaxWidth | number | The width never goes above this. |
MaxHeight | number | The height never goes above this. |
Visibility | Visible | Hidden | Collapsed | Hidden keeps the place of the widget, Collapsed gives it back. |
Enabled | boolean | A disabled widget is dimmed and does not react. |
Opacity | number | From 0 (invisible) to 1. |
Material | Default | Solid | Glass | FrostedGlass | TintedGlass | What the surface of the widget is made of; Default follows the theme. |
Tooltip | text | Text shown when the pointer rests on the widget. |
Cursor | Arrow | IBeam | Hand | Crosshair | ResizeH | ResizeV | ResizeNWSE | ResizeNESW | Move | NotAllowed | None | Pointer shown over the widget. |
Appear | None | Fade | Pop | Zoom | FlyUp | FlyDown | FlyLeft | FlyRight | Drop | SlideLeft | SlideRight | How the widget comes in when it is first shown. |
AppearDelay | number | Seconds before the widget comes in. |
Action | action name | Name of the action the widget fires. |
HitTestable | boolean | false lets the pointer through to what is behind. |
Focusable | boolean | Can take the keyboard. |
Clip | boolean | Cuts what is inside at the bounds of the widget. |
WindowDrag | boolean | Dragging the widget moves the window (custom header). |
Class | text | Style classes of the widget, separated by spaces: the styles of the theme that name one of them apply. |
Theme | Default | Dark | Light | GlassDark | GlassLight | HighContrastDark | HighContrastLight | Theme of the widget and of what it contains: a name, or a theme file; Default follows what is around. |
Direction | Inherit | LTR | RTL | Right to left: the children placed as in a mirror, the texts aligned on the right (raven_layout.h). |
AccessibleName | text | What a screen reader says of the widget (its text by default). |
AccessibleDescription | text | A longer explanation, read after the name. |
AccessibleRole | Auto | None | Group | Text | Heading | Link | Button | ToggleButton | CheckBox | RadioButton | Slider | ProgressBar | SpinButton | TextField | Document | ComboBox | List | ListItem | Tree | TreeItem | Table | MenuBar | Menu | MenuItem | TabList | Tab | TabPanel | Toolbar | StatusBar | Dialog | Alert | Image | Canvas | Separator | ScrollBar | Pane | What the widget is for a screen reader. |
AccessibleHidden | boolean | Hidden from screen readers, with what it contains (decoration). |
| Attribute | Value | Meaning |
|---|---|---|
Slot.Fill | number | Share of the free space of the panel the widget takes; 0 keeps its own size. |
Slot.Padding | numbers, comma separated | Space around the widget: one number, "x,y" or "left,top,right,bottom". |
Slot.HAlign | Fill | Left | Center | Right | Where the widget sits across its place. |
Slot.VAlign | Fill | Top | Center | Bottom | Where the widget sits down its place. |
Slot.Auto | boolean | Takes its own size (the opposite of Slot.Fill). |
Slot.MaxSize | number | The most a filling widget takes along the panel. |
Slot.Column | number | Grid: column, from 0. |
Slot.Row | number | Grid: row, from 0. |
Slot.ColumnSpan | number | Grid: number of columns taken. |
Slot.RowSpan | number | Grid: number of rows taken. |
Slot.Anchors | numbers, comma separated | Canvas: "x,y" or "minx,miny,maxx,maxy", from 0 to 1 across the canvas. |
Slot.Position | numbers, comma separated | Canvas: "x,y" from the anchor. |
Slot.Size | numbers, comma separated | Canvas: "width,height". |
Slot.Alignment | numbers, comma separated | Canvas: "x,y", the point of the widget placed at the position, from 0 to 1. |
Slot.Title | text | Title of the tab or of the docked panel that holds the widget. |
Slot.Dock | Left | Right | Top | Bottom | Tab | DockArea: the side of the area, or of Slot.DockTo, the panel takes. |
Slot.DockTo | text | DockArea: name of the panel the panel is placed against. |
Slot.DockSize | number | DockArea: share of the place it is cut from, between 0 and 1. |
Slot.Closable | boolean | DockArea: the tab has a close button. |
Color.<Role>| Attribute | Value | Meaning |
|---|---|---|
Color.Window | color | |
Color.Panel | color | |
Color.Border | color | |
Color.Text | color | |
Color.TextDisabled | color | |
Color.TextPlaceholder | color | |
Color.Accent | color | |
Color.AccentHovered | color | |
Color.AccentPressed | color | |
Color.AccentText | color | |
Color.Control | color | |
Color.ControlHovered | color | |
Color.ControlPressed | color | |
Color.ControlBorder | color | |
Color.Input | color | |
Color.Focus | color | |
Color.Selection | color | |
Color.RowHovered | color | |
Color.Track | color | |
Color.Handle | color | |
Color.HandleHovered | color | |
Color.Separator | color | |
Color.Header | color | |
Color.HeaderHovered | color | |
Color.TabActive | color | |
Color.Popup | color | |
Color.PopupBorder | color | |
Color.Shadow | color | |
Color.Tooltip | color | |
Color.TooltipText | color | |
Color.Switch | color | |
Color.Success | color | |
Color.Warning | color | |
Color.Danger | color | |
Color.Link | color | |
Color.Code | color |
Metric.<Name>| Attribute | Value | Meaning |
|---|---|---|
Metric.FontSize | number | |
Metric.CornerRadius | number | |
Metric.BorderWidth | number | |
Metric.ControlHeight | number | |
Metric.PaddingX | number | |
Metric.PaddingY | number | |
Metric.Spacing | number | |
Metric.ScrollbarSize | number | |
Metric.RowHeight | number | |
Metric.Indent | number | |
Metric.SplitterSize | number | |
Metric.CheckSize | number | |
Metric.SliderHandleSize | number | |
Metric.PopupRadius | number | |
Metric.GlassFrost | number | |
Metric.GlassRefraction | number | |
Metric.GlassSaturation | number | |
Metric.GlassRim | number | |
Metric.GlassShadow | number | |
Metric.BlurRadius | number |
| Slot attribute | Read by |
|---|---|
Slot.Padding | every panel, and the window for its content |
Slot.HAlign | VBox, Grid, Overlay, Border, SizeBox, ScrollBox, Switcher, window content |
Slot.VAlign | HBox, Grid, Overlay, Border, SizeBox, ScrollBox, Switcher, window content |
Slot.Fill, Slot.Auto, Slot.MaxSize | VBox, HBox (Slot.Fill: also the panes of a Splitter) |
Slot.Column, Slot.Row, Slot.ColumnSpan, Slot.RowSpan | Grid, UniformGrid |
Slot.Anchors, Slot.Position, Slot.Size, Slot.Alignment | Canvas |
Slot.Title | TabView, DockArea |
Slot.Dock, Slot.DockTo, Slot.DockSize, Slot.Closable | DockArea |
<Window> is only a root, read by Rwindow_create_from_xml_file
and Rwindow_create_from_xml. It holds one widget, its content; optionally an
<Island> that floats at its top; any number of <Shortcut> and
<Widget> declarations.
<Window Title="Tool" Width="1100" Height="720" CustomHeader="true" Theme="GlassDark">
<Shortcut Keys="Ctrl+S" Action="file.save"/>
<Island>
<Label Text="Ready"/> <!-- folded -->
<VBox Spacing="6" Slot.Padding="12"> <!-- unfolded -->
<Label Text="Build finished"/>
<Button Text="Run" OnClicked="run"/>
</VBox>
</Island>
<VBox>
<HeaderBar>
<MenuBar>
<Menu Text="File">
<MenuItem Text="Open..." Shortcut="Ctrl+O" OnClicked="file.open"/>
<Separator/>
<MenuItem Text="Quit" Shortcut="Ctrl+Q" OnClicked="app.quit"/>
</Menu>
</MenuBar>
<Button Text="Run" Style="Primary" Slot.HAlign="Right" OnClicked="run"/>
</HeaderBar>
<DockArea Slot.Fill="1">
<TextEditor Name="code" Slot.Title="main.c" Language="C" LineNumbers="true"/>
<TreeView Name="files" Slot.Title="Files" Slot.Dock="Left" Slot.DockSize="0.22"/>
<TextEditor Name="log" Slot.Title="Output" Slot.Dock="Bottom" Slot.DockSize="0.3" ReadOnly="true"/>
</DockArea>
</VBox>
</Window>
A MenuItem with a Shortcut works without a <Shortcut>
element: the window looks in its menus when keys are pressed. In a window
with CustomHeader, the HeaderBar draws the title and the window buttons;
dragging it moves the window, and any widget with WindowDrag="true" does
the same.
A window; it contains one element, and optionally an Island and Shortcut elements.
| Attribute | Value | Meaning |
|---|---|---|
Title | text | Title of the window. |
Width | number | Width of the content, in logical units. |
Height | number | Height of the content. |
MinWidth | number | The user cannot make the window narrower. |
MinHeight | number | The user cannot make the window shorter. |
Resizable | boolean | false fixes the size. |
CustomHeader | boolean | No title bar from the system: a HeaderBar of the interface replaces it. |
Borderless | boolean | No frame at all. |
Maximized | boolean | Starts maximized. |
Hidden | boolean | Starts hidden, until Rwindow_show. |
ClearColor | color | Color behind the content. |
Background | file path | Image behind the content (what glass refracts). |
Transparent | boolean | The window can be seen through where nothing is drawn (needs a compositing window system). |
Backdrop | None | Transparent | Blur | Acrylic | Mica | What the system shows behind a window that is seen through: the desktop as it is, blurred, or a material of Windows 11. |
Theme | Dark | Light | GlassDark | GlassLight | HighContrastDark | HighContrastLight | Theme of the window: a name, or a theme file. |
The title bar of a window with a custom header; holds any widgets. (also written TitleBar; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Title | text | Text of the bar. |
Buttons | All | None | Close | Close,Minimize | Close,Maximize | The window buttons the bar shows. |
ButtonSide | Right | Left | Where the window buttons are. |
TitleAlign | Center | Left | Where the title is. |
Background | boolean | false leaves the bar without a surface, over what is behind. |
Panels the user arranges by dragging their tabs. (any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Movable | boolean | false keeps the panels where they are. |
Layout | text | An arrangement saved with Rdock_area_save_layout. |
CloseHides | boolean | The close button of a tab hides its panel (Rdock_area_open_panel brings it back) instead of deleting it. |
Tearable | boolean | false: a tab dragged out of the area does not take its panel to a window of its own. |
A pill at the top of the window that unfolds: first child folded, second unfolded. (also written Notch, DynamicIsland; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Expanded | boolean | Unfolded. |
ExpandOnHover | boolean | Unfolds while the pointer is over it. |
ExpandOnClick | boolean | A click unfolds it and folds it back. |
Attached | boolean | Hangs from the top edge, like a notch, instead of floating below it. |
A bar of Menu elements. (any number of child widgets)
No attribute of its own: those of every widget and of its slot.
A menu: MenuItem, Separator and Menu elements. (any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Title | text | Text of the menu in its bar, or in the menu that holds it. |
An item of a menu. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | Text of the item. |
Shortcut | text | Keys shown beside it and that fire it: "Ctrl+S". |
Checkable | boolean | Clicking it checks and unchecks it. |
Checked | boolean | Its state. |
Separator | boolean | A line instead of an item. |
OnClicked | action name | Action fired by the item. |
Panels place their children; how each child is placed is written on the child, in its slot (slot attributes).
<Grid Columns="auto,1" Rows="auto,auto,1" Spacing="8">
<Label Text="Name"/> <TextInput Slot.Column="1"/>
<Label Text="Notes" Slot.Row="1"/>
<TextEditor Slot.Row="1" Slot.Column="1" Slot.RowSpan="2" Height="120"/>
</Grid>
<Canvas>
<!-- pinned to the bottom right corner, 16 units from it -->
<Button Text="Help" Slot.Anchors="1,1" Slot.Alignment="1,1" Slot.Position="-16,-16"/>
<!-- stretched over the whole width, 40 high -->
<Border Background="#202020" Slot.Anchors="0,0,1,0" Slot.Size="0,40"/>
</Canvas>
<Splitter MinPaneSize="120">
<TreeView Slot.Fill="1"/>
<TextEditor Slot.Fill="3"/>
</Splitter>
<Border Padding="16" CornerRadius="14" Shadow="24,0,8" Material="FrostedGlass">
<Label Text="On glass"/>
</Border>
<Border Effect="aurora" CornerRadius="18" Height="160">
<Label Text="Tonight" TextSize="24" Slot.Padding="16" Slot.VAlign="Bottom"/>
</Border>
Stacks its children from top to bottom. (also written VerticalBox; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Spacing | number | Space between the children. |
Lines its children up from left to right. (also written HorizontalBox; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Spacing | number | Space between the children. |
Places its children in rows and columns (Slot.Column, Slot.Row). (also written GridPanel; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Columns | text | Share of the width of each column: "0,1,2" (0 = the size of its content). |
Rows | text | Share of the height of each row. |
Spacing | number | Space between the cells. |
Cells of the same size, filled in order. (also written UniformGridPanel; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Columns | number | Number of columns; 0 fits as many as the width allows. |
MinCellSize | numbers, comma separated | "width,height" every cell has at least. |
Spacing | number | Space between the cells. |
Puts its children on top of each other. (any number of child widgets)
No attribute of its own: those of every widget and of its slot.
A surface with padding around one child. (one child widget)
| Attribute | Value | Meaning |
|---|---|---|
Padding | numbers, comma separated | Space between the border and its content. |
Background | color | Color of the surface. |
BorderColor | color | Color of the outline. |
BorderWidth | number | Width of the outline. |
CornerRadius | numbers, comma separated | One number, or "top-left,top-right,bottom-right,bottom-left". |
Shadow | numbers, comma separated | "blur" or "blur,x,y". |
Effect | text | An effect as its background: aurora, shimmer, neon, ripple, plasma, grain, spotlight, mesh, or a .spv file (raven_shader.h). |
EffectColor | color | First color of the effect. |
EffectColor2 | color | Second color of the effect. |
EffectParams | numbers, comma separated | The four parameters of the effect: "a,b,c,d" (fewer keep the defaults of the others). |
EffectAnimate | boolean | Draws frames while it is shown (the animated effects do by default). |
EffectPointer | boolean | The effect follows the pointer: where it is, over the border and pressing it (true by default). |
EffectBackdrop | boolean | The .spv effect reads what is behind it (R_SHADER_BACKDROP). |
Gives one child a size or a shape. (also written Box; one child widget)
| Attribute | Value | Meaning |
|---|---|---|
AspectRatio | numbers, comma separated | Width over height: "1.5" or "16,9". |
Empty space. (no child widget)
No attribute of its own: those of every widget and of its slot.
Scrolls content that is larger than its place. (any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Orientation | Horizontal | Vertical | The way the content scrolls and is stacked. |
ScrollBoth | boolean | Scrolls both ways. |
Spacing | number | Space between the children. |
Panes separated by bars the user drags. (any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Orientation | Horizontal | Vertical | Horizontal puts the panes side by side. |
MinPaneSize | number | The smallest a pane can be dragged to. |
Lines its children up and continues on the next line. (any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Spacing | number | Space between the children. |
Places its children freely (Slot.Position, Slot.Size, Slot.Anchors). (also written CanvasPanel; any number of child widgets)
No attribute of its own: those of every widget and of its slot.
Shows one of its children. (also written WidgetSwitcher; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
Index | number | Which child is shown, from 0. |
Its children as tabs (Slot.Title). (also written Tabs; any number of child widgets)
| Attribute | Value | Meaning |
|---|---|---|
ActiveTab | number | Which tab is shown, from 0. |
OnChanged | action name | Action fired when the tab changes. |
A header that shows and hides one child. (also written ExpandableArea; one child widget)
| Attribute | Value | Meaning |
|---|---|---|
Title | text | Text of the header. |
Expanded | boolean | The content is shown. |
OnChanged | action name | Action fired when it opens or closes. |
A panel that shows what is behind it out of focus, around one child. (one child widget)
| Attribute | Value | Meaning |
|---|---|---|
Style | Plain | Frosted | Glass | Native | Plain only blurs; Frosted adds a veil and grain; Glass bends light at its rim; Native shows the desktop, blurred by the system, through a window that is seen through. |
Radius | number | How far the blur spreads; 0 uses the theme. |
Tint | color | Color laid over what is blurred; its alpha is its strength. |
Saturation | number | Colors of what is behind: 1 unchanged, 0 gray, more than 1 vivid. |
Grain | number | Fine noise, from 0 to 1 (what keeps a blur from banding). |
Shadow | number | Blur of the shadow under the panel; 0 = none. |
Padding | numbers, comma separated | Space around the child. |
CornerRadius | number | Radius of the corners. |
<VBox Spacing="8">
<Label Markdown="true" Wrap="true">**Bold**, *italic* and a [link](https://example.org).</Label>
<Button Text="Delete" Class="danger" Tooltip="Deletes the file" OnClicked="file.delete"/>
<Checkbox Text="Dark mode" Style="Switch" Checked="true" OnChanged="view.dark"/>
<HBox Spacing="6">
<Checkbox Text="Small" Style="Radio"/>
<Checkbox Text="Large" Style="Radio" Checked="true"/>
</HBox>
<Slider Min="0" Max="100" Value="40" Step="5" OnChanged="volume"/>
<SpinBox Min="0" Max="10" Value="2.5" Step="0.1" Decimals="1"/>
<TextInput Name="email" Placeholder="you@example.com" OnCommitted="send"/>
<ComboBox Items="Small|Medium|Large" Selected="1"/>
<ListView Height="120">
<Item Text="First"/>
<Item Text="Second"/>
</ListView>
<TreeView Height="140">
<Item Text="src" Expanded="true">
<Item Text="main.c"/>
</Item>
</TreeView>
<Image Source="logo.png" Width="64" Height="64" Stretch="Fit"/>
<ProgressBar Value="0.6"/>
<TextEditor Language="Python" LineNumbers="true" Height="200">print("hello")</TextEditor>
</VBox>
Text. (also written Text, TextBlock; no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | The text. |
TextSize | number | Size of the text; 0 uses the theme. |
TextAlign | Left | Center | Right | Where the lines sit across the label. |
Wrap | boolean | Long lines continue on the next one. |
Color | color | Color of the text. |
Font | file path | Font file, or "monospace". |
Markdown | boolean | The text is Markdown: headings, emphasis, lists, quotes, code, tables, links. |
A button, with a text or with one child. (one child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | The text of the button. |
Style | Default | Primary | Flat | Primary is the button of the main action; Flat has no surface until hovered. |
OnClicked | action name | Action fired by a click. |
A box to check, a radio button or a switch. (also written CheckBox; no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | The text beside the box. |
Checked | boolean | Its state. |
Style | Check | Radio | Switch | What it looks like. |
OnChanged | action name | Action fired when the state changes. |
A value chosen by dragging. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Min | number | Lowest value. |
Max | number | Highest value. |
Value | number | The value. |
Step | number | The value moves by this much; 0 moves freely. |
Orientation | Horizontal | Vertical | The way the slider lies. |
OnChanged | action name | Action fired when the value changes. |
How far something is. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Value | number | How far, from 0 to 1. |
A picture. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Source | file path | Image file. |
Stretch | Fill | Fit | Cover | None | How the image fills its place. |
Tint | color | Color the image is multiplied by. |
CornerRadius | number | Rounds the corners. |
Region | numbers, comma separated | Part of the image shown: "minu,minv,maxu,maxv" from 0 to 1. |
TintText | boolean | Tinted with the color of the text around it: white icons that follow the theme. |
One line of text to type. (also written TextBox, EditableText; no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | The text. |
Placeholder | text | Shown, dimmed, while the input is empty. |
Password | boolean | Shows dots. |
ReadOnly | boolean | Can be selected and copied, not changed. |
MaxLength | number | Most characters accepted; 0 for no limit. |
OnChanged | action name | Action fired at each change. |
OnCommitted | action name | Action fired by Enter. |
A number to type or to step. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Min | number | Lowest value. |
Max | number | Highest value. |
Value | number | The value. |
Step | number | What the arrows add. |
Decimals | number | Digits shown after the point. |
OnChanged | action name | Action fired when the value changes. |
One choice in a list that drops down. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Items | texts separated by | | The choices, separated by '|'. |
Selected | number | Which one is chosen, from 0; -1 for none. |
OnChanged | action name | Action fired when the choice changes. |
A line between things. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Orientation | Horizontal | Vertical | Horizontal is a line across. |
Rows of text, one selected; any number of them. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Items | texts separated by | | The rows, separated by '|'. |
Selected | number | Which row is selected, from 0; -1 for none. |
OnChanged | action name | Action fired when the selection changes. |
OnActivated | action name | Action fired by a double click or Enter. |
Rows inside rows, made of Item elements. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
OnChanged | action name | Action fired when the selection changes. |
OnActivated | action name | Action fired by a double click or Enter. |
A grid of tiles, an icon over a name, given by the application (Rtile_view_set_items). (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
TileWidth | number | Width of a tile. |
Layout | Tiles | Rows | Tiles: a grid. Rows: one item per line, as wide as the view, the icon on the left. |
TileHeight | number | Height of a tile, name included. |
IconSize | number | Size of the icon of a tile. |
Spacing | number | Space between the tiles. |
EmptyText | text | Text shown when there is no tile. |
DragType | text | Type given to Rdrag_begin when tiles are dragged; empty: no drag. |
OnActivated | action name | Action fired by a double click or Enter. |
Text of several lines: notes, code. (also written TextArea; no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Text | text | The text. |
Language | None | C | C++ | C# | Java | JavaScript | TypeScript | Python | Rust | GLSL | JSON | CSS | XML | HTML | Colors the text and helps while typing. |
LineNumbers | boolean | Shows the line numbers in a margin. |
Wrap | boolean | Long lines continue on the next row. |
ReadOnly | boolean | Can be scrolled, selected and copied, not changed. |
Placeholder | text | Shown, dimmed, while the editor is empty. |
TabSize | number | Width of a tab, in spaces. |
TabSpaces | boolean | The Tab key writes spaces. |
Completion | boolean | Proposes words while typing. |
AutoPairs | boolean | Closes brackets and quotes, indents after them. |
TextSize | number | Size of the text; 0 uses the theme. |
Zoom | number | Zoom of the text, 1 = 100 % (0.5 .. 4): Ctrl + wheel changes it. |
Zoomable | boolean | Ctrl + wheel, Ctrl + '+' / '-' / 0 zoom the text (on by default). |
Font | file path | Font file, or "monospace". |
Markdown | boolean | The text is Markdown, styled where it is typed (the same as Language="Markdown"). |
OnChanged | action name | Action fired at each change. |
<NodeGraph Name="graph" FrameAll="true">
<Type Name="number" Color="#64D2FF"/>
<Node Name="noise" Title="Noise" X="40" Y="60" Color="#FF9F0A">
<Output Name="value" Label="Value" Type="number"/>
<Slider Value="0.4" Width="150"/>
</Node>
<Node Name="blend" Title="Blend" X="320" Y="90">
<Input Name="a" Label="A" Type="number"/>
</Node>
<Link From="noise.value" To="blend.a"/>
</NodeGraph>
<Timeline Duration="12" FrameRate="24" Height="180">
<Track Name="Camera" Color="#0A84FF">
<Clip Start="0" Length="3.5" Label="Wide shot"/>
<Key Time="6"/>
</Track>
<Marker Time="4" Label="Intro"/>
</Timeline>
<ColorPicker Color="#3B82F6" Popup="true" Swatches="#FF453A, #0A84FF, white" OnChanged="color"/>
<BlockEditor Height="320">
<Category Name="Events" Color="#FFBF00"/>
<Category Name="Control" Color="#FFAB19"/>
<Kind Name="start" Label="when started" Shape="Hat" Category="Events"/>
<Kind Name="repeat" Label="repeat %n{10}" Shape="C" Category="Control"/>
</BlockEditor>
<FileBrowser Mode="Open" Filter="*.png;*.jpg" Height="360"/>
Chooses a color: square, hues, opacity, code, numbers, swatches. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Color | color | The color. |
Previous | color | The color shown next to it, to compare. |
Alpha | boolean | Shows the opacity strip; false makes colors opaque. |
Popup | boolean | A swatch the size of a button, that opens the picker when clicked. |
Compact | boolean | Only the square, the hues and the opacity. |
Numbers | RGB | HSV | The numbers shown under the square. |
Swatches | text | Colors proposed under the picker: "#FF453A, #0A84FF, white". |
OnChanged | action name | Action fired when the user changes the color. |
A sequencer: Track elements holding Clip and Key elements, and Marker elements. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Duration | number | Length of the sequence, in seconds. |
Time | number | Where the playhead is, in seconds. |
FrameRate | number | Frames per second: times snap to frames and show as seconds:frames; 0 = none. |
Snapping | boolean | Items snap to frames, to the playhead and to each other. |
ViewStart | number | First second shown. |
ViewEnd | number | Last second shown. |
Loop | boolean | Playing starts again at the end. |
Playing | boolean | The playhead runs. |
HeaderWidth | number | Width of the names of the tracks; 0 fits the longest. |
TrackHeight | number | Height of a track. |
OnChanged | action name | Action fired when the user moves, stretches or removes something. |
Nodes linked by wires: Node elements (Input, Output, any widget), Link and Type elements. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Zoom | number | Size of the canvas: 1 = life size. |
CenterX | number | What the middle of the widget shows, across the canvas. |
CenterY | number | What the middle of the widget shows, down the canvas. |
Grid | boolean | The dots of the canvas. |
Flow | Auto | true | false | The pulses that run along the links: while the pointer is over the graph, always, or never. |
ReadOnly | boolean | The user can look, select and move the view, but not change the graph. |
FrameAll | boolean | Starts with every node in view. |
OnChanged | action name | Action fired when the user links, unlinks, moves or removes something. |
Blocks that snap into each other (Scratch): Kind elements (Name, Label, Shape, Category) and Category elements (Name, Color). (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Zoom | number | Size of the canvas: 1 = life size. |
Palette | boolean | The column of blocks to drag from, on the left. |
OnChanged | action name | Action fired when the user snaps, moves, edits or deletes blocks. |
Folders and files to choose from. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Directory | text | Folder shown first. |
Mode | Open | Save | Folder | What is being chosen. |
Filter | text | Patterns of the files shown: "*.png;*.jpg". |
FileName | text | Save: the name proposed. |
DefaultExtension | text | Save: added to a name typed without one. |
ShowHidden | boolean | Shows the hidden files. |
Multiple | boolean | Open: several files can be chosen. |
Controls | boolean | false hides the name, the filter and the buttons. |
Places | boolean | false hides the list of places. |
A place the application draws in with its own renderer. (no child widget)
| Attribute | Value | Meaning |
|---|---|---|
Stretch | Fill | Fit | Cover | None | How the picture fills its place. |
FlipY | boolean | Turns the picture upside down (some renderers draw that way). |
Realtime | boolean | Drawn again at every frame. |
Source | file path | Image shown until the application draws. |
A widget painted and measured by the application. (any number of child widgets)
No attribute of its own: those of every widget and of its slot.
| Element | Inside | Attributes |
|---|---|---|
<Shortcut> | Window, or any element | Keys (a shortcut), Action: fires the action when the keys are pressed anywhere in the window |
<Item> | ComboBox, ListView, TreeView (nested for a tree) | Text (or the text of the element), Expanded (tree) |
<Strings> | anywhere | Source: a CSV table of translations, loaded with the document |
<Track> | Timeline | Name, Color, Height, Locked, Muted; contains <Clip> and <Key> |
<Clip> | Track | Start, Length or End, Label (or the text), Color, Selected |
<Key> | Track | Time, Label, Color |
<Marker> | Timeline | Time, Label, Color: a flag on the ruler |
<Node> | NodeGraph | Name (for links and Rnode_graph_find_node), Title, X, Y, Color, Selected; contains <Input>, <Output> and any widgets, shown inside the node |
<Input>, <Output> | Node | Name, Label, Type: free text; pins of different types do not link, a pin without a type links to any |
<Link> | NodeGraph, after the nodes | From="node.output", To="node.input" |
<Type> | NodeGraph | Name, Color: the color of the pins of a type and of their links |
<Kind> | BlockEditor | Name, Label (words and slots: %n number, %s text, %b condition, %r any value, %m menu; {10} after a slot is its default; | separates the sections of a C block), Shape (Statement Hat Cap C Reporter Boolean), Category |
<Category> | BlockEditor | Name, Color |
<Theme> | a theme file | see the guide |
<Widget>, <Widgets>, <Children>, <If>, <Repeat>, <ForEach>, <Include> | anywhere | see Declaring tags |
<Window Title="@app.title">
<Strings Source="strings.csv"/>
<VBox Spacing="8" Slot.Padding="16">
<Label Text="@greeting"/>
<Button Text="@menu.file" Tooltip="@menu.file.tip"/>
</VBox>
</Window>
key,en,fr app.title,Notes,Notes greeting,Hello!,Bonjour ! menu.file,File,Fichier menu.file.tip,Open and save files,Ouvrir et enregistrer
A text that starts with @ is a key: the widget shows the text of the
language in use and follows it when the language changes
(Rlocale_set_language). @@ writes a text that starts with @. The guide
has everything about translations.
<Label Markdown="true" Wrap="true">
## Notes
Some **strong** and *emphasized* text, ~~struck~~, `code`,
a [link](https://example.org) and an [action](action:file.open).
- a list
- [x] with a box
| Key | Value |
|-----|-------|
| a | 1 |
</Label>
<TextEditor Markdown="true"/>
On a Label the text is rendered: headings, strong, emphasis, struck,
code, links, lists (nested, numbered, with boxes), quotes, code blocks
(colored when they name a language of the text editor), tables, rules, line
breaks and images ( on a line of its own; the path is
relative to the document, or an https:// address loaded in the
background). The text may be indented with the document;
<![CDATA[ ... ]]> avoids escaping < and &. A link opens in
the browser of the system; action:name fires an action;
Rlabel_set_link_callback receives them all instead. On a TextEditor the
text stays as typed and is styled where it stands.
A document can declare its own tags. A <Widget> names a piece of
interface, with parameters, and is then used like any tag of the library:
<Widget Name="Field" Label="Name" Hint="" Wide="false">
<HBox Spacing="8">
<Label Text="{Label}:" Width="{Wide ? 140 : 90}"/>
<TextInput Placeholder="{Hint}" Slot.Fill="1"/>
<Children/>
</HBox>
</Widget>
<Field Label="Email" Hint="you@example.com" Name="email"/>
<Field Label="Password" Wide="true"><Button Text="Show"/></Field>
<Widget Name="Card" Title="">
<Border Class="card" Padding="14">
<VBox Spacing="6">
<Label Text="{Title}" TextSize="17" If="{!empty(Title)}"/>
<Children/>
<HBox Spacing="6"><Children Name="footer"/></HBox>
</VBox>
</Border>
</Widget>
<Card Title="Upload">
<Label Text="Drop files here"/>
<Button Text="Send" Into="footer"/>
</Card>
<Repeat Count="3" Var="i">
<Checkbox Text="Option {i + 1}"/>
</Repeat>
<ForEach Items="Red|Green|Blue" Var="c" Index="n">
<Button Text="{n}: {c}" OnClicked="color.{lower(c)}"/>
</ForEach>
<Include Source="parts/toolbar.xml"/>
<Widget> other than Name are its parameters, with their default values. It contains exactly one element: what the tag stands for.{...} is computed and replaced by its value; {{ and }} write a brace.Name, Slot.Fill, OnClicked, Material...) go to the element the tag stands for. The text inside the tag is its Text.<Children/> is replaced by the children given where the tag is used; <Children Name="footer"/> by those marked Into="footer".<Widgets> is the root of a file that only holds declarations. From C: Rxml_register_widgets, Rxml_register_widgets_from_file, Rxml_get_registered_widget_name.| Element or attribute | |
|---|---|
If="..." | on any element: kept when the value is true |
<If Test="..."> | keeps what it contains when the test is true |
<Repeat Count="3" Var="i"> | repeats what it contains; {i} is 0, 1, 2 |
<ForEach Items="a|b" Var="x" Index="n" Separator="|"> | repeats for each text of a list |
<Include Source="file.xml"/> | brings in another file: its declarations, and its element if it has one |
Expressions. Numbers, texts between single quotes, parameters and
variables; + - * / % (+ joins texts), == != < <= > >=,
&& || !, a ? b : c, parentheses; min(a, b), max(a, b), round,
floor, ceil, abs, len(text), upper, lower, empty(text),
default(value, fallback); {Instance} is a number that differs for each use
of a tag (for unique names). False is false, 0 and the empty text.
{...} is only computed inside a <Widget>, a <Repeat> or a
<ForEach>: elsewhere braces are ordinary characters.
What is created from a file (Rwindow_create_from_xml_file,
Rwidget_create_from_xml_file, the files they include, the files of
Rxml_register_widgets_from_file, the theme files, the CSV tables) is watched
while the application runs. Save the file in any editor and the interface
follows:
Name, else by content, else by position among those of the same tag; new ones are built, those that are gone are deleted;ComboBox, Timeline, NodeGraph, menus...) is built again when what is inside it changes;static void on_reload(const char* path, int ok, void* user) {
if (ok) g_status = Rwidget_find(g_window, "status"); /* widgets built again have new handles */
}
Rxml_set_reload_callback(on_reload, NULL);
Rxml_set_live_reload(R_FALSE); /* a shipped application; or RAVEN_LIVE_RELOAD=0 */
Rxml_check_files(); /* look now (else five times a second) */
static Rid make_gauge(const char* tag, void* user) {
Rid gauge = Rwidget_create(R_WIDGET_CUSTOM);
Rcustom_set_paint_callback(gauge, paint_gauge, NULL);
return gauge;
}
static int gauge_attribute(Rid widget, const char* name, const char* value, void* user) {
if (strcmp(name, "Level") != 0) return R_FALSE; /* not mine: Name, Width, Slot... are left to Raven */
set_level(widget, (float)atof(value));
return R_TRUE;
}
Rxml_register_tag("Gauge", make_gauge, gauge_attribute, NULL);
/* then, in any document: <Gauge Level="0.7" Width="120" Height="24"/> */
Rxml_resolve_path gives the path of a file named in the document being
loaded; Rwidget_set_destroy_callback tells when the widget is gone.
<WebView> of raven_web.h is such a tag, registered by
Rweb_register_xml:
<WebView Name="docs" Url="https://example.org" Slot.Fill="1" OnChanged="docs.navigated"/> <WebView Source="pages/help.html" Zoom="1.25"/> <WebView Frames="Jpeg" Quality="80"><![CDATA[<h1>Hello</h1><p>From <b>HTML</b>.</p>]]></WebView>
| WebView attribute | |
|---|---|
Url | an address |
Source | a file, relative to the document |
Html, or the text of the element | HTML |
Zoom | the size of the content |
Frames, Quality | Png or Jpeg; 1..100 |
OnChanged | fired when the address changes |
Rxml_document_parse reads a text into a tree of nodes that can be
changed, written back with its comments (Rxml_document_to_string) and
built (Rxml_document_create_widget, Rxml_document_create_window). A widget
built from a document knows its node (Rwidget_get_xml_node), and a node its
widget (Rxml_node_get_widget). Rxml_get_tag_count, Rxml_get_tag_name,
Rxml_get_attribute_count and Rxml_get_attribute_info list the tags and
their attributes: the tables of this page as data. The IDE is built on these
functions.
RXmlError error;
Rid doc = Rxml_document_parse(text, strlen(text), &error);
if (doc == R_INVALID_ID) {
printf("line %d, column %d: %s\n", error.line, error.column, error.message);
} else {
Rid root = Rxml_document_get_root(doc);
Rid button = Rxml_node_add_child(root, "Button", -1); /* at the end */
Rxml_node_set_attribute(button, "Text", "Added");
Rid preview = Rxml_document_create_widget(doc);
puts(Rxml_document_to_string(doc));
Rxml_document_destroy(doc); /* what was built lives on */
}
/* every attribute of a tag, as the loader knows it */
int i, n = Rxml_get_attribute_count("Button");
for (i = 0; i < n; i++) {
RXmlAttributeInfo info;
Rxml_get_attribute_info("Button", i, &info);
printf("%-20s %s\n", info.name, info.description);
}
A document can be written next to its code in one file (.xmlc for C,
.xmlrs for Rust, .xmlpy for Python...): ravenc turns the XML into tables
of your language, built by Rwindow_create_from_compiled, and
OnClicked="{on_save}" calls a function of the scripts. Everything on this
page works the same compiled. See XMLC in the guide.
Raven 0.1 — Apache License 2.0 — raven home · source