Impossible SDK

Reference

ui/tree.h

Element tree, properties, template instantiation and invalidation. Portable.

IM_FIXED_AUTO

Sentinel for an unset/Auto dimension (width or height).

ui/tree.h, line 11
#define IM_FIXED_AUTO ((im_fixed)INT32_MIN)

IM_FIXED_INF

Sentinel for an unbounded dimension (max width/height or infinite available measure size).

ui/tree.h, line 14
#define IM_FIXED_INF ((im_fixed)INT32_MAX)

im_alloc_fn im_realloc_fn im_free_fn

Caller-supplied allocator callbacks used by im_tree for all dynamic storage.

ui/tree.h, line 17
typedef void *(*im_alloc_fn)(void *ctx, size_t size);
typedef void *(*im_realloc_fn)(void *ctx, void *ptr, size_t old_size, size_t new_size);
typedef void (*im_free_fn)(void *ctx, void *ptr, size_t size);

im_allocator

Allocator table passed to im_tree_init. Every callback must be non-NULL.

ui/tree.h, line 22
typedef struct im_allocator {
    im_alloc_fn alloc;
    im_realloc_fn realloc;
    im_free_fn free;
    void *ctx;
} im_allocator;

im_size

Two-dimensional size in 16.16 fixed-point logical units.

ui/tree.h, line 30
typedef struct im_size {
    im_fixed width;
    im_fixed height;
} im_size;

im_thickness

Four-edge thickness (Margin, Padding, BorderThickness) in 16.16 fixed-point logical units.

ui/tree.h, line 36
typedef struct im_thickness {
    im_fixed left;
    im_fixed top;
    im_fixed right;
    im_fixed bottom;
} im_thickness;

im_align

Horizontal or vertical alignment of an element within its layout slot.

ui/tree.h, line 44
typedef enum im_align {
    IM_ALIGN_STRETCH = 0,
    IM_ALIGN_START,
    IM_ALIGN_CENTER,
    IM_ALIGN_END
} im_align;

im_visibility

Layout visibility (Collapsed occupies zero space and is excluded from StackPanel spacing).

ui/tree.h, line 52
typedef enum im_visibility {
    IM_VIS_VISIBLE = 0,
    IM_VIS_COLLAPSED
} im_visibility;

im_orientation

Orientation of a StackPanel.

ui/tree.h, line 58
typedef enum im_orientation {
    IM_ORIENT_VERTICAL = 0,
    IM_ORIENT_HORIZONTAL
} im_orientation;

im_flow_dir

Flow direction controlling horizontal layout mirroring.

ui/tree.h, line 64
typedef enum im_flow_dir {
    IM_FLOW_LTR = 0,
    IM_FLOW_RTL
} im_flow_dir;

im_grid_unit

Grid track sizing unit (Pixel, Auto, or Star).

ui/tree.h, line 70
typedef enum im_grid_unit {
    IM_GRID_STAR = 0,
    IM_GRID_AUTO,
    IM_GRID_PIXEL
} im_grid_unit;

im_grid_def

One RowDefinition or ColumnDefinition of a Grid.

ui/tree.h, line 77
typedef struct im_grid_def {
    im_grid_unit unit;
    im_fixed value;
    im_fixed min_size;
    im_fixed max_size;
} im_grid_def;

im_prop_bit

Bitmask of properties that have a local override or template binding on an element.

ui/tree.h, line 85
typedef enum im_prop_bit {
    IM_PBIT_PADDING = 1u << 0,
    IM_PBIT_BORDER_THICKNESS = 1u << 1,
    IM_PBIT_H_CONTENT_ALIGN = 1u << 2,
    IM_PBIT_V_CONTENT_ALIGN = 1u << 3,
    IM_PBIT_FLOW_DIR = 1u << 4
} im_prop_bit;

im_node

One element in the portable UI tree.

