CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
host_api_canvas.cpp File Reference

extern-C adapter for the plugin canvas view. More...

#include "plugin_manager/PluginUiState.h"
#include "plugin_manager/host_api.h"
#include "cdc_views/CanvasView.h"
#include "cdc_views/Fonts.h"
#include "cdc_views/RenderHelpers.h"
#include "cdc_hal/IDisplay.h"
#include "host_str_conv.h"
#include <goodisplay/gdey029T94.h>
#include <cstring>
#include <string>

Go to the source code of this file.

Functions

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_body_size (uint16_t *w, uint16_t *h)
 Read the drawable body region (excluding header/footer).
int host_view_canvas_set_footer (const char *hint)
 Override the footer hint of the canvas.
int host_view_canvas_clear (void)
 Clear all draw state and widgets.
int host_view_canvas_set_text_size (uint8_t size)
 Set text size multiplier (Adafruit-GFX semantics).
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_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 in array order; sort them from largest to smallest. Falls back to the last entry when nothing fits.
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_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_draw_rect (int16_t x, int16_t y, int16_t w, int16_t h, bool filled)
 Draw a rectangle outline or filled rectangle.
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_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_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.
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_add_button (uint32_t widget_id)
 Add a focusable button widget bound to widget_id.
int host_view_canvas_remove_widget (uint32_t widget_id)
 Remove a widget previously added to the canvas.
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_value (uint32_t widget_id, int32_t *out)
 Read the integer value of a slider widget.
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_get_text (uint32_t widget_id, char *out, size_t cap)
 Read the text of a text-input widget.
int host_view_canvas_set_focus (uint32_t widget_id)
 Move keyboard focus to the given widget.
int host_view_canvas_get_focus (uint32_t *out)
 Read the currently focused widget id, 0 if none.
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_set_long_press_action (uint32_t action_id)
 Set the action id fired on a canvas long-press.

Detailed Description

extern-C adapter for the plugin canvas view.

Push a CanvasView, then forward draw/widget/focus calls to it. All state lives in PluginUiState / CanvasView; this TU only marshals C arguments.

Definition in file host_api_canvas.cpp.