docs
Loading...
Searching...
No Matches
Builder.h

Overview

Declarative functions for constructing layout trees.

#include <AppCore/layout/Builder.h>

The panel(), row(), and column() functions return builder elements that describe panels and containers. They let you declare an entire layout hierarchy in a single expression instead of adding nodes step by step with Container::AddPanel(), Container::AddRow(), and Container::AddColumn().

This declares a toolbar above a resizable body with a sidebar and a content pane:

RefPtr<Panel> toolbar, sidebar, content;
window->BuildLayout({},
panel({ .key = "toolbar", .size = "44px", .fixed = true }, &toolbar),
row({ .key = "body", .resizable = true },
panel({ .key = "sidebar", .size = "240px" }, &sidebar),
panel({ .key = "content" }, &content)));
toolbar->view()->LoadURL("file:///toolbar.html");
ContainerSpec< Children... > row(ContainerOptions options, Children... children)
Describe a row container with child elements.
Definition Builder.h:125
PanelSpec panel(PanelOptions options={}, RefPtr< Panel > *out=nullptr)
Describe a panel in a builder expression (see Builder.h for an example).
Definition Builder.h:90

Building Layout Trees

Builder elements construct nodes through a window or an existing container:

  • Window::BuildLayout() populates the window while setting options on its root container. Pass ContainerOptions for the root container as the first argument, followed by the child elements.
  • Container::Build() appends children to an existing container. Pass the child elements directly to add them to that container.

The builder functions accept the same PanelOptions and ContainerOptions as Container::AddPanel(), Container::AddRow(), and Container::AddColumn(), and they produce the same Panel and Container nodes.

Capturing Node Handles

You can capture handles to nodes during layout construction by passing the address of a RefPtr handle to panel(), row(), or column(). When the layout is built, each function populates the target pointer with the created Panel or Container. This lets you interact with nodes immediately (such as calling Panel::view() to load content) so you don't need to look them up by key later.

Note
Window::BuildLayout() and Container::Build() append children to the existing tree. Calling either method again appends duplicate children. Call Container::RemoveAll() first if you want to rebuild from a clean slate.
See also
Window::BuildLayout(), Container::Build(), panel(), row(), column()

Classes

struct  PanelSpec
 A panel element inside a Build()/BuildLayout() expression. More...
struct  ContainerSpec< Children >
 A container element inside a Build()/BuildLayout() expression. More...

Functions

PanelSpec panel (PanelOptions options={}, RefPtr< Panel > *out=nullptr)
 Describe a panel in a builder expression (see Builder.h for an example).
template<typename... Children>
requires (LayoutBuildable<Children> && ...)
ContainerSpec< Children... > row (ContainerOptions options, Children... children)
 Describe a row container with child elements.
template<typename... Children>
requires (LayoutBuildable<Children> && ...)
ContainerSpec< Children... > row (ContainerOptions options, RefPtr< Container > *out, Children... children)
 Describe a row container, capturing the created handle in out.
template<typename... Children>
requires (LayoutBuildable<Children> && ...)
ContainerSpec< Children... > column (ContainerOptions options, Children... children)
 Describe a column container with child elements.
template<typename... Children>
requires (LayoutBuildable<Children> && ...)
ContainerSpec< Children... > column (ContainerOptions options, RefPtr< Container > *out, Children... children)
 Describe a column container, capturing the created handle in out.

Namespaces

namespace  ultralight
 Root namespace for every public Ultralight type, function, and enumeration.

Go to the source code of this file.