XML reference

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.

Contents

  1. Loading a document
  2. Rules of the syntax
  3. Kinds of values
  4. Actions
  5. Attributes every widget has — widget · slot · colors · metrics
  6. Windows and their shell — Window · HeaderBar · DockArea · Island · MenuBar · Menu · MenuItem
  7. Panels — VBox · HBox · Grid · UniformGrid · Overlay · Border · SizeBox · Spacer · ScrollBox · Splitter · WrapBox · Canvas · Switcher · TabView · Expander · BackgroundBlur
  8. Controls — Label · Button · Checkbox · Slider · ProgressBar · Image · TextInput · SpinBox · ComboBox · Separator · ListView · TreeView · TileView · TextEditor
  9. Tools — ColorPicker · Timeline · NodeGraph · BlockEditor · FileBrowser · Viewport · Custom
  10. Elements that are not widgets
  11. Translations
  12. Markdown
  13. Declaring tags
  14. Files that are loaded again
  15. Tags made by code; WebView
  16. Documents, for tools
  17. Compiled XML (XMLC)

1. Loading a document

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>

2. Rules of the syntax

3. Kinds of values

KindWritten
textanything; a text that starts with @ is a key of the translations (section 11)
number12, 0.5, -3: always with a dot, whatever the language of the system
booleantrue / false, yes / no, 1 / 0
color#RGB, #RGBA, #RRGGBB, #RRGGBBAA, or transparent white black red green blue yellow orange cyan magenta gray
numbersseparated by commas. A margin: 8 (all sides), 8,4 (horizontal, vertical), 1,2,3,4 (left, top, right, bottom)
listtexts separated by |: Items="One|Two|Three"
choiceone of the words given in the tables
file pathrelative to the document
action nameany text: file.save (see actions); {name} in a compiled file (XMLC) calls a function
shortcutCtrl+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

4. Actions

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.

WidgetThe action fires when
Button, MenuItemit is clicked
Checkbox, Slider, SpinBox, ComboBox, TabView, Expander, ColorPicker, Timeline, NodeGraphits value changes
TextInputEnter is pressed
ListView, TreeView, TileViewa 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.

5. Attributes every widget has

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).

Attributes of every widget

AttributeValueMeaning
NametextName of the widget, for Rwidget_find.
WidthnumberFixed width; a negative value lets the content decide.
HeightnumberFixed height; a negative value lets the content decide.
MinWidthnumberThe width never goes below this.
MinHeightnumberThe height never goes below this.
MaxWidthnumberThe width never goes above this.
MaxHeightnumberThe height never goes above this.
VisibilityVisible | Hidden | CollapsedHidden keeps the place of the widget, Collapsed gives it back.
EnabledbooleanA disabled widget is dimmed and does not react.
OpacitynumberFrom 0 (invisible) to 1.
MaterialDefault | Solid | Glass | FrostedGlass | TintedGlassWhat the surface of the widget is made of; Default follows the theme.
TooltiptextText shown when the pointer rests on the widget.
CursorArrow | IBeam | Hand | Crosshair | ResizeH | ResizeV | ResizeNWSE | ResizeNESW | Move | NotAllowed | NonePointer shown over the widget.
AppearNone | Fade | Pop | Zoom | FlyUp | FlyDown | FlyLeft | FlyRight | Drop | SlideLeft | SlideRightHow the widget comes in when it is first shown.
AppearDelaynumberSeconds before the widget comes in.
Actionaction nameName of the action the widget fires.
HitTestablebooleanfalse lets the pointer through to what is behind.
FocusablebooleanCan take the keyboard.
ClipbooleanCuts what is inside at the bounds of the widget.
WindowDragbooleanDragging the widget moves the window (custom header).
ClasstextStyle classes of the widget, separated by spaces: the styles of the theme that name one of them apply.
ThemeDefault | Dark | Light | GlassDark | GlassLight | HighContrastDark | HighContrastLightTheme of the widget and of what it contains: a name, or a theme file; Default follows what is around.
DirectionInherit | LTR | RTLRight to left: the children placed as in a mirror, the texts aligned on the right (raven_layout.h).
AccessibleNametextWhat a screen reader says of the widget (its text by default).
AccessibleDescriptiontextA longer explanation, read after the name.
AccessibleRoleAuto | 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 | PaneWhat the widget is for a screen reader.
AccessibleHiddenbooleanHidden from screen readers, with what it contains (decoration).

Slot attributes: the place of a widget in its parent

