|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Push-button leaf widget for the ra8_widget tree model (#145 Phase 2). More...
Go to the source code of this file.
Functions | |
| static uint32_t | internal_button_face (const ra8_widget_button_t *b) |
| Pick the face fill colour for the button's current state. | |
| static void | internal_button_render (ra8_widget_t *w) |
| Button vtable render: paint the bordered face, then the label. | |
| static bool | internal_button_on_input (ra8_widget_t *w, const ra8_widget_event_t *ev) |
| Button vtable input: latch a touch, decline everything else. | |
| const ra8_widget_vtable_t * | ra8_widget_button_vtable (void) |
| Return the shared vtable backing every push-button widget. | |
| ra8_err_t | ra8_widget_button_init (ra8_widget_t *w, ra8_widget_button_t *button) |
| Bind a widget instance to a push button. | |
Variables | |
| static const char * | s_tag = "ra8_widget_button" |
| Logging / check tag. | |
| static const ra8_widget_vtable_t | s_button_vt |
| The single immutable vtable shared by every push button. | |
Push-button leaf widget for the ra8_widget tree model (#145 Phase 2).
The interactive counterpart to the text label: a bordered, filled face with an aligned label that latches on a tap. render paints the face (a different fill while pressed) and label through the injected ra8_widget_paint_t backend; on_input consumes a touch the dispatcher has already hit-tested onto it – flipping pressed, bumping the presses counter, self-invalidating with the fast hint (so only this button's rect re-flushes through the panel's damage cycle), then firing the optional on_press callback. Button-kind events are declined so they keep routing. Like the rest of ra8_widget, the file carries no ra8_gfx dependency.
[Ring 5 / UI] {World: NS}
Definition in file ra8_widget_button.c.
|
static |
Pick the face fill colour for the button's current state.
Folds the pressed/released face selection out of the render body so it stays a single, branch-coverable decision.
| [in] | b | The button descriptor (non-NULL). |
| b->face_pressed | When b->pressed is true. |
| b->face | When b->pressed is false. |
b is non-NULL. Definition at line 48 of file ra8_widget_button.c.
Referenced by internal_button_render().
|
static |
Button vtable input: latch a touch, decline everything else.
A touch routed onto this button flips pressed, increments presses, marks the button dirty with the fast hint (so the panel flushes only this rect next compose), fires on_press if set, and reports the event consumed. Non-touch events return false so the dispatcher keeps offering them to other widgets.
| [in] | w | The button widget (its ctx is a ra8_widget_button_t). |
| [in] | ev | The event already routed to this button. |
| true | ev was a touch and the button latched it. |
| false | ev was not a touch (or ctx is NULL). |
w and ev are non-NULL. w->ctx points at a valid button descriptor or is NULL. Definition at line 115 of file ra8_widget_button.c.
References k_ra8_widget_ev_touch, k_ra8_widget_refresh_fast, ra8_widget_event_t::kind, and ra8_widget_invalidate().
|
static |
Button vtable render: paint the bordered face, then the label.
Reads the ra8_widget_button_t from w->ctx, fills its (optionally bordered) face for the current pressed state via priv_widget_fill_box, then – when there is text and a draw_text backend – places and draws the label over the face.
| [in] | w | The button widget (its ctx is a ra8_widget_button_t). |
w is non-NULL (guaranteed by ra8_widget_render_dirty). w->ctx points at a valid button descriptor or is NULL. Definition at line 72 of file ra8_widget_button.c.
References internal_button_face(), priv_widget_fill_box(), and priv_widget_text_pos().
|
nodiscard |
Bind a widget instance to a push button.
Wires w to render + route button: sets its vtable to ra8_widget_button_vtable, points its ctx at button, and makes it visible. The caller still sets w's fixed / flex (and usually its action_id) for its parent's layout and hit routing.
| [in,out] | w | Widget to turn into a button (non-NULL). |
| [in] | button | Button descriptor (non-NULL; outlives w's use). |
| k_ra8_ok | Bound; w renders + routes button. |
| k_ra8_err_null_ptr | w or button is NULL. |
w and button are non-NULL. button outlives every render / dispatch of w. w is left unchanged.Definition at line 145 of file ra8_widget_button.c.
References k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_widget_button_vtable(), and s_tag.
Referenced by wk_build_tree().
| const ra8_widget_vtable_t * ra8_widget_button_vtable | ( | void | ) |
Return the shared vtable backing every push-button widget.
One immutable vtable serves all buttons: render paints the (optionally bordered) face and aligned label through the button's ra8_widget_paint_t; on_input latches a touch (flip pressed, bump presses, self-invalidate fast, call on_press) and consumes it, ignoring button events; measure is NULL. ra8_widget_button_init binds it.
Definition at line 140 of file ra8_widget_button.c.
References s_button_vt.
Referenced by ra8_widget_button_init().
|
static |
The single immutable vtable shared by every push button.
Definition at line 134 of file ra8_widget_button.c.
Referenced by ra8_widget_button_vtable().
|
static |
Logging / check tag.
Definition at line 30 of file ra8_widget_button.c.