ui/tree.h, line 94
typedef struct im_node {
    im_element_kind kind;
    const char *name;
    struct im_node *parent;
    struct im_node *templated_parent;
    struct im_node **children;
    uint32_t child_count;
    uint32_t child_cap;

    /* Box and alignment properties. */
    im_fixed width;
    im_fixed height;
    im_fixed min_width;
    im_fixed min_height;
    im_fixed max_width;
    im_fixed max_height;
    im_fixed intrinsic_width;
    im_fixed intrinsic_height;
    im_thickness margin;
    im_thickness padding;
    im_thickness default_padding;
    im_thickness border_thickness;
    im_thickness default_border_thickness;
    im_align h_align;
    im_align v_align;
    im_align h_content_align;
    im_align default_h_content_align;
    im_align v_content_align;
    im_align default_v_content_align;
    im_visibility visibility;
    im_flow_dir flow_direction;
    bool use_layout_rounding;

    /* Property override and TemplateBinding masks. */
    uint32_t local_mask;
    uint32_t bind_mask;

    /* StackPanel properties. */
    im_orientation orientation;
    im_fixed spacing;

    /* Grid panel and attached child properties. */
    im_grid_def *rows;
    uint32_t row_count;
    im_grid_def *cols;
    uint32_t col_count;
    im_fixed row_spacing;
    im_fixed col_spacing;
    uint32_t grid_row;
    uint32_t grid_col;
    uint32_t grid_row_span;
    uint32_t grid_col_span;

    /* Layout invalidation and cached pass results. */
    bool measure_dirty;
    bool arrange_dirty;
    bool has_measured;
    bool has_arranged;
    bool measured_inf_w;
    bool measured_inf_h;
    im_size last_avail;
    im_rect last_arrange_rect;
    im_fixed last_scale;
    im_size desired_size;
    im_size unclipped_desired;
    im_rect layout_rect;
    im_rect absolute_rect;
} im_node;

im_tree

Element tree owning the allocator and root pointer.

ui/tree.h, line 164
typedef struct im_tree {
    im_allocator alloc;
    im_node *root;
    uint32_t node_count;
} im_tree;

im_tree_init

Initialise an empty element tree with a caller-supplied allocator. Returns false if invalid.

ui/tree.h, line 171
bool im_tree_init(im_tree *tree, im_allocator alloc);

im_tree_destroy

Destroy every node reachable from tree->root and reset the tree to empty.

ui/tree.h, line 174
void im_tree_destroy(im_tree *tree);

im_tree_create_node

Create a detached element node with WinUI defaults. Returns NULL on allocation failure.

ui/tree.h, line 177
im_node *im_tree_create_node(im_tree *tree, im_element_kind kind, const char *name);

im_tree_destroy_subtree

Destroy a detached subtree (or detach from parent/root first) and release all memory.

ui/tree.h, line 180
void im_tree_destroy_subtree(im_tree *tree, im_node *node);

im_tree_append_child

Append child to parent. On allocation failure, leaves parent and child unchanged and returns false.

ui/tree.h, line 183
bool im_tree_append_child(im_tree *tree, im_node *parent, im_node *child);

im_tree_insert_child

Insert child at index in parent. On allocation failure, leaves parent and child unchanged and returns false.

ui/tree.h, line 186
bool im_tree_insert_child(im_tree *tree, im_node *parent, uint32_t index, im_node *child);

im_tree_remove_child

Remove child from its parent without destroying it. Invalidates parent measure.

ui/tree.h, line 189
bool im_tree_remove_child(im_tree *tree, im_node *parent, im_node *child);

im_tree_replace_child

Replace existing child at index with replacement, returning the removed child (or NULL on error).

ui/tree.h, line 192
im_node *im_tree_replace_child(im_tree *tree, im_node *parent, uint32_t index, im_node *replacement);

im_tree_find_by_name

Find the first descendant (or self) matching name.

ui/tree.h, line 195
im_node *im_tree_find_by_name(im_node *root, const char *name);

im_tree_invalidate_measure

Mark node and its ancestors measure-dirty and arrange-dirty.

ui/tree.h, line 198
void im_tree_invalidate_measure(im_node *node);

im_tree_invalidate_arrange

Mark node and its ancestors arrange-dirty.

ui/tree.h, line 201
void im_tree_invalidate_arrange(im_node *node);

im_tree_set_grid_rows

Set Grid row definitions transactionally; on allocation failure, existing rows remain intact.

ui/tree.h, line 204
bool im_tree_set_grid_rows(im_tree *tree, im_node *grid, const im_grid_def *defs, uint32_t count);

im_tree_set_grid_cols

Set Grid column definitions transactionally; on allocation failure, existing columns remain intact.

ui/tree.h, line 207
bool im_tree_set_grid_cols(im_tree *tree, im_node *grid, const im_grid_def *defs, uint32_t count);

im_node_set_size

Set explicit Width/Height (use IM_FIXED_AUTO for Auto). Invalidates measure on change.

ui/tree.h, line 210
void im_node_set_size(im_node *node, im_fixed width, im_fixed height);

im_node_set_min_max

Set MinWidth/MinHeight/MaxWidth/MaxHeight constraints. Invalidates measure on change.

ui/tree.h, line 213
void im_node_set_min_max(im_node *node, im_fixed min_w, im_fixed min_h, im_fixed max_w, im_fixed max_h);

im_node_set_intrinsic_size

Set intrinsic content size for leaf elements. Invalidates measure on change.

ui/tree.h, line 216
void im_node_set_intrinsic_size(im_node *node, im_fixed width, im_fixed height);

im_node_set_margin

Set Margin. Invalidates measure on change.

ui/tree.h, line 219
void im_node_set_margin(im_node *node, im_thickness margin);