AttributeValueMeaning
Slot.FillnumberShare of the free space of the panel the widget takes; 0 keeps its own size.
Slot.Paddingnumbers, comma separatedSpace around the widget: one number, "x,y" or "left,top,right,bottom".
Slot.HAlignFill | Left | Center | RightWhere the widget sits across its place.
Slot.VAlignFill | Top | Center | BottomWhere the widget sits down its place.
Slot.AutobooleanTakes its own size (the opposite of Slot.Fill).
Slot.MaxSizenumberThe most a filling widget takes along the panel.
Slot.ColumnnumberGrid: column, from 0.
Slot.RownumberGrid: row, from 0.
Slot.ColumnSpannumberGrid: number of columns taken.
Slot.RowSpannumberGrid: number of rows taken.
Slot.Anchorsnumbers, comma separatedCanvas: "x,y" or "minx,miny,maxx,maxy", from 0 to 1 across the canvas.
Slot.Positionnumbers, comma separatedCanvas: "x,y" from the anchor.
Slot.Sizenumbers, comma separatedCanvas: "width,height".
Slot.Alignmentnumbers, comma separatedCanvas: "x,y", the point of the widget placed at the position, from 0 to 1.
Slot.TitletextTitle of the tab or of the docked panel that holds the widget.
Slot.DockLeft | Right | Top | Bottom | TabDockArea: the side of the area, or of Slot.DockTo, the panel takes.
Slot.DockTotextDockArea: name of the panel the panel is placed against.
Slot.DockSizenumberDockArea: share of the place it is cut from, between 0 and 1.
Slot.ClosablebooleanDockArea: the tab has a close button.

Color attributes: Color.<Role>

AttributeValueMeaning
Color.Windowcolor
Color.Panelcolor
Color.Bordercolor
Color.Textcolor
Color.TextDisabledcolor
Color.TextPlaceholdercolor
Color.Accentcolor
Color.AccentHoveredcolor
Color.AccentPressedcolor
Color.AccentTextcolor
Color.Controlcolor
Color.ControlHoveredcolor
Color.ControlPressedcolor
Color.ControlBordercolor
Color.Inputcolor
Color.Focuscolor
Color.Selectioncolor
Color.RowHoveredcolor
Color.Trackcolor
Color.Handlecolor
Color.HandleHoveredcolor
Color.Separatorcolor
Color.Headercolor
Color.HeaderHoveredcolor
Color.TabActivecolor
Color.Popupcolor
Color.PopupBordercolor
Color.Shadowcolor
Color.Tooltipcolor
Color.TooltipTextcolor
Color.Switchcolor
Color.Successcolor
Color.Warningcolor
Color.Dangercolor
Color.Linkcolor
Color.Codecolor

Metric attributes: Metric.<Name>

AttributeValueMeaning
Metric.FontSizenumber
Metric.CornerRadiusnumber
Metric.BorderWidthnumber
Metric.ControlHeightnumber
Metric.PaddingXnumber
Metric.PaddingYnumber
Metric.Spacingnumber
Metric.ScrollbarSizenumber
Metric.RowHeightnumber
Metric.Indentnumber
Metric.SplitterSizenumber
Metric.CheckSizenumber
Metric.SliderHandleSizenumber
Metric.PopupRadiusnumber
Metric.GlassFrostnumber
Metric.GlassRefractionnumber
Metric.GlassSaturationnumber
Metric.GlassRimnumber
Metric.GlassShadownumber
Metric.BlurRadiusnumber

Which panel reads which slot attribute

Slot attributeRead by
Slot.Paddingevery panel, and the window for its content
Slot.HAlignVBox, Grid, Overlay, Border, SizeBox, ScrollBox, Switcher, window content
Slot.VAlignHBox, Grid, Overlay, Border, SizeBox, ScrollBox, Switcher, window content
Slot.Fill, Slot.Auto, Slot.MaxSizeVBox, HBox (Slot.Fill: also the panes of a Splitter)
Slot.Column, Slot.Row, Slot.ColumnSpan, Slot.RowSpanGrid, UniformGrid
Slot.Anchors, Slot.Position, Slot.Size, Slot.AlignmentCanvas
Slot.TitleTabView, DockArea
Slot.Dock, Slot.DockTo, Slot.DockSize, Slot.ClosableDockArea

6. Windows and their shell

<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.

<Window>

A window; it contains one element, and optionally an Island and Shortcut elements.

