23typedef enum : int32_t {
47 for (int32_t r = 0; r < rows; ++r) {
48 const uint32_t ci = (uint32_t)(
g_sh.toc_scroll + r);
49 if (ci >=
g_sh.chapter_count) {
53 const bool cur = (ci ==
g_sh.chapter);
86 const uint32_t ci = (uint32_t)(
g_sh.toc_scroll + row);
87 return (ci <
g_sh.chapter_count) ? (int32_t)ci : -1;
93 int32_t top =
g_sh.toc_scroll + (dir * rows);
94 const int32_t max = (int32_t)
g_sh.chapter_count - rows;
101 g_sh.toc_scroll = top;
Software 2D graphics primitives layered on top of a caller-ownedframebuffer (DRW / D/AVE 2D / GLCDC r...
ra8_err_t ra8_gfx_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_err_t ra8_gfx_text_out(int32_t x, int32_t y, const char *str, const ra8_gfx_font_t *font, uint32_t fg_color, uint32_t bg_color)
Render a NUL-terminated ASCII string.
ra8_err_t ra8_gfx_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color, bool filled)
Draw an axis-aligned rectangle.
Bitmap font descriptor + bundled font handles for ra8_gfx.
const ra8_gfx_font_t ra8_gfx_font_8x16
Bundled 8x16 IBM PC VGA bitmap font, ASCII 0x20..0x7E.
Shared contract for the ereader_shelf multi-screen e-reader.
int32_t sh_cells(int32_t pixels)
Cells of the 8px bitmap font that fit in pixels.
void sh_book_chapter_label(uint32_t chapter, char *out, size_t cap)
Resolve a chapter's TOC label (or "Chapter N") into out.
void sh_titlebar(const char *title, const char *right)
Fill the header bar and draw title left + optional right text.
@ k_sh_glyph_h
Bitmap font cell height.
@ k_sh_fb_h
Panel height in pixels.
@ k_sh_pad
Outer margin / content inset.
@ k_sh_bar_h
Header / title-bar height.
@ k_sh_linebuf
Per-line draw buffer bytes.
@ k_sh_toc_row_h
TOC list row height.
@ k_sh_fb_w
Panel width in pixels.
@ k_sh_dec_base
Decimal formatting base.
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.
sh_state_t g_sh
The single whole-app state instance (defined in main.c).
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 "..".
@ k_sh_col_edge
Card / image border.
@ k_sh_col_rowhi
TOC selected-row fill.
@ k_sh_col_card
Card / page fill (paper).
@ k_sh_col_sub
Secondary ink (author / hints).
void sh_toc_scroll(int32_t dir)
Scroll the TOC list by dir pages (-1 up / +1 down), clamped.
static int32_t sh_toc_visible_rows(void)
Rows of the chapter list visible at once.
void sh_toc_render(void)
Render the open book's chapter list (TOC).
sh_toc_const_t
TOC layout constants.
@ k_sh_toc_text_pad
Row text inset.
@ k_sh_toc_num_w
Chapter-number column width.
int32_t sh_toc_hit(int32_t x, int32_t y)
Hit-test a TOC tap; returns the chapter index or -1.
static void sh_toc_label(uint32_t idx, char *buf, size_t cap)
Resolve chapter idx's display label into buf (cap bytes), truncated.