ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_widget_panel.c
Go to the documentation of this file.
1
23
24#include "ra8_attributes.h"
25#include "ra8_check.h"
26#include "ra8_widget.h"
27
29static const char* s_tag = "ra8_widget_panel";
30
51{
52 return ra8_widget_layout_stack(p->children,
53 p->count,
54 rect,
55 p->axis,
56 p->gap,
57 p->pad,
58 p->box_scratch,
59 p->box_cap);
60}
61
86 const ra8_ui_rect_t* frame,
87 const ra8_ui_rect_t* out_damage,
88 const ra8_widget_refresh_t* out_hint,
89 const uint16_t* out_dirty,
90 ra8_widget_panel_t** out_panel)
91{
92 RA8_CHECK_NULL_PTR(panel_w, s_tag, "panel_w must not be nullptr");
93 RA8_CHECK_NULL_PTR(frame, s_tag, "frame must not be nullptr");
94 RA8_CHECK_NULL_PTR(out_damage, s_tag, "out_damage must not be nullptr");
95 RA8_CHECK_NULL_PTR(out_hint, s_tag, "out_hint must not be nullptr");
96 RA8_CHECK_NULL_PTR(out_dirty, s_tag, "out_dirty must not be nullptr");
97 ra8_widget_panel_t* p = (ra8_widget_panel_t*)panel_w->ctx;
98 if ((p == nullptr) || (p->children == nullptr)) {
100 }
101 *out_panel = p;
102 return k_ra8_ok;
103}
104
124{
126 if ((p == nullptr) || (p->children == nullptr)) {
127 return;
128 }
129 if (internal_panel_layout(p, &w->rect) != k_ra8_ok) {
130 return;
131 }
132 const ra8_widget_refresh_t hint = (w->refresh == (uint8_t)k_ra8_widget_refresh_none)
134 : (ra8_widget_refresh_t)w->refresh;
135 for (uint16_t i = 0U; i < p->count; ++i) {
136 if (p->children[i].visible) {
137 (void)ra8_widget_invalidate(&p->children[i], hint);
138 }
139 }
140 (void)ra8_widget_render_dirty(p->children, p->count);
141}
142
163{
165 if ((p == nullptr) || (p->children == nullptr)) {
166 return false;
167 }
168 bool handled = false;
169 (void)ra8_widget_dispatch(p->children, p->count, ev, &handled);
170 return handled;
171}
172
175 .measure = nullptr,
176 .render = internal_panel_render,
177 .on_input = internal_panel_on_input,
178};
179
181{
182 return &s_panel_vt;
183}
184
186{
187 RA8_CHECK_NULL_PTR(w, s_tag, "w must not be nullptr");
188 RA8_CHECK_NULL_PTR(panel, s_tag, "panel must not be nullptr");
189 if (panel->count > 0U) {
190 if (panel->children == nullptr) {
192 }
193 if ((uint32_t)panel->box_cap < ((uint32_t)panel->count + 1U)) {
195 }
196 }
197 w->vt = ra8_widget_panel_vtable();
198 w->ctx = panel;
199 w->visible = true;
200 return k_ra8_ok;
201}
202
204 const ra8_ui_rect_t* frame,
205 ra8_ui_rect_t* out_damage,
206 ra8_widget_refresh_t* out_hint,
207 uint16_t* out_dirty)
208{
209 ra8_widget_panel_t* p = nullptr;
210 const ra8_err_t cerr =
211 internal_compose_check(panel_w, frame, out_damage, out_hint, out_dirty, &p);
212 if (cerr != k_ra8_ok) {
213 return cerr;
214 }
215 panel_w->rect = *frame;
216 const ra8_err_t lerr = internal_panel_layout(p, &panel_w->rect);
217 if (lerr != k_ra8_ok) {
218 return lerr;
219 }
220 const ra8_err_t derr = ra8_widget_damage(p->children, p->count, out_damage, out_hint, out_dirty);
221 if (derr != k_ra8_ok) {
222 return derr;
223 }
224 const ra8_err_t rerr = ra8_widget_render_dirty(p->children, p->count);
225 if (rerr != k_ra8_ok) {
226 return rerr;
227 }
228 panel_w->dirty = false;
229 panel_w->refresh = (uint8_t)k_ra8_widget_refresh_none;
230 return k_ra8_ok;
231}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Zero-heap composable widget layer (dwm-style) over ra8_box + ra8_ui.
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).
Definition ra8_widget.c:215
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.
Definition ra8_widget.c:299
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).
Definition ra8_widget.c:286
ra8_widget_refresh_t
E-ink-style refresh hint carried by a dirty widget.
Definition ra8_widget.h:98
@ k_ra8_widget_refresh_none
Clean – not dirty.
Definition ra8_widget.h:99
@ k_ra8_widget_refresh_quality
Full / GC16 (whole-area redraw).
Definition ra8_widget.h:101
ra8_err_t ra8_widget_render_dirty(ra8_widget_t *widgets, uint16_t count)
Render every visible + dirty widget, clearing its damage.
Definition ra8_widget.c:331
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.
Definition ra8_widget.c:252
const ra8_widget_vtable_t * ra8_widget_panel_vtable(void)
Return the shared vtable that every container panel uses.
static const ra8_widget_vtable_t s_panel_vt
The single immutable vtable shared by every container panel.
ra8_err_t ra8_widget_panel_init(ra8_widget_t *w, ra8_widget_panel_t *panel)
Bind a widget instance to a container panel.
ra8_err_t ra8_widget_panel_compose(ra8_widget_t *panel_w, const ra8_ui_rect_t *frame, ra8_ui_rect_t *out_damage, ra8_widget_refresh_t *out_hint, uint16_t *out_dirty)
Run one top-level compose cycle over a panel and report the flush.
static ra8_err_t internal_compose_check(ra8_widget_t *panel_w, const ra8_ui_rect_t *frame, const ra8_ui_rect_t *out_damage, const ra8_widget_refresh_t *out_hint, const uint16_t *out_dirty, ra8_widget_panel_t **out_panel)
Validate ra8_widget_panel_compose arguments and extract the panel.
static bool internal_panel_on_input(ra8_widget_t *w, const ra8_widget_event_t *ev)
Panel vtable input: route the event down to the children.
static void internal_panel_render(ra8_widget_t *w)
Panel vtable render: lay out + composite the whole subtree.
static ra8_err_t internal_panel_layout(const ra8_widget_panel_t *p, const ra8_ui_rect_t *rect)
Lay a panel's children out inside a rectangle.
Axis-aligned rectangle in framebuffer pixel coordinates.
Definition ra8_ui.h:72
One input event delivered to ra8_widget_dispatch.
Definition ra8_widget.h:77
A container widget's child array + stack-layout parameters (#145).
One widget instance (caller-owned, no allocation).
Behaviour table shared by all widgets of one kind.
Definition ra8_widget.h:121