ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_widget_progress_bar.c
Go to the documentation of this file.
1
22
24
25#include "ra8_check.h"
26#include "ra8_widget.h"
27#include "ra8_widget_internal.h"
28
30static const char* s_tag = "ra8_widget_progress_bar";
31
35typedef enum : int32_t {
38
56{
58 if (pb == nullptr) {
59 return;
60 }
61 if (pb->paint == nullptr) {
62 return;
63 }
64 if (pb->paint->fill_rect == nullptr) {
65 return;
66 }
67 const ra8_ui_rect_t* r = &w->rect;
68 pb->paint->fill_rect(pb->paint->user, r->x, r->y, r->w, r->h, pb->track);
69 const int32_t fw = priv_widget_fill_frac(pb->value, pb->total, r->w);
70 if (fw > (int32_t)k_ra8_widget_pb_empty) {
71 pb->paint->fill_rect(pb->paint->user, r->x, r->y, fw, r->h, pb->fill);
72 }
73}
74
77 .measure = nullptr,
78 .render = internal_pb_render,
79 .on_input = nullptr,
80};
81
86
89{
90 RA8_CHECK_NULL_PTR(w, s_tag, "w must not be nullptr");
91 RA8_CHECK_NULL_PTR(bar, s_tag, "bar must not be nullptr");
93 w->ctx = bar;
94 w->visible = true;
95 return k_ra8_ok;
96}
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.
int32_t priv_widget_fill_frac(uint32_t value, uint32_t total, int32_t width)
Filled width in pixels for a value / total bar spanning width.
static void internal_pb_render(ra8_widget_t *w)
Progress-bar vtable render: fill the track, then the proportional fill.
static const ra8_widget_vtable_t s_pb_vt
The single immutable vtable shared by every progress bar.
ra8_err_t ra8_widget_progress_bar_init(ra8_widget_t *w, ra8_widget_progress_bar_t *bar)
Bind a widget instance to a progress bar.
const ra8_widget_vtable_t * ra8_widget_progress_bar_vtable(void)
Return the shared vtable backing every progress-bar widget.
ra8_widget_pb_geom_t
Empty-bar sentinel: at or below this fill width, no fill is painted.
@ k_ra8_widget_pb_empty
No filled pixels (0% or degenerate rect).
Progress-bar leaf widget for the ra8_widget tree model (#145 Phase 2).
Axis-aligned rectangle in framebuffer pixel coordinates.
Definition ra8_ui.h:72
int32_t w
Width (pixels, >= 0).
Definition ra8_ui.h:75
int32_t h
Height (pixels, >= 0).
Definition ra8_ui.h:76
int32_t x
Left edge (pixels).
Definition ra8_ui.h:73
int32_t y
Top edge (pixels).
Definition ra8_ui.h:74
A proportional progress bar: a track plus a value / total fill.
One widget instance (caller-owned, no allocation).
Behaviour table shared by all widgets of one kind.
Definition ra8_widget.h:121