|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bounded, allocation-free box-model layout for e-reader chrome. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_box_t |
| One node in a box tree (caller-owned). More... | |
| struct | ra8_box_tree_t |
| Append-only builder over caller-owned node storage. More... | |
Enumerations | |
| enum | ra8_box_const_t : int32_t { k_ra8_box_none = -1 , k_ra8_box_no_colour = (int32_t)0 } |
| Box-tree sentinels and the "no colour" marker. More... | |
| enum | ra8_box_kind_t : uint8_t { k_ra8_box_stack_v = 0U , k_ra8_box_stack_h = 1U , k_ra8_box_grid = 2U , k_ra8_box_leaf = 3U } |
| Box layout kind. More... | |
Functions | |
| 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. | |
| 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. | |
| 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. | |
Bounded, allocation-free box-model layout for e-reader chrome.
ra8_box is the minimal CSS-style box model the e-reader chrome needs (issue #80, #76). The full document engine (ra8_reflow) reflows arbitrary book XHTML; the chrome (library grid, reading bars, menus) is instead a small fixed box tree laid out once per screen. This is the only "web-like" layout compatible with the no-malloc / bounded / MC/DC bar: the screen is a caller-owned array of nodes, the layout is a single forward pass (no recursion, P10 Rule 1), and the engine produces only positioned rectangles – it never touches a font or a framebuffer, so the same layout runs on the host test harness and on the RA8D2, and the renderer (ra8_gfx) and hit-tester (ra8_ui) are layered on top.
Supported box kinds: a vertical stack (column), a horizontal stack (row), a fixed-column grid, and a leaf. Children size either to a fixed extent along the parent's main axis or to a flex weight that splits the leftover space. Padding insets a container's content; gap separates its children. Fill / border colours are carried on each node for the renderer to consume; the engine itself only computes geometry.
[Ring 5 / UI] {World: NS}
Definition in file ra8_box.h.
| enum ra8_box_const_t : int32_t |
| enum ra8_box_kind_t : uint8_t |
|
nodiscard |
Append a node and link it as a child of parent.
Copies node into storage, resets its tree links, and appends it to parent's child chain (or makes it a root when parent ==
k_ra8_box_none). Returns the new node's index for use as a parent in later calls.
| [in,out] | tree | Initialised tree. |
| [in] | parent | Parent index, or k_ra8_box_none for a root. |
| [in] | node | Node template (kind / sizing / colours). |
Definition at line 297 of file ra8_box.c.
References ra8_box_tree_t::cap, ra8_box_tree_t::count, ra8_box_t::first_child, internal_iter_live(), k_ra8_box_none, ra8_box_t::next, and ra8_box_tree_t::nodes.
Referenced by ch_build_chrome(), er_add_book_tile(), er_build_library(), er_build_nav(), er_build_toolbar(), internal_build_stack_tree(), and sh_layout_cards().
|
nodiscard |
Lay out the tree, filling every node's rect.
Sets nodes[root].rect = *frame, then makes one forward pass: each container distributes its content box (its rect inset by pad) across its children – fixed children take their fixed extent, the rest split the leftover by flex weight, separated by gap. Grids place children row-major across grid_cols. Because parents precede children in index order, a single in-order pass suffices (no recursion).
| [in,out] | tree | Built tree (>= 1 node). |
| [in] | root | Index of the root node. |
| [in] | frame | Outer rectangle the root fills. |
| k_ra8_ok | Laid out; every reachable rect set. |
| k_ra8_err_null_ptr | tree or frame is NULL. |
| k_ra8_err_invalid_arg | root out of range, or empty tree. |
Definition at line 331 of file ra8_box.c.
References ra8_box_tree_t::count, internal_layout_grid(), internal_layout_stack(), k_ra8_box_grid, k_ra8_box_leaf, k_ra8_box_stack_h, k_ra8_box_stack_v, k_ra8_err_invalid_arg, k_ra8_ok, ra8_box_t::kind, ra8_box_tree_t::nodes, RA8_CHECK_NULL_PTR, ra8_box_t::rect, and s_tag.
Referenced by er_build_library(), main(), ra8_widget_layout_stack(), and sh_layout_cards().
|
nodiscard |
Bind a tree builder to caller-owned node storage.
| [out] | tree | Tree to initialise. |
| [in] | storage | Node array owned by the caller. |
| [in] | cap | Number of nodes storage holds (>= 1). |
| k_ra8_ok | Initialised (empty tree). |
| k_ra8_err_null_ptr | tree or storage is NULL. |
| k_ra8_err_invalid_arg | cap is 0. |
Definition at line 284 of file ra8_box.c.
References ra8_box_tree_t::cap, ra8_box_tree_t::count, k_ra8_err_invalid_arg, k_ra8_ok, ra8_box_tree_t::nodes, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ch_build_chrome(), er_build_library(), internal_build_stack_tree(), and sh_layout_cards().