ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_widget_label.c
Go to the documentation of this file.
1
23
24#include "ra8_check.h"
25#include "ra8_widget.h"
26#include "ra8_widget_internal.h"
27
29static const char* s_tag = "ra8_widget_label";
30
39
57{
59 if (l == nullptr) {
60 return;
61 }
62 if (l->paint == nullptr) {
63 return;
64 }
65 priv_widget_fill_box(l->paint, &w->rect, l->bg, l->bg, (int16_t)k_ra8_widget_label_no_border);
66 if (l->text == nullptr) {
67 return;
68 }
69 if (l->paint->draw_text == nullptr) {
70 return;
71 }
72 int32_t tx = 0;
73 int32_t ty = 0;
74 priv_widget_text_pos(l->paint, &w->rect, l->text, l->pad, l->align, &tx, &ty);
75 l->paint->draw_text(l->paint->user, tx, ty, l->text, l->fg, l->bg);
76}
77
80 .measure = nullptr,
81 .render = internal_label_render,
82 .on_input = nullptr,
83};
84
89
91{
92 RA8_CHECK_NULL_PTR(w, s_tag, "w must not be nullptr");
93 RA8_CHECK_NULL_PTR(label, s_tag, "label must not be nullptr");
95 w->ctx = label;
96 w->visible = true;
97 return k_ra8_ok;
98}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
#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_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.
Module-private paint helpers shared by the concrete leaf-widget TUs.
void priv_widget_fill_box(const ra8_widget_paint_t *paint, const ra8_ui_rect_t *rect, uint32_t fill, uint32_t border, int16_t border_w)
Fill a widget rect with an optional 1-or-more-pixel border.
void priv_widget_text_pos(const ra8_widget_paint_t *paint, const ra8_ui_rect_t *rect, const char *text, int16_t pad, ra8_widget_align_t align, int32_t *out_x, int32_t *out_y)
Compute where a leaf widget's text should start within its rect.
static const ra8_widget_vtable_t s_label_vt
The single immutable vtable shared by every text label.
ra8_err_t ra8_widget_label_init(ra8_widget_t *w, ra8_widget_label_t *label)
Bind a widget instance to a text label.
const ra8_widget_vtable_t * ra8_widget_label_vtable(void)
Return the shared vtable backing every text-label widget.
static void internal_label_render(ra8_widget_t *w)
Label vtable render: fill the background, then draw the aligned text.
ra8_widget_label_geom_t
No border on a plain label – a single background fill.
@ k_ra8_widget_label_no_border
RA8 widget label no border.
A text-label leaf widget: a background fill plus an aligned string.
One widget instance (caller-owned, no allocation).
Behaviour table shared by all widgets of one kind.
Definition ra8_widget.h:121