AttributeValueMeaning
TitletextTitle of the window.
WidthnumberWidth of the content, in logical units.
HeightnumberHeight of the content.
MinWidthnumberThe user cannot make the window narrower.
MinHeightnumberThe user cannot make the window shorter.
Resizablebooleanfalse fixes the size.
CustomHeaderbooleanNo title bar from the system: a HeaderBar of the interface replaces it.
BorderlessbooleanNo frame at all.
MaximizedbooleanStarts maximized.
HiddenbooleanStarts hidden, until Rwindow_show.
ClearColorcolorColor behind the content.
Backgroundfile pathImage behind the content (what glass refracts).
TransparentbooleanThe window can be seen through where nothing is drawn (needs a compositing window system).
BackdropNone | Transparent | Blur | Acrylic | MicaWhat the system shows behind a window that is seen through: the desktop as it is, blurred, or a material of Windows 11.
ThemeDark | Light | GlassDark | GlassLight | HighContrastDark | HighContrastLightTheme of the window: a name, or a theme file.

<HeaderBar>

The title bar of a window with a custom header; holds any widgets. (also written TitleBar; any number of child widgets)

AttributeValueMeaning
TitletextText of the bar.
ButtonsAll | None | Close | Close,Minimize | Close,MaximizeThe window buttons the bar shows.
ButtonSideRight | LeftWhere the window buttons are.
TitleAlignCenter | LeftWhere the title is.
Backgroundbooleanfalse leaves the bar without a surface, over what is behind.

<DockArea>

Panels the user arranges by dragging their tabs. (any number of child widgets)

AttributeValueMeaning
Movablebooleanfalse keeps the panels where they are.
LayouttextAn arrangement saved with Rdock_area_save_layout.
CloseHidesbooleanThe close button of a tab hides its panel (Rdock_area_open_panel brings it back) instead of deleting it.
Tearablebooleanfalse: a tab dragged out of the area does not take its panel to a window of its own.

<Island>

A pill at the top of the window that unfolds: first child folded, second unfolded. (also written Notch, DynamicIsland; any number of child widgets)

AttributeValueMeaning
ExpandedbooleanUnfolded.
ExpandOnHoverbooleanUnfolds while the pointer is over it.
ExpandOnClickbooleanA click unfolds it and folds it back.
AttachedbooleanHangs from the top edge, like a notch, instead of floating below it.

<MenuBar>

A bar of Menu elements. (any number of child widgets)

No attribute of its own: those of every widget and of its slot.

<Menu>

A menu: MenuItem, Separator and Menu elements. (any number of child widgets)

AttributeValueMeaning
TitletextText of the menu in its bar, or in the menu that holds it.

<MenuItem>

An item of a menu. (no child widget)

AttributeValueMeaning
TexttextText of the item.
ShortcuttextKeys shown beside it and that fire it: "Ctrl+S".
CheckablebooleanClicking it checks and unchecks it.
CheckedbooleanIts state.
SeparatorbooleanA line instead of an item.
OnClickedaction nameAction fired by the item.

7. Panels

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>

<VBox>

Stacks its children from top to bottom. (also written VerticalBox; any number of child widgets)

AttributeValueMeaning
SpacingnumberSpace between the children.

<HBox>

Lines its children up from left to right. (also written HorizontalBox; any number of child widgets)

AttributeValueMeaning
SpacingnumberSpace between the children.

<Grid>

Places its children in rows and columns (Slot.Column, Slot.Row). (also written GridPanel; any number of child widgets)

AttributeValueMeaning
ColumnstextShare of the width of each column: "0,1,2" (0 = the size of its content).
RowstextShare of the height of each row.
SpacingnumberSpace between the cells.

<UniformGrid>

Cells of the same size, filled in order. (also written UniformGridPanel; any number of child widgets)

AttributeValueMeaning
ColumnsnumberNumber of columns; 0 fits as many as the width allows.
MinCellSizenumbers, comma separated"width,height" every cell has at least.
SpacingnumberSpace between the cells.

<Overlay>

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.

<Border>

A surface with padding around one child. (one child widget)

