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

Small shared drawing + formatting helpers for ereader_shelf. More...

#include <string.h>
#include "ra8_gfx.h"
#include "ra8_gfx_font.h"
#include "sh_app.h"
Include dependency graph for sh_util.c:

Go to the source code of this file.

Enumerations

enum  sh_util_const_t : uint32_t { k_sh_ellipsis_min = 2U }
 Local layout constants. More...

Functions

int32_t sh_cells (int32_t pixels)
 Cells of the 8px bitmap font that fit in pixels.
void sh_fit (char *dst, size_t cap, const char *src, int32_t max_chars)
 Copy src into dst (cap bytes), truncating past max_chars with "..".
size_t sh_fmt_uint (char *dst, size_t pos, uint32_t v)
 Append unsigned v as decimal into dst at pos; returns new pos.
void sh_border (ra8_ui_rect_t r, uint32_t colour, int32_t width)
 Draw a width-thick rectangle outline in colour.
void sh_titlebar (const char *title, const char *right)
 Fill the header bar and draw title left + optional right text.

Detailed Description

Small shared drawing + formatting helpers for ereader_shelf.

Text/measure/format primitives every screen reuses: bitmap-font cell math, ellipsis truncation, decimal formatting, rectangle outlines, and the common header bar. All drawing goes through ra8_gfx into the bound framebuffer.

[Ring 6 / App] {World: NS}

Since
0.1.0

Definition in file sh_util.c.

Enumeration Type Documentation

◆ sh_util_const_t

enum sh_util_const_t : uint32_t

Local layout constants.

Enumerator
k_sh_ellipsis_min 

Chars kept before the ".." truncation.

Definition at line 24 of file sh_util.c.

Function Documentation

◆ sh_border()

void sh_border ( ra8_ui_rect_t r,
uint32_t colour,
int32_t width )

Draw a width-thick rectangle outline in colour.

Definition at line 69 of file sh_util.c.

References ra8_ui_rect_t::h, ra8_gfx_rect(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by sh_draw_card(), and sh_loupe_chrome().

◆ sh_cells()

int32_t sh_cells ( int32_t pixels)

Cells of the 8px bitmap font that fit in pixels.

Definition at line 28 of file sh_util.c.

References k_sh_glyph_w.

Referenced by sh_cover_render(), sh_draw_card(), sh_reader_load_chapter(), and sh_toc_label().

◆ sh_fit()

void sh_fit ( char * dst,
size_t cap,
const char * src,
int32_t max_chars )

Copy src into dst (cap bytes), truncating past max_chars with "..".

Definition at line 33 of file sh_util.c.

References k_sh_ellipsis_min, memcpy(), and strlen().

Referenced by sh_cover_render(), sh_draw_card(), and sh_toc_label().

◆ sh_fmt_uint()

size_t sh_fmt_uint ( char * dst,
size_t pos,
uint32_t v )

Append unsigned v as decimal into dst at pos; returns new pos.

Definition at line 52 of file sh_util.c.

References k_sh_dec_base.

Referenced by sh_book_chapter_label(), sh_comic_append_banner(), sh_comic_render(), sh_print_banner(), sh_reader_render(), and sh_toc_render().

◆ sh_titlebar()

void sh_titlebar ( const char * title,
const char * right )

Fill the header bar and draw title left + optional right text.

Definition at line 76 of file sh_util.c.

References k_sh_bar_h, k_sh_col_bar, k_sh_col_barfg, k_sh_fb_w, k_sh_glyph_h, k_sh_glyph_w, k_sh_pad, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), and strlen().

Referenced by sh_comic_render(), sh_cover_render(), sh_reader_render(), sh_shelf_render(), and sh_toc_render().