ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_widget_label.c File Reference

Text-label leaf widget for the ra8_widget tree model (#145 Phase 2). More...

#include "ra8_check.h"
#include "ra8_widget.h"
#include "ra8_widget_internal.h"
Include dependency graph for ra8_widget_label.c:

Go to the source code of this file.

Enumerations

enum  ra8_widget_label_geom_t : int16_t { k_ra8_widget_label_no_border = 0 }
 No border on a plain label – a single background fill. More...

Functions

static void internal_label_render (ra8_widget_t *w)
 Label vtable render: fill the background, then draw the aligned text.
const ra8_widget_vtable_tra8_widget_label_vtable (void)
 Return the shared vtable backing every text-label widget.
ra8_err_t ra8_widget_label_init (ra8_widget_t *w, ra8_widget_label_t *label)
 Bind a widget instance to a text label.

Variables

static const char * s_tag = "ra8_widget_label"
 Logging / check tag.
static const ra8_widget_vtable_t s_label_vt
 The single immutable vtable shared by every text label.

Detailed Description

Text-label leaf widget for the ra8_widget tree model (#145 Phase 2).

The simplest concrete leaf the panel compositor can composite: a background fill plus an aligned string. Its render paints through the injected ra8_widget_paint_t backend (so the file stays free of any ra8_gfx dependency) and its vtable leaves on_input NULL because a label is purely display – it never consumes a touch. The geometry is delegated to the shared RA8_PRIV helpers in ra8_widget_paint.c, so a label is just "fill the box, place the text". Binding a widget with ra8_widget_label_init makes it a label that drops into any panel's child array.

[Ring 5 / UI] {World: NS}

Since
0.1.0

Definition in file ra8_widget_label.c.

Enumeration Type Documentation

◆ ra8_widget_label_geom_t

enum ra8_widget_label_geom_t : int16_t

No border on a plain label – a single background fill.

Passed as the border_w to priv_widget_fill_box so the label paints exactly one fill (no frame), unlike the bordered button.

Enumerator
k_ra8_widget_label_no_border 

RA8 widget label no border.

Definition at line 36 of file ra8_widget_label.c.

Function Documentation

◆ internal_label_render()

void internal_label_render ( ra8_widget_t * w)
static

Label vtable render: fill the background, then draw the aligned text.

Reads the ra8_widget_label_t from w->ctx, fills the rect with bg, then – when there is text and a draw_text backend – places it via priv_widget_text_pos and draws it. Each guard is a single condition so a missing backend / text is a safe no-op.

Parameters
[in]wThe label widget (its ctx is a ra8_widget_label_t).
Returns
Nothing.
Precondition
w is non-NULL (guaranteed by ra8_widget_render_dirty).
w->ctx points at a valid label descriptor or is NULL.
Postcondition
At most the background fill plus one text draw are issued.
No pixels are touched when the label has no paint backend.
Note
Not thread-safe.
Since
0.1.0

Definition at line 56 of file ra8_widget_label.c.

References k_ra8_widget_label_no_border, priv_widget_fill_box(), and priv_widget_text_pos().

◆ ra8_widget_label_init()

ra8_err_t ra8_widget_label_init ( ra8_widget_t * w,
ra8_widget_label_t * label )
nodiscard

Bind a widget instance to a text label.

Wires w to render label: sets its vtable to ra8_widget_label_vtable, points its ctx at label, and makes it visible. The caller still sets w's fixed / flex for its parent's layout.

Parameters
[in,out]wWidget to turn into a label (non-NULL).
[in]labelLabel descriptor (non-NULL; outlives w's use).
Returns
ra8_err_t
Return values
k_ra8_okBound; w renders label.
k_ra8_err_null_ptrw or label is NULL.
Precondition
w and label are non-NULL.
label outlives every render of w.
Postcondition
On success w->vt == ra8_widget_label_vtable(), w->ctx == label, w->visible == true.
On failure w is left unchanged.
Note
Not thread-safe.
See also
ra8_widget_label_vtable
Since
0.1.0

Definition at line 90 of file ra8_widget_label.c.

References k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_widget_label_vtable(), and s_tag.

Referenced by wk_build_tree().

◆ ra8_widget_label_vtable()

const ra8_widget_vtable_t * ra8_widget_label_vtable ( void )

Return the shared vtable backing every text-label widget.

One immutable vtable serves all labels: render fills the background and draws the aligned text through the label's ra8_widget_paint_t; measure and on_input are NULL (a label sizes from its parent's fixed/flex and never consumes input). ra8_widget_label_init binds it, so callers rarely need it directly – it is exposed for tests and hand-built widgets.

Returns
Non-NULL pointer to the static label vtable.
Precondition
None.
None.
Postcondition
The returned pointer is non-NULL and references static storage.
No state is modified.
Note
Pure; thread-safe (returns a pointer to immutable static data).
See also
ra8_widget_label_init
Since
0.1.0

Definition at line 85 of file ra8_widget_label.c.

References s_label_vt.

Referenced by ra8_widget_label_init().

Variable Documentation

◆ s_label_vt

const ra8_widget_vtable_t s_label_vt
static
Initial value:
= {
.measure = nullptr,
.on_input = nullptr,
}
static void internal_label_render(ra8_widget_t *w)
Label vtable render: fill the background, then draw the aligned text.

The single immutable vtable shared by every text label.

Definition at line 79 of file ra8_widget_label.c.

Referenced by ra8_widget_label_vtable().

◆ s_tag

const char* s_tag = "ra8_widget_label"
static

Logging / check tag.

Definition at line 29 of file ra8_widget_label.c.