im_node_set_padding

Set local Padding override (flows to TemplateBinding children). Invalidates measure on change.

ui/tree.h, line 222
void im_node_set_padding(im_node *node, im_thickness padding);

im_node_clear_padding

Clear local Padding override back to template/style default. Invalidates measure on change.

ui/tree.h, line 225
void im_node_clear_padding(im_node *node);

im_node_set_border_thickness

Set local BorderThickness override (flows to TemplateBinding children). Invalidates measure on change.

ui/tree.h, line 228
void im_node_set_border_thickness(im_node *node, im_thickness thickness);

im_node_clear_border_thickness

Clear local BorderThickness override back to template/style default. Invalidates measure on change.

ui/tree.h, line 231
void im_node_clear_border_thickness(im_node *node);

im_node_set_alignment

Set HorizontalAlignment and VerticalAlignment. Invalidates arrange on change.

ui/tree.h, line 234
void im_node_set_alignment(im_node *node, im_align h_align, im_align v_align);

im_node_set_content_alignment

Set local HorizontalContentAlignment and VerticalContentAlignment overrides. Invalidates measure on change.

ui/tree.h, line 237
void im_node_set_content_alignment(im_node *node, im_align h_align, im_align v_align);

im_node_clear_content_alignment

Clear local content alignment overrides back to template/style defaults. Invalidates measure on change.

ui/tree.h, line 240
void im_node_clear_content_alignment(im_node *node);

im_node_set_visibility

Set Visibility (Visible or Collapsed). Invalidates measure on change.

ui/tree.h, line 243
void im_node_set_visibility(im_node *node, im_visibility visibility);

im_node_set_flow_direction

Set explicit FlowDirection override on node. Invalidates arrange on change.

ui/tree.h, line 246
void im_node_set_flow_direction(im_node *node, im_flow_dir dir);

im_node_set_layout_rounding

Set UseLayoutRounding (default true). Invalidates measure on change.

ui/tree.h, line 249
void im_node_set_layout_rounding(im_node *node, bool enabled);

im_node_set_stack

Set StackPanel orientation and spacing. Invalidates measure on change.

ui/tree.h, line 252
void im_node_set_stack(im_node *node, im_orientation orientation, im_fixed spacing);

im_node_set_grid_spacing

Set Grid RowSpacing and ColumnSpacing. Invalidates measure on change.

ui/tree.h, line 255
void im_node_set_grid_spacing(im_node *node, im_fixed row_spacing, im_fixed col_spacing);

im_node_set_grid_cell

Set Grid.Row, Grid.Column, Grid.RowSpan, Grid.ColumnSpan attached properties. Invalidates measure on change.

ui/tree.h, line 258
void im_node_set_grid_cell(im_node *node, uint32_t row, uint32_t col, uint32_t row_span, uint32_t col_span);

im_node_effective_padding

Resolve effective Padding on node (following TemplateBinding when active).

ui/tree.h, line 261
im_thickness im_node_effective_padding(const im_node *node);

im_node_effective_border_thickness

Resolve effective BorderThickness on node (following TemplateBinding when active).

ui/tree.h, line 264
im_thickness im_node_effective_border_thickness(const im_node *node);

im_node_effective_h_content_align

Resolve effective HorizontalContentAlignment on node (following TemplateBinding when active).

ui/tree.h, line 267
im_align im_node_effective_h_content_align(const im_node *node);

im_node_effective_v_content_align

Resolve effective VerticalContentAlignment on node (following TemplateBinding when active).

ui/tree.h, line 270
im_align im_node_effective_v_content_align(const im_node *node);

im_node_effective_flow_direction

Resolve effective FlowDirection on node (inheriting from ancestors if unset).

ui/tree.h, line 273
im_flow_dir im_node_effective_flow_direction(const im_node *node);

im_tree_instantiate_template

Instantiate a compiled WinUI template (ui/template_data.c) into a new control node subtree, resolving theme resources with im_value(palette, id) and wiring TemplateBindings. On any allocation failure, frees all partial nodes and returns NULL leaving tree unchanged.

ui/tree.h, line 278
im_node *im_tree_instantiate_template(im_tree *tree, const im_palette *palette, enum im_template_id id, const char *name);

im_tree_instantiate_custom_template

Instantiate an arbitrary im_template descriptor with custom tables (used for compiled fixture tests). On any allocation failure, frees all partial nodes and returns NULL leaving tree unchanged.

ui/tree.h, line 282
im_node *im_tree_instantiate_custom_template(
    im_tree *tree,
    const im_palette *palette,
    const im_template *tpl,
    const im_template_setter *setters,
    const im_template_element *elems,
    const im_template_prop *props,
    const char *name);
GeneratedMade from ui/tree.hPublished from c4737ad