|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Toolbar leaf widget for the ra8_widget tree model (#145 Phase 2). More...
#include "ra8_widget_toolbar.h"#include "ra8_check.h"#include "ra8_ui.h"#include "ra8_widget.h"#include "ra8_widget_internal.h"Go to the source code of this file.
Functions | |
| static ra8_ui_rect_t | internal_tb_field_rect (const ra8_widget_toolbar_t *bar, const ra8_ui_rect_t *band) |
| Compute the search-field sub-rectangle inside a toolbar band. | |
| static void | internal_tb_render (ra8_widget_t *w) |
| Toolbar vtable render: band fill, bordered field + hint, count chip. | |
| static bool | internal_tb_on_input (ra8_widget_t *w, const ra8_widget_event_t *ev) |
| Toolbar vtable input: latch a touch inside the search field. | |
| const ra8_widget_vtable_t * | ra8_widget_toolbar_vtable (void) |
| Return the shared vtable backing every toolbar widget. | |
| ra8_err_t | ra8_widget_toolbar_init (ra8_widget_t *w, ra8_widget_toolbar_t *bar) |
| Bind a widget instance to a toolbar. | |
Variables | |
| static const char * | s_tag = "ra8_widget_toolbar" |
| Logging / check tag. | |
| static const ra8_widget_vtable_t | s_tb_vt |
| The single immutable vtable shared by every toolbar. | |
Toolbar leaf widget for the ra8_widget tree model (#145 Phase 2).
Extracts the e-reader Library toolbar (a search field + a count chip) into a reusable ra8_widget leaf. The search-field rect is computed once by internal_tb_field_rect and shared between render (paint the bordered box + hint) and on_input (hit-test a tap), so the tap target is exactly the drawn field. Painting goes through the injected ra8_widget_paint_t backend, so the file carries no ra8_gfx dependency and the whole thing is host-testable with a recording mock paint.
[Ring 5 / UI] {World: NS}
Definition in file ra8_widget_toolbar.c.
|
static |
Compute the search-field sub-rectangle inside a toolbar band.
The band is inset by pad on every side; the count chip reserves a fixed count_w (plus a pad gutter) on the right and the field fills the remaining width. Shared by render (draw the field) and on_input (hit-test a tap) so the drawn box and the tap target coincide.
| [in] | bar | Toolbar descriptor (non-NULL). |
| [in] | band | The toolbar widget rect (non-NULL). |
| rect | The inset field rectangle. |
bar and band are non-NULL. band. Definition at line 51 of file ra8_widget_toolbar.c.
References ra8_ui_rect_t::h, ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by internal_tb_on_input(), and internal_tb_render().
|
static |
Toolbar vtable input: latch a touch inside the search field.
A touch that lands inside the search-field rect bumps searches, self-invalidates fast (so only this band re-flushes), fires the optional on_search, and reports the event consumed. A tap outside the field, or a button event, is declined so it keeps routing.
| [in] | w | The toolbar widget (its ctx is a ra8_widget_toolbar_t). |
| [in] | ev | The event already routed to this toolbar. |
| true | ev was a touch inside the field and it latched. |
| false | Non-touch, a tap outside the field, or ctx is NULL. |
w and ev are non-NULL. w->ctx points at a valid toolbar descriptor or is NULL. Definition at line 131 of file ra8_widget_toolbar.c.
References internal_tb_field_rect(), k_ra8_widget_ev_touch, k_ra8_widget_refresh_fast, ra8_widget_event_t::kind, ra8_ui_rect_contains(), ra8_widget_invalidate(), ra8_widget_event_t::x, and ra8_widget_event_t::y.
|
static |
Toolbar vtable render: band fill, bordered field + hint, count chip.
Reads the ra8_widget_toolbar_t from w->ctx, fills the band with bg, draws the border-framed search field with its left-aligned hint, then the right-aligned count chip – each through the paint backend and only when a draw_text callback is present.
| [in] | w | The toolbar widget (its ctx is a ra8_widget_toolbar_t). |
w is non-NULL (guaranteed by ra8_widget_render_dirty). w->ctx points at a valid toolbar descriptor or is NULL. Definition at line 81 of file ra8_widget_toolbar.c.
References internal_tb_field_rect(), k_ra8_widget_align_left, k_ra8_widget_align_right, priv_widget_fill_box(), and priv_widget_text_pos().
|
nodiscard |
Bind a widget instance to a toolbar.
Wires w to render + route bar: sets its vtable to ra8_widget_toolbar_vtable, points its ctx at bar, and makes it visible. The caller still sets w's fixed / flex for its parent's layout.
| [in,out] | w | Widget to turn into a toolbar (non-NULL). |
| [in] | bar | Toolbar descriptor (non-NULL; outlives w's use). |
| k_ra8_ok | Bound; w renders + routes bar. |
| k_ra8_err_null_ptr | w or bar is NULL. |
w and bar are non-NULL. bar outlives every render / dispatch of w. w is left unchanged.Definition at line 164 of file ra8_widget_toolbar.c.
References k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_widget_toolbar_vtable(), and s_tag.
| const ra8_widget_vtable_t * ra8_widget_toolbar_vtable | ( | void | ) |
Return the shared vtable backing every toolbar widget.
One immutable vtable serves all toolbars: render fills the band, the bordered search field + hint, and the count chip through the toolbar's ra8_widget_paint_t; on_input latches a touch inside the search field and declines everything else; measure is NULL. ra8_widget_toolbar_init binds it.
Definition at line 159 of file ra8_widget_toolbar.c.
References s_tb_vt.
Referenced by ra8_widget_toolbar_init(), and wd_build_tree().
|
static |
Logging / check tag.
Definition at line 31 of file ra8_widget_toolbar.c.
|
static |
The single immutable vtable shared by every toolbar.
Definition at line 153 of file ra8_widget_toolbar.c.
Referenced by ra8_widget_toolbar_vtable().