ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_box.h
Go to the documentation of this file.
1
35
36#pragma once
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#include <stdint.h>
43
44#include "ra8_err.h"
45#include "ra8_ui.h"
46
47/* ===========================================================================
48 * Sentinels
49 * ===========================================================================
50 */
51
56typedef enum : int32_t {
58 k_ra8_box_no_colour = (int32_t)0,
60
71
72/* ===========================================================================
73 * Node + tree
74 * ===========================================================================
75 */
76
90typedef struct {
91 uint8_t kind;
92 uint8_t grid_cols;
93 int16_t fixed;
94 uint16_t flex;
95 int16_t pad;
96 int16_t gap;
97 uint32_t fill;
98 uint32_t border;
99 int16_t border_w;
100 int16_t tag;
101 int32_t first_child;
102 int32_t next;
104} ra8_box_t;
105
115typedef struct {
117 uint16_t cap;
118 uint16_t count;
120
121/* ===========================================================================
122 * API
123 * ===========================================================================
124 */
125
146[[nodiscard]] ra8_err_t ra8_box_tree_init(ra8_box_tree_t* tree, ra8_box_t* storage, uint16_t cap);
147
171[[nodiscard]] int16_t ra8_box_add(ra8_box_tree_t* tree, int16_t parent, const ra8_box_t* node);
172
200[[nodiscard]] ra8_err_t
201ra8_box_layout(ra8_box_tree_t* tree, int16_t root, const ra8_ui_rect_t* frame);
202
203#ifdef __cplusplus
204}
205#endif
ra8_err_t ra8_box_tree_init(ra8_box_tree_t *tree, ra8_box_t *storage, uint16_t cap)
Bind a tree builder to caller-owned node storage.
Definition ra8_box.c:284
ra8_err_t ra8_box_layout(ra8_box_tree_t *tree, int16_t root, const ra8_ui_rect_t *frame)
Lay out the tree, filling every node's rect.
Definition ra8_box.c:331
ra8_box_const_t
Box-tree sentinels and the "no colour" marker.
Definition ra8_box.h:56
@ k_ra8_box_no_colour
Carried fill/border: absent.
Definition ra8_box.h:58
@ k_ra8_box_none
No child / no sibling link.
Definition ra8_box.h:57
int16_t ra8_box_add(ra8_box_tree_t *tree, int16_t parent, const ra8_box_t *node)
Append a node and link it as a child of parent.
Definition ra8_box.c:297
ra8_box_kind_t
Box layout kind.
Definition ra8_box.h:65
@ k_ra8_box_stack_v
Vertical stack: children stack top->bottom.
Definition ra8_box.h:66
@ k_ra8_box_grid
Fixed-column grid, row-major.
Definition ra8_box.h:68
@ k_ra8_box_leaf
Terminal box (no children laid out).
Definition ra8_box.h:69
@ k_ra8_box_stack_h
Horizontal stack: children left->right.
Definition ra8_box.h:67
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Bounded UI interaction core: hit-testing, screen stack, paging.
One node in a box tree (caller-owned).
Definition ra8_box.h:90
uint8_t grid_cols
Columns for k_ra8_box_grid (>= 1).
Definition ra8_box.h:92
uint8_t kind
ra8_box_kind_t.
Definition ra8_box.h:91
uint16_t flex
Flex weight when not fixed.
Definition ra8_box.h:94
int32_t first_child
First child index, or k_ra8_box_none.
Definition ra8_box.h:101
int16_t fixed
Fixed main-axis extent; 0 => use flex.
Definition ra8_box.h:93
uint32_t border
Border colour, or k_ra8_box_no_colour.
Definition ra8_box.h:98
int16_t tag
Caller tag (e.g.
Definition ra8_box.h:100
int16_t gap
Gap between children.
Definition ra8_box.h:96
int16_t border_w
Border width (0 = no border draw).
Definition ra8_box.h:99
int32_t next
Next sibling index, or k_ra8_box_none.
Definition ra8_box.h:102
int16_t pad
Inner padding (all four sides).
Definition ra8_box.h:95
ra8_ui_rect_t rect
OUTPUT: computed rectangle.
Definition ra8_box.h:103
uint32_t fill
Background colour, or k_ra8_box_no_colour.
Definition ra8_box.h:97
Append-only builder over caller-owned node storage.
Definition ra8_box.h:115
uint16_t cap
Capacity of nodes.
Definition ra8_box.h:117
ra8_box_t * nodes
Caller storage.
Definition ra8_box.h:116
uint16_t count
Nodes used.
Definition ra8_box.h:118
Axis-aligned rectangle in framebuffer pixel coordinates.
Definition ra8_ui.h:72