28typedef enum : uint32_t {
39 g_sh.thumb_w[idx] = 0U;
40 g_sh.thumb_h[idx] = 0U;
57 g_sh.thumb_w[idx] = (uint16_t)w;
58 g_sh.thumb_h[idx] = (uint16_t)h;
67 for (uint16_t i = 0U; i <
g_sh.book_count; ++i) {
83 const bool sel = (idx ==
g_sh.selected);
90 const int32_t tw = (int32_t)
g_sh.thumb_w[idx];
91 const int32_t th = (int32_t)
g_sh.thumb_h[idx];
92 const int32_t cx = r.
x + ((r.
w - tw) / (int32_t)
k_sh_two);
139 for (uint16_t i = 0U; i <
g_sh.book_count; ++i) {
154 for (uint16_t i = 0U; i <
g_sh.book_count; ++i) {
155 g_sh.card_rect[i] = store[(size_t)gi + 1U + (
size_t)i].
rect;
157 return g_sh.book_count;
165 for (uint16_t i = 0U; i < n; ++i) {
172 for (uint16_t i = 0U; i <
g_sh.book_count; ++i) {
174 if ((x >= r.
x) && (x < (r.
x + r.
w)) && (y >= r.
y) && (y < (r.
y + r.
h))) {
@ k_book_nil
Absent index / "applies to all chapters".
Bounded, allocation-free box-model layout for e-reader chrome.
ra8_err_t ra8_box_tree_init(ra8_box_tree_t *tree, ra8_box_t *storage, uint16_t cap)
Bind a tree builder to caller-owned node storage.
ra8_err_t ra8_box_layout(ra8_box_tree_t *tree, int16_t root, const ra8_ui_rect_t *frame)
Lay out the tree, filling every node's rect.
@ k_ra8_box_none
No child / no sibling link.
int16_t ra8_box_add(ra8_box_tree_t *tree, int16_t parent, const ra8_box_t *node)
Append a node and link it as a child of parent.
@ k_ra8_box_grid
Fixed-column grid, row-major.
@ k_ra8_box_leaf
Terminal box (no children laid out).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
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.
ra8_err_t sh_image_decode_gray8(const book_src_t *src, uint32_t img_idx, uint8_t *out, int32_t box_w, int32_t box_h, int32_t *out_w, int32_t *out_h)
Decode a 4bpp grayscale image, aspect-fit-scale it into box, and write the result into a gray8 buffer...
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.
@ k_sh_gap
Gap between shelf cards.
@ k_sh_thumb_h
Shelf cover-thumbnail box height.
@ 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_thumb_w
Shelf cover-thumbnail box width.
@ k_sh_bar_h
Header / title-bar height.
@ k_sh_linebuf
Per-line draw buffer bytes.
@ k_sh_fb_w
Panel width in pixels.
@ k_sh_grid_cols
Shelf grid columns.
@ k_sh_card_pad
Inner card inset.
void sh_image_blit_gray8(const uint8_t *src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y)
Blit a gray8 bitmap to the bound framebuffer at dst_x, dst_y.
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_card_hi
Selected card fill.
@ k_sh_col_bg
App background (dark wood).
@ k_sh_col_card
Card / page fill (paper).
@ k_sh_col_sub
Secondary ink (author / hints).
@ k_sh_col_sel
Selection accent (amber).
@ k_sh_two
Centring divisor / half-extent divisor.
void sh_decode_cover(uint16_t idx, const book_src_t *src)
Decode the open rabook source's 4bpp cover into thumbnail slot idx.
void sh_shelf_build_thumbs(void)
Copy the baked books' pre-decoded covers into sh_state_t::thumb at boot.
static uint16_t sh_layout_cards(void)
Lay out the shelf grid into sh_state_t::card_rect; returns count placed.
int32_t sh_shelf_hit(int32_t x, int32_t y)
Hit-test a shelf tap; returns the book index or -1.
static void sh_draw_card(ra8_ui_rect_t r, uint16_t idx)
Draw one book card: cover thumbnail (or placeholder) + title + author.
sh_shelf_const_t
Shelf-layout constants.
@ k_sh_sel_border
Selected card border width.
@ k_sh_title_gap
Cover-to-title vertical gap.
@ k_sh_box_cap
ra8_box scratch node capacity.
@ k_sh_card_h
Card height (cover box + 2 text lines + insets).
@ k_sh_card_bord
Idle card border width.
void sh_shelf_render(void)
Render the shelf grid (cover cards) into the framebuffer.
A book data source: resident (zero-copy) or paged (demand-fetched).
book_header_t hdr
Resident copy of the blob header.
One node in a box tree (caller-owned).
ra8_ui_rect_t rect
OUTPUT: computed rectangle.
Append-only builder over caller-owned node storage.
Axis-aligned rectangle in framebuffer pixel coordinates.
int32_t w
Width (pixels, >= 0).
int32_t h
Height (pixels, >= 0).
int32_t x
Left edge (pixels).
int32_t y
Top edge (pixels).
One shelf book, sourced from MRAM (baked) or the SD card, in either the .rabook or ....
bool from_sd
true: read sd_name from SD; false: use blob.
uint16_t thumb_w
Pre-baked thumbnail width.
uint16_t thumb_h
Pre-baked thumbnail height.
const uint8_t * thumb
Pre-baked gray8 cover thumbnail, or NULL.