AttributeValueMeaning
Paddingnumbers, comma separatedSpace between the border and its content.
BackgroundcolorColor of the surface.
BorderColorcolorColor of the outline.
BorderWidthnumberWidth of the outline.
CornerRadiusnumbers, comma separatedOne number, or "top-left,top-right,bottom-right,bottom-left".
Shadownumbers, comma separated"blur" or "blur,x,y".
EffecttextAn effect as its background: aurora, shimmer, neon, ripple, plasma, grain, spotlight, mesh, or a .spv file (raven_shader.h).
EffectColorcolorFirst color of the effect.
EffectColor2colorSecond color of the effect.
EffectParamsnumbers, comma separatedThe four parameters of the effect: "a,b,c,d" (fewer keep the defaults of the others).
EffectAnimatebooleanDraws frames while it is shown (the animated effects do by default).
EffectPointerbooleanThe effect follows the pointer: where it is, over the border and pressing it (true by default).
EffectBackdropbooleanThe .spv effect reads what is behind it (R_SHADER_BACKDROP).

<SizeBox>

Gives one child a size or a shape. (also written Box; one child widget)

AttributeValueMeaning
AspectRationumbers, comma separatedWidth over height: "1.5" or "16,9".

<Spacer>

Empty space. (no child widget)

No attribute of its own: those of every widget and of its slot.

<ScrollBox>

Scrolls content that is larger than its place. (any number of child widgets)

AttributeValueMeaning
OrientationHorizontal | VerticalThe way the content scrolls and is stacked.
ScrollBothbooleanScrolls both ways.
SpacingnumberSpace between the children.

<Splitter>

Panes separated by bars the user drags. (any number of child widgets)

AttributeValueMeaning
OrientationHorizontal | VerticalHorizontal puts the panes side by side.
MinPaneSizenumberThe smallest a pane can be dragged to.

<WrapBox>

Lines its children up and continues on the next line. (any number of child widgets)

AttributeValueMeaning
SpacingnumberSpace between the children.

<Canvas>

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.

<Switcher>

Shows one of its children. (also written WidgetSwitcher; any number of child widgets)

AttributeValueMeaning
IndexnumberWhich child is shown, from 0.

<TabView>

Its children as tabs (Slot.Title). (also written Tabs; any number of child widgets)

AttributeValueMeaning
ActiveTabnumberWhich tab is shown, from 0.
OnChangedaction nameAction fired when the tab changes.

<Expander>

A header that shows and hides one child. (also written ExpandableArea; one child widget)

AttributeValueMeaning
TitletextText of the header.
ExpandedbooleanThe content is shown.
OnChangedaction nameAction fired when it opens or closes.

<BackgroundBlur>

A panel that shows what is behind it out of focus, around one child. (one child widget)

AttributeValueMeaning
StylePlain | Frosted | Glass | NativePlain 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.
RadiusnumberHow far the blur spreads; 0 uses the theme.
TintcolorColor laid over what is blurred; its alpha is its strength.
SaturationnumberColors of what is behind: 1 unchanged, 0 gray, more than 1 vivid.
GrainnumberFine noise, from 0 to 1 (what keeps a blur from banding).
ShadownumberBlur of the shadow under the panel; 0 = none.
Paddingnumbers, comma separatedSpace around the child.
CornerRadiusnumberRadius of the corners.

8. Controls

<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>

<Label>

Text. (also written Text, TextBlock; no child widget)

AttributeValueMeaning
TexttextThe text.
TextSizenumberSize of the text; 0 uses the theme.
TextAlignLeft | Center | RightWhere the lines sit across the label.
WrapbooleanLong lines continue on the next one.
ColorcolorColor of the text.
Fontfile pathFont file, or "monospace".
MarkdownbooleanThe text is Markdown: headings, emphasis, lists, quotes, code, tables, links.

<Button>

A button, with a text or with one child. (one child widget)

AttributeValueMeaning
TexttextThe text of the button.
StyleDefault | Primary | FlatPrimary is the button of the main action; Flat has no surface until hovered.
OnClickedaction nameAction fired by a click.

<Checkbox>

A box to check, a radio button or a switch. (also written CheckBox; no child widget)

AttributeValueMeaning
TexttextThe text beside the box.
CheckedbooleanIts state.
StyleCheck | Radio | SwitchWhat it looks like.
OnChangedaction nameAction fired when the state changes.

<Slider>

A value chosen by dragging. (no child widget)

AttributeValueMeaning
MinnumberLowest value.
MaxnumberHighest value.
ValuenumberThe value.
StepnumberThe value moves by this much; 0 moves freely.
OrientationHorizontal | VerticalThe way the slider lies.
OnChangedaction nameAction fired when the value changes.

<ProgressBar>

How far something is. (no child widget)

AttributeValueMeaning
ValuenumberHow far, from 0 to 1.

<Image>

A picture. (no child widget)

AttributeValueMeaning
Sourcefile pathImage file.
StretchFill | Fit | Cover | NoneHow the image fills its place.
TintcolorColor the image is multiplied by.
CornerRadiusnumberRounds the corners.
Regionnumbers, comma separatedPart of the image shown: "minu,minv,maxu,maxv" from 0 to 1.
TintTextbooleanTinted with the color of the text around it: white icons that follow the theme.

<TextInput>

One line of text to type. (also written TextBox, EditableText; no child widget)

AttributeValueMeaning
TexttextThe text.
PlaceholdertextShown, dimmed, while the input is empty.
PasswordbooleanShows dots.
ReadOnlybooleanCan be selected and copied, not changed.
MaxLengthnumberMost characters accepted; 0 for no limit.
OnChangedaction nameAction fired at each change.
OnCommittedaction nameAction fired by Enter.

<SpinBox>

A number to type or to step. (no child widget)

AttributeValueMeaning
MinnumberLowest value.
MaxnumberHighest value.
ValuenumberThe value.
StepnumberWhat the arrows add.
DecimalsnumberDigits shown after the point.
OnChangedaction nameAction fired when the value changes.

<ComboBox>

One choice in a list that drops down. (no child widget)

AttributeValueMeaning
Itemstexts separated by |The choices, separated by '|'.
SelectednumberWhich one is chosen, from 0; -1 for none.
OnChangedaction nameAction fired when the choice changes.

<Separator>

A line between things. (no child widget)

AttributeValueMeaning
OrientationHorizontal | VerticalHorizontal is a line across.

<ListView>

Rows of text, one selected; any number of them. (no child widget)

AttributeValueMeaning
Itemstexts separated by |The rows, separated by '|'.
SelectednumberWhich row is selected, from 0; -1 for none.
OnChangedaction nameAction fired when the selection changes.
OnActivatedaction nameAction fired by a double click or Enter.

<TreeView>

Rows inside rows, made of Item elements. (no child widget)

AttributeValueMeaning
OnChangedaction nameAction fired when the selection changes.
OnActivatedaction nameAction fired by a double click or Enter.

<TileView>

A grid of tiles, an icon over a name, given by the application (Rtile_view_set_items). (no child widget)

AttributeValueMeaning
TileWidthnumberWidth of a tile.
LayoutTiles | RowsTiles: a grid. Rows: one item per line, as wide as the view, the icon on the left.
TileHeightnumberHeight of a tile, name included.
IconSizenumberSize of the icon of a tile.
SpacingnumberSpace between the tiles.
EmptyTexttextText shown when there is no tile.
DragTypetextType given to Rdrag_begin when tiles are dragged; empty: no drag.
OnActivatedaction nameAction fired by a double click or Enter.

<TextEditor>

Text of several lines: notes, code. (also written TextArea; no child widget)

AttributeValueMeaning
TexttextThe text.
LanguageNone | C | C++ | C# | Java | JavaScript | TypeScript | Python | Rust | GLSL | JSON | CSS | XML | HTMLColors the text and helps while typing.
LineNumbersbooleanShows the line numbers in a margin.
WrapbooleanLong lines continue on the next row.
ReadOnlybooleanCan be scrolled, selected and copied, not changed.
PlaceholdertextShown, dimmed, while the editor is empty.
TabSizenumberWidth of a tab, in spaces.
TabSpacesbooleanThe Tab key writes spaces.
CompletionbooleanProposes words while typing.
AutoPairsbooleanCloses brackets and quotes, indents after them.
TextSizenumberSize of the text; 0 uses the theme.
ZoomnumberZoom of the text, 1 = 100 % (0.5 .. 4): Ctrl + wheel changes it.
ZoomablebooleanCtrl + wheel, Ctrl + '+' / '-' / 0 zoom the text (on by default).
Fontfile pathFont file, or "monospace".
MarkdownbooleanThe text is Markdown, styled where it is typed (the same as Language="Markdown").
OnChangedaction nameAction fired at each change.

9. Tools

<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"/>

<ColorPicker>

Chooses a color: square, hues, opacity, code, numbers, swatches. (no child widget)

AttributeValueMeaning
ColorcolorThe color.
PreviouscolorThe color shown next to it, to compare.
AlphabooleanShows the opacity strip; false makes colors opaque.
PopupbooleanA swatch the size of a button, that opens the picker when clicked.
CompactbooleanOnly the square, the hues and the opacity.
NumbersRGB | HSVThe numbers shown under the square.
SwatchestextColors proposed under the picker: "#FF453A, #0A84FF, white".
OnChangedaction nameAction fired when the user changes the color.

<Timeline>

A sequencer: Track elements holding Clip and Key elements, and Marker elements. (no child widget)

AttributeValueMeaning
DurationnumberLength of the sequence, in seconds.
TimenumberWhere the playhead is, in seconds.
FrameRatenumberFrames per second: times snap to frames and show as seconds:frames; 0 = none.
SnappingbooleanItems snap to frames, to the playhead and to each other.
ViewStartnumberFirst second shown.
ViewEndnumberLast second shown.
LoopbooleanPlaying starts again at the end.
PlayingbooleanThe playhead runs.
HeaderWidthnumberWidth of the names of the tracks; 0 fits the longest.
TrackHeightnumberHeight of a track.
OnChangedaction nameAction fired when the user moves, stretches or removes something.

<NodeGraph>

Nodes linked by wires: Node elements (Input, Output, any widget), Link and Type elements. (no child widget)

AttributeValueMeaning
ZoomnumberSize of the canvas: 1 = life size.
CenterXnumberWhat the middle of the widget shows, across the canvas.
CenterYnumberWhat the middle of the widget shows, down the canvas.
GridbooleanThe dots of the canvas.
FlowAuto | true | falseThe pulses that run along the links: while the pointer is over the graph, always, or never.
ReadOnlybooleanThe user can look, select and move the view, but not change the graph.
FrameAllbooleanStarts with every node in view.
OnChangedaction nameAction fired when the user links, unlinks, moves or removes something.

<BlockEditor>

Blocks that snap into each other (Scratch): Kind elements (Name, Label, Shape, Category) and Category elements (Name, Color). (no child widget)

AttributeValueMeaning
ZoomnumberSize of the canvas: 1 = life size.
PalettebooleanThe column of blocks to drag from, on the left.
OnChangedaction nameAction fired when the user snaps, moves, edits or deletes blocks.

<FileBrowser>

Folders and files to choose from. (no child widget)

AttributeValueMeaning
DirectorytextFolder shown first.
ModeOpen | Save | FolderWhat is being chosen.
FiltertextPatterns of the files shown: "*.png;*.jpg".
FileNametextSave: the name proposed.
DefaultExtensiontextSave: added to a name typed without one.
ShowHiddenbooleanShows the hidden files.
MultiplebooleanOpen: several files can be chosen.
Controlsbooleanfalse hides the name, the filter and the buttons.
Placesbooleanfalse hides the list of places.

<Viewport>

A place the application draws in with its own renderer. (no child widget)

AttributeValueMeaning
StretchFill | Fit | Cover | NoneHow the picture fills its place.
FlipYbooleanTurns the picture upside down (some renderers draw that way).
RealtimebooleanDrawn again at every frame.
Sourcefile pathImage shown until the application draws.

<Custom>

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.

10. Elements that are not widgets

ElementInsideAttributes
<Shortcut>Window, or any elementKeys (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>anywhereSource: a CSV table of translations, loaded with the document
<Track>TimelineName, Color, Height, Locked, Muted; contains <Clip> and <Key>
<Clip>TrackStart, Length or End, Label (or the text), Color, Selected
<Key>TrackTime, Label, Color
<Marker>TimelineTime, Label, Color: a flag on the ruler
<Node>NodeGraphName (for links and Rnode_graph_find_node), Title, X, Y, Color, Selected; contains <Input>, <Output> and any widgets, shown inside the node
<Input>, <Output>NodeName, Label, Type: free text; pins of different types do not link, a pin without a type links to any
<Link>NodeGraph, after the nodesFrom="node.output", To="node.input"
<Type>NodeGraphName, Color: the color of the pins of a type and of their links
<Kind>BlockEditorName, 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>BlockEditorName, Color
<Theme>a theme filesee the guide
<Widget>, <Widgets>, <Children>, <If>, <Repeat>, <ForEach>, <Include>anywheresee Declaring tags

11. Translations

<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.

12. Markdown

<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 (![description](path) 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.

13. Declaring tags

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"/>
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.

14. Files that are loaded again

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:

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) */

15. Tags made by code; WebView

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
Urlan address
Sourcea file, relative to the document
Html, or the text of the elementHTML
Zoomthe size of the content
Frames, QualityPng or Jpeg; 1..100
OnChangedfired when the address changes

16. Documents, for tools

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);
}

17. Compiled XML (XMLC)

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