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

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

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

Go to the source code of this file.

Enumerations

enum  ra8_widget_sb_geom_t : int16_t { k_ra8_widget_sb_no_rule = 0 }
 No hairline: a rule_h at or below this draws no bottom rule. More...

Functions

static void internal_sb_label (const ra8_widget_paint_t *paint, const ra8_ui_rect_t *rect, const char *text, int16_t pad, ra8_widget_align_t align, uint32_t fg, uint32_t bg)
 Draw one aligned label on the status band through the paint backend.
static void internal_sb_render (ra8_widget_t *w)
 Status-bar vtable render: fill, left + right labels, bottom hairline.
const ra8_widget_vtable_tra8_widget_status_bar_vtable (void)
 Return the shared vtable backing every status-bar widget.
ra8_err_t ra8_widget_status_bar_init (ra8_widget_t *w, ra8_widget_status_bar_t *bar)
 Bind a widget instance to a status bar.

Variables

static const char * s_tag = "ra8_widget_status_bar"
 Logging / check tag.
static const ra8_widget_vtable_t s_sb_vt
 The single immutable vtable shared by every status bar.

Detailed Description

Status-bar leaf widget for the ra8_widget tree model (#145 Phase 2).

Extracts the e-reader top band into a reusable ra8_widget leaf: a background fill, a left-aligned + a right-aligned label, and a bottom hairline rule, all painted through the injected ra8_widget_paint_t backend so the file carries no ra8_gfx dependency. Text placement reuses the shared RA8_PRIV priv_widget_text_pos helper (left / right alignment, vertical centring when the backend can measure). Display-only: the vtable leaves on_input NULL.

[Ring 5 / UI] {World: NS}

Since
0.1.0

Definition in file ra8_widget_status_bar.c.

Enumeration Type Documentation

◆ ra8_widget_sb_geom_t

enum ra8_widget_sb_geom_t : int16_t

No hairline: a rule_h at or below this draws no bottom rule.

Enumerator
k_ra8_widget_sb_no_rule 

Threshold below which the rule is skipped.

Definition at line 34 of file ra8_widget_status_bar.c.

Function Documentation

◆ internal_sb_label()

void internal_sb_label ( const ra8_widget_paint_t * paint,
const ra8_ui_rect_t * rect,
const char * text,
int16_t pad,
ra8_widget_align_t align,
uint32_t fg,
uint32_t bg )
static

Draw one aligned label on the status band through the paint backend.

Places text at align within rect via priv_widget_text_pos and draws it. A NULL text or a NULL draw_text backend is a no-op, so the left / right labels share one branch-coverable helper.

Parameters
[in]paintDraw backend (non-NULL).
[in]rectThe band rectangle the text sits inside (non-NULL).
[in]textNUL-terminated ASCII, or NULL to draw nothing.
[in]padInner inset from the rect edges, pixels.
[in]alignHorizontal alignment (left / right).
[in]fgText colour, 0xRRGGBB.
[in]bgBackground colour drawn behind the glyphs, 0xRRGGBB.
Returns
Nothing.
Precondition
paint and rect are non-NULL.
text is NUL-terminated or NULL.
Postcondition
At most one draw_text call is issued.
No draw call is issued when text or draw_text is NULL.
Note
Not thread-safe.
Since
0.1.0

Definition at line 59 of file ra8_widget_status_bar.c.

References priv_widget_text_pos().

Referenced by internal_sb_render().

◆ internal_sb_render()

void internal_sb_render ( ra8_widget_t * w)
static

Status-bar vtable render: fill, left + right labels, bottom hairline.

Reads the ra8_widget_status_bar_t from w->ctx, fills the rect with bg, draws the two labels via internal_sb_label, then – when rule_h > 0 – fills a rule strip along the band's bottom edge. A missing paint backend / fill_rect callback keeps drawing safe.

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

Definition at line 95 of file ra8_widget_status_bar.c.

References ra8_ui_rect_t::h, internal_sb_label(), k_ra8_widget_align_left, k_ra8_widget_align_right, k_ra8_widget_sb_no_rule, priv_widget_fill_box(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

◆ ra8_widget_status_bar_init()

ra8_err_t ra8_widget_status_bar_init ( ra8_widget_t * w,
ra8_widget_status_bar_t * bar )
nodiscard

Bind a widget instance to a status bar.

Wires w to render bar: sets its vtable to ra8_widget_status_bar_vtable, points its ctx at bar, 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 status bar (non-NULL).
[in]barStatus-bar descriptor (non-NULL; outlives w's use).
Returns
ra8_err_t
Return values
k_ra8_okBound; w renders bar.
k_ra8_err_null_ptrw or bar is NULL.
Precondition
w and bar are non-NULL.
bar outlives every render of w.
Postcondition
On success w->vt == ra8_widget_status_bar_vtable(), w->ctx == bar, w->visible == true.
On failure w is left unchanged.
Note
Not thread-safe.
See also
ra8_widget_status_bar_vtable
Since
0.1.0

Definition at line 140 of file ra8_widget_status_bar.c.

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

◆ ra8_widget_status_bar_vtable()

const ra8_widget_vtable_t * ra8_widget_status_bar_vtable ( void )

Return the shared vtable backing every status-bar widget.

One immutable vtable serves all status bars: render fills the background, draws the left + right labels and the bottom hairline through the bar's ra8_widget_paint_t; measure and on_input are NULL (a status bar sizes from its parent's fixed/flex and never consumes input). ra8_widget_status_bar_init binds it, so callers rarely need it directly.

Returns
Non-NULL pointer to the static status-bar 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_status_bar_init
Since
0.1.0

Definition at line 135 of file ra8_widget_status_bar.c.

References s_sb_vt.

Referenced by ra8_widget_status_bar_init(), and wd_build_tree().

Variable Documentation

◆ s_sb_vt

const ra8_widget_vtable_t s_sb_vt
static
Initial value:
= {
.measure = nullptr,
.render = internal_sb_render,
.on_input = nullptr,
}
static void internal_sb_render(ra8_widget_t *w)
Status-bar vtable render: fill, left + right labels, bottom hairline.

The single immutable vtable shared by every status bar.

Definition at line 129 of file ra8_widget_status_bar.c.

Referenced by ra8_widget_status_bar_vtable().

◆ s_tag

const char* s_tag = "ra8_widget_status_bar"
static

Logging / check tag.

Definition at line 29 of file ra8_widget_status_bar.c.