16#include <goodisplay/gdey029T94.h>
32 uint32_t widget_action_id)
35 .
pushCanvas(title, key_action_id, widget_action_id);
71 c->setTextInverted(inverted);
80 c->setFontId(font_id);
85 const uint8_t* candidates, uint32_t count,
88 if (!text || !candidates || !out_font_id || count == 0) {
93 auto* gfx =
static_cast<Gdey029T94*
>(display->getNativeHandle());
99 for (uint32_t i = 0; i < count; ++i) {
103 gfx, cp.c_str(), max_width_px, candFonts, count,
false);
105 uint8_t pickedId = candidates[count - 1];
106 for (uint32_t i = 0; i < count; ++i) {
107 if (candFonts[i] == picked) {
108 pickedId = candidates[i];
112 *out_font_id = pickedId;
125 const char* text, uint8_t align)
137 c->drawRect(x, y, w, h, filled);
145 c->invertRect(x, y, w, h);
153 c->drawHLine(x, y, w);
161 c->drawVLine(x, y, h);
169 c->commit(full_refresh);
174 int32_t initial, int32_t step)
186 return c->addText(widget_id, max_len, initial ? cp.c_str() :
nullptr)
233 int n = c->getText(widget_id, &tmp[0], cap);
235 tmp.resize(std::strlen(tmp.c_str()));
250 *out = c->getFocus();
258 c->setKeyRepeat(initial_ms, repeat_ms);
Singleton that owns plugin-pushed UI views (lists, confirms, inputs).
int setCanvasLongPressAction(uint32_t action_id)
int pushCanvas(const char *title, uint32_t key_action_id, uint32_t widget_action_id)
int setViewFooter(const char *hint)
cdc::ui::CanvasView * canvasView()
static PluginUiState & instance() noexcept
Generic canvas view exposed to WASM plugins for custom UIs.
int host_view_canvas_get_value(uint32_t widget_id, int32_t *out)
Read the integer value of a slider widget.
int host_view_canvas_invert_rect(int16_t x, int16_t y, int16_t w, int16_t h)
Invert all pixels inside the rectangle.
int host_view_canvas_push(const char *title, uint32_t key_action_id, uint32_t widget_action_id)
Push a new canvas view.
int host_view_canvas_get_focus(uint32_t *out)
Read the currently focused widget id, 0 if none.
int host_view_canvas_hline(int16_t x, int16_t y, int16_t w)
Draw a horizontal line.
int host_view_canvas_vline(int16_t x, int16_t y, int16_t h)
Draw a vertical line.
int host_view_canvas_clear(void)
Clear all draw state and widgets.
int host_view_canvas_draw_rect(int16_t x, int16_t y, int16_t w, int16_t h, bool filled)
Draw a rectangle outline or filled rectangle.
#define HOST_FONT_COUNT
Number of defined font ids.
int host_view_canvas_set_text_color(bool inverted)
Switch between normal and inverted (white on black) text.
int host_view_canvas_set_font(uint8_t font_id)
Switch the canvas font to one of the canonical HOST_FONT_* ids.
int host_view_canvas_add_button(uint32_t widget_id)
Add a focusable button widget bound to widget_id.
int host_view_canvas_set_focus(uint32_t widget_id)
Move keyboard focus to the given widget.
int host_view_canvas_get_text(uint32_t widget_id, char *out, size_t cap)
Read the text of a text-input widget.
int host_view_canvas_set_text_size(uint8_t size)
Set text size multiplier (Adafruit-GFX semantics).
int host_view_canvas_set_key_repeat(uint16_t initial_ms, uint16_t repeat_ms)
Configure key auto-repeat timing for the canvas.
int host_view_canvas_draw_text_aligned(int16_t x, int16_t y, int16_t w, const char *text, uint8_t align)
Draw text within a horizontal box.
int host_view_canvas_set_footer(const char *hint)
Override the footer hint of the canvas.
int host_view_canvas_draw_text(int16_t x, int16_t y, const char *text)
Draw text at (x, y) using the current text size/colour.
int host_view_canvas_remove_widget(uint32_t widget_id)
Remove a widget previously added to the canvas.
int host_text_pick_font_that_fits(const char *text, int16_t max_width_px, const uint8_t *candidates, uint32_t count, uint8_t *out_font_id)
Pick the largest HOST_FONT_* whose rendered text fits within max_width_px. Candidates are evaluated i...
int host_view_canvas_add_text(uint32_t widget_id, uint16_t max_len, const char *initial)
Add a T9 text input widget bound to widget_id.
int host_view_canvas_set_text(uint32_t widget_id, const char *text)
Set the text of a text-input widget.
int host_view_canvas_set_long_press_action(uint32_t action_id)
Set the action id fired on a canvas long-press.
int host_view_canvas_set_value(uint32_t widget_id, int32_t value)
Set the integer value of a slider widget.
int host_view_canvas_get_body_size(uint16_t *w, uint16_t *h)
Read the drawable body region (excluding header/footer).
int host_view_canvas_commit(bool full_refresh)
Flush draw state to the panel.
int host_view_canvas_add_slider(uint32_t widget_id, int32_t min, int32_t max, int32_t initial, int32_t step)
Add an integer slider widget bound to widget_id.
CDC Badge OS plugin host API - canonical C ABI contract.
#define HOST_ERR_INVALID_ARG
#define HOST_ERR_NOT_FOUND
Internal UTF-8 <-> CP437 helpers for the plugin host API boundary.
IDisplay * getDisplayInstance()
Returns lazily created singleton display instance.
std::string toDisplay(const char *utf8)
Decode a UTF-8 (with optional HTML entities) string into CP437 bytes.
int copyUtf8(const char *cp437, char *out, size_t out_size)
Encode a CP437 string into a caller buffer as UTF-8.
const GFXfont * pickFontThatFits(Gdey029T94 *gfx, const char *text, int maxWidthPx, const GFXfont *const *candidates, size_t count, bool cp437=false)
Picks the largest font from candidates whose rendered width of text fits within maxWidthPx....
const GFXfont * getGfxFont(FontId id)
Resolves a FontId to its underlying GFX font pointer.