|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Implementation of the ra8_widget composable-UI layer (#145). More...
Go to the source code of this file.
Functions | |
| static bool | internal_rect_empty (const ra8_ui_rect_t *r) |
| True if a rect covers no pixels (used as the union identity). | |
| static int32_t | internal_min_i32 (int32_t a, int32_t b) |
| Smaller of two signed values. | |
| static int32_t | internal_max_i32 (int32_t a, int32_t b) |
| Larger of two signed values. | |
| static ra8_ui_rect_t | internal_rect_union (ra8_ui_rect_t acc, ra8_ui_rect_t r) |
| Bounding union of two rects (empty acts as the identity). | |
| static uint16_t | internal_visible_count (const ra8_widget_t *widgets, uint16_t count) |
Count the visible widgets in widgets[0..count). | |
| static ra8_err_t | internal_build_stack_tree (const ra8_widget_t *widgets, uint16_t count, ra8_widget_axis_t axis, int16_t gap, int16_t pad, ra8_box_t *scratch, uint16_t cap, ra8_box_tree_t *out_tree, int16_t *out_root) |
| Build a ra8_box stack tree: one container + a leaf per visible widget. | |
| ra8_err_t | ra8_widget_layout_stack (ra8_widget_t *widgets, uint16_t count, const ra8_ui_rect_t *frame, ra8_widget_axis_t axis, int16_t gap, int16_t pad, ra8_box_t *box_scratch, uint16_t box_cap) |
| Lay a stack of widgets out inside a frame (delegates to ra8_box). | |
| ra8_err_t | ra8_widget_dispatch (ra8_widget_t *widgets, uint16_t count, const ra8_widget_event_t *ev, bool *out_handled) |
| Route an event to the widget that should handle it. | |
| ra8_err_t | ra8_widget_invalidate (ra8_widget_t *w, ra8_widget_refresh_t refresh) |
| Mark a widget dirty with a refresh hint (folds upward in strength). | |
| ra8_err_t | ra8_widget_damage (const ra8_widget_t *widgets, uint16_t count, ra8_ui_rect_t *out_rect, ra8_widget_refresh_t *out_hint, uint16_t *out_count) |
| Compute the minimal damage rectangle + refresh hint to flush. | |
| ra8_err_t | ra8_widget_render_dirty (ra8_widget_t *widgets, uint16_t count) |
| Render every visible + dirty widget, clearing its damage. | |
Variables | |
| static const char * | s_tag = "ra8_widget" |
| Logging / check tag. | |
Implementation of the ra8_widget composable-UI layer (#145).
Implements bounded widget traversal, invalidation, event routing, and drawing over caller-owned widget and rendering state.
Definition in file ra8_widget.c.
|
static |
Build a ra8_box stack tree: one container + a leaf per visible widget.
Sizes the scratch against the visible count, adds a stack container (row/column) then one leaf per visible widget carrying its fixed/flex. The caller then runs ra8_box_layout and copies the leaf rects back. Split out so ra8_widget_layout_stack stays within the NASA Rule 4 function-size cap.
| [in] | widgets | Widget array. |
| [in] | count | Number of widgets. |
| [in] | axis | Stack main axis. |
| [in] | gap | Gap between children. |
| [in] | pad | Inner padding. |
| [in] | scratch | Caller ra8_box scratch. |
| [in] | cap | Capacity of scratch. |
| [out] | out_tree | Receives the built tree. |
| [out] | out_root | Receives the container root index. |
| k_ra8_ok | Tree built; out_root is the container. |
| k_ra8_err_invalid_arg | Scratch too small or a box add failed. |
| <ra8_box_tree_init's> | Forwarded from ra8_box_tree_init. |
out_tree / out_root non-NULL; scratch covers cap. cap >= visible_count + 1. out_tree holds the container + visible leaves. out_root. count (NASA Rule 2). Definition at line 170 of file ra8_widget.c.
References ra8_box_t::fixed, ra8_box_t::flex, ra8_box_t::gap, internal_visible_count(), k_ra8_box_leaf, k_ra8_box_none, k_ra8_box_stack_h, k_ra8_box_stack_v, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_widget_axis_row, ra8_box_t::kind, ra8_box_t::pad, ra8_box_add(), ra8_box_tree_init(), and ra8_box_t::tag.
Referenced by ra8_widget_layout_stack().
|
static |
Larger of two signed values.
Branch-style max used by the rect-union corner math.
| [in] | a | First value. |
| [in] | b | Second value. |
a and b. | a | When a > b. |
| b | Otherwise. |
Definition at line 77 of file ra8_widget.c.
Referenced by internal_rect_union().
|
static |
Smaller of two signed values.
Branch-style min used by the rect-union corner math.
| [in] | a | First value. |
| [in] | b | Second value. |
a and b. | a | When a < b. |
| b | Otherwise. |
Definition at line 56 of file ra8_widget.c.
Referenced by internal_rect_union().
|
static |
True if a rect covers no pixels (used as the union identity).
A w <= 0 and h <= 0 rect is the empty/identity element of internal_rect_union, so the damage accumulator can start at {}.
| [in] | r | Rect to test (non-NULL). |
r covers no pixels, false otherwise. | true | Both width and height are non-positive. |
| false | At least one dimension is positive. |
r is non-NULL. Definition at line 35 of file ra8_widget.c.
References ra8_ui_rect_t::h, and ra8_ui_rect_t::w.
Referenced by internal_rect_union().
|
static |
Bounding union of two rects (empty acts as the identity).
Returns the smallest rect covering both inputs; an empty input returns the other unchanged, so a {} accumulator folds cleanly.
| [in] | acc | Accumulated rect (or empty identity). |
| [in] | r | Rect to fold in. |
acc and r. | r | When acc is empty. |
| acc | When r is empty. |
Definition at line 99 of file ra8_widget.c.
References ra8_ui_rect_t::h, internal_max_i32(), internal_min_i32(), internal_rect_empty(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by ra8_widget_damage().
|
static |
Count the visible widgets in widgets[0..count).
Used to size the ra8_box scratch (one leaf per visible widget plus the container) before laying a stack out.
| [in] | widgets | Widget array (non-NULL when count > 0). |
| [in] | count | Number of widgets. |
| 0 | No widget is visible. |
widgets covers count entries. count (NASA Rule 2). Definition at line 131 of file ra8_widget.c.
Referenced by internal_build_stack_tree().
|
nodiscard |
Compute the minimal damage rectangle + refresh hint to flush.
Unions the rects of every visible AND dirty widget into one bounding rectangle and folds their refresh hints into the strongest one. This is the single display_pal flush the compositor issues: changing only the status bar yields just the status bar's rect with the fast hint; a full redraw yields the whole frame with the quality hint.
| [in] | widgets | Widget array. |
| [in] | count | Number of widgets. |
| [out] | out_rect | Receives the union rect (w == h == 0 if nothing dirty). |
| [out] | out_hint | Receives the folded refresh hint (none if clean). |
| [out] | out_count | Receives the number of dirty widgets. |
| k_ra8_ok | Computed (see out_count). |
| k_ra8_err_null_ptr | Any output pointer, or widgets (count>0), NULL. |
Definition at line 299 of file ra8_widget.c.
References internal_rect_union(), k_ra8_err_null_ptr, k_ra8_ok, k_ra8_widget_refresh_none, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_widget_panel_compose(), wa_verify_or_halt(), and wd_check_damage().
|
nodiscard |
Route an event to the widget that should handle it.
For a touch event, finds the first visible widget whose rect contains (ev->x, ev->y) (earlier widgets win on overlap) and calls its on_input. For a button event, offers it to each visible widget in order until one consumes it. A widget with a NULL on_input never consumes.
| [in,out] | widgets | Widget array. |
| [in] | count | Number of widgets. |
| [in] | ev | The event to route. |
| [out] | out_handled | Receives true if some widget consumed the event. |
| k_ra8_ok | Routed (see out_handled). |
| k_ra8_err_null_ptr | widgets (with count>0), ev, or out_handled is NULL. |
Definition at line 252 of file ra8_widget.c.
References k_ra8_err_null_ptr, k_ra8_ok, k_ra8_widget_ev_touch, ra8_widget_event_t::kind, RA8_CHECK_NULL_PTR, ra8_ui_rect_contains(), s_tag, ra8_widget_event_t::x, and ra8_widget_event_t::y.
Referenced by internal_panel_on_input(), and wd_app_on_input().
|
nodiscard |
Mark a widget dirty with a refresh hint (folds upward in strength).
| [in,out] | w | Widget to invalidate. |
| [in] | refresh | k_ra8_widget_refresh_fast / _quality. |
| k_ra8_ok | Marked dirty. |
| k_ra8_err_null_ptr | w is NULL. |
| k_ra8_err_invalid_arg | refresh is k_ra8_widget_refresh_none. |
Definition at line 286 of file ra8_widget.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_widget_refresh_none, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by er_render_keyboard(), er_render_library(), er_render_reading(), internal_bg_on_input(), internal_button_on_input(), internal_kbd_on_input(), internal_nav_on_input(), internal_panel_render(), internal_rv_link(), internal_rv_on_input(), internal_tb_on_input(), wa_app_render(), wa_verify_or_halt(), wc_check_partial(), wc_invalidate_all(), wc_tick_live(), wd_app_render(), wd_check_damage(), wd_check_partial(), wd_invalidate_all(), wd_tick_live(), wk_invalidate_all(), and wk_on_button_press().
|
nodiscard |
Lay a stack of widgets out inside a frame (delegates to ra8_box).
Builds a transient ra8_box tree – one container plus a leaf per visible widget (invisible widgets are skipped, dwm-style) carrying that widget's fixed / flex – runs ra8_box_layout, then copies each visible widget's computed rect back into widget->rect. Invisible widgets keep their old rect. No allocation: the caller supplies the ra8_box scratch.
| [in,out] | widgets | Widget array. |
| [in] | count | Number of widgets. |
| [in] | frame | Outer rectangle the stack fills. |
| [in] | axis | k_ra8_widget_axis_col / _row. |
| [in] | gap | Gap between children (pixels). |
| [in] | pad | Inner padding of the frame (pixels). |
| [in] | box_scratch | Caller ra8_box_t scratch (>= count + 1 nodes). |
| [in] | box_cap | Capacity of box_scratch. |
| k_ra8_ok | Laid out; every visible widget's rect set. |
| k_ra8_err_null_ptr | widgets, frame, or box_scratch NULL. |
| k_ra8_err_invalid_arg | box_cap < (visible count + 1). |
Definition at line 215 of file ra8_widget.c.
References internal_build_stack_tree(), k_ra8_box_none, k_ra8_ok, ra8_box_layout(), RA8_CHECK_NULL_PTR, ra8_box_t::rect, and s_tag.
Referenced by er_render_keyboard(), er_render_library(), er_render_reading(), internal_panel_layout(), wa_app_render(), and wd_app_render().
|
nodiscard |
Render every visible + dirty widget, clearing its damage.
Calls each visible, dirty widget's render (skipping NULL render callbacks) and then clears its dirty flag and resets refresh to none. The selection of which widgets render is pure (host-testable with a recording mock vtable); the pixel drawing inside render is the on-target part.
| [in,out] | widgets | Widget array. |
| [in] | count | Number of widgets. |
| k_ra8_ok | Rendered + cleared. |
| k_ra8_err_null_ptr | widgets is NULL while count > 0. |
Definition at line 331 of file ra8_widget.c.
References k_ra8_err_null_ptr, k_ra8_ok, and k_ra8_widget_refresh_none.
Referenced by er_render_current(), er_render_keyboard(), er_render_library(), er_render_nag_region(), er_render_reading(), internal_panel_render(), ra8_widget_panel_compose(), wa_app_render(), and wd_app_render().
|
static |
Logging / check tag.
Definition at line 17 of file ra8_widget.c.