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

E-reader UI chrome – Library + Reading rendering and in-content nav. More...

#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "er_pageturn.h"
#include "ereader_ui_steps.h"
#include "figure_fixture.h"
#include "ra8_box.h"
#include "ra8_err.h"
#include "ra8_gfx.h"
#include "ra8_gfx_font.h"
#include "ra8_glyph_atlas.h"
#include "ra8_ui.h"
#include "ra8_widget.h"
#include "reflow.h"
#include "reflow_image.h"
Include dependency graph for ereader_ui_screens.c:

Go to the source code of this file.

Enumerations

enum  er_svg_len_t : uint32_t {
  k_er_logo_svg_len = (uint32_t)(sizeof(k_er_logo_svg) - 1U) ,
  k_er_ext_len = 4U
}
 SVG fixture size + the .svg extension length for href routing. More...
enum  er_filter_t : uint32_t { k_er_match_scan_max = 256U }
 Search-filter scan bound (NASA Rule 2). More...

Functions

static ra8_err_t er_image_loader (void *ctx, const char *href, uint32_t href_len, const uint8_t **out_bytes, size_t *out_len)
 reflow image loader: resolve any <img src> to the baked figure.
void er_text_left (int32_t x, int32_t y, const char *str, uint32_t color)
 Draw a left-anchored text run in the bundled font.
void er_text_right (int32_t right, int32_t y, const char *str, uint32_t color)
 Draw a right-anchored text run ending at column right.
static void er_reset_side_tables (void)
 Reset the per-node label / progress side tables.
static ra8_box_t er_leaf (int16_t fixed, uint16_t flex, uint32_t fill, uint32_t border)
 Make a leaf box template carrying fill / border.
static ra8_box_t er_container (ra8_box_kind_t kind, int16_t fixed, int16_t pad, int16_t gap, uint8_t cols)
 Make a container box template (stack or grid).
static void er_build_toolbar (ra8_box_tree_t *tree, int16_t parent)
 Add the toolbar (search field + book-count chip) under a parent.
static void er_add_book_tile (ra8_box_tree_t *tree, int16_t grid, const er_book_t *book)
 Add one book card (cover, title, author, progress) under a grid.
static void er_build_nav (ra8_box_tree_t *tree, int16_t parent)
 Add the bottom navigation strip under a parent.
static char er_lc (char c)
 Lower-case an ASCII letter (identity for non-letters).
static bool er_ci_contains (const char *hay, const char *needle)
 Case-insensitive: does needle occur within hay?
static bool er_book_matches (const er_book_t *book)
 Does book pass the committed search query (true if no filter)?
static void er_build_library (ra8_box_tree_t *tree, const ra8_ui_rect_t *frame)
 Build the Library box tree (status bar, toolbar, grid, nav).
static void er_render_boxnodes (uint16_t from, uint16_t to)
 Render box nodes [from, to) of s_nodes (fills, borders, progress bars, labels).
static void er_collect_targets (const ra8_box_tree_t *tree)
 Collect tap targets from a laid-out tree's tagged nodes.
static void er_lib_sb_render (ra8_widget_t *w)
 Render the full Library screen.
static void er_lib_body_render (ra8_widget_t *w)
 Body band widget: toolbar + book grid + nav nodes + the above-nav rule.
void er_render_library (void)
 Render the full Library screen.
static void er_bind_glyph_atlas (void)
 Bind the Layer-3 glyph atlas (#164) to the reflow engine.
static bool er_reflow_relayout (int32_t body_w, int32_t body_h, const uint8_t *font_data, uint32_t font_len)
 Re-init the reflow engine and lay the current chapter into the cache.
static bool er_draw_reading_body_reflow (int32_t body_top, int32_t height)
 Render the Reading body through reflow when an SD font is loaded.
static bool er_draw_reading_body (int32_t height)
 Paint the Reading body: reflowed text (SD or baked font), else bitmap.
static void er_read_sb_render (ra8_widget_t *w)
 Status-bar band widget: wordmark + book title + status-right + hairline.
static void er_read_body_render (ra8_widget_t *w)
 Body band widget: the reflowed (or bitmap-fallback) chapter text.
static void er_read_footer_render (ra8_widget_t *w)
 Footer band widget: rule + chapter title + page label + progress bar.
void er_render_reading (void)
 Render the full Reading screen (status bar, body, footer).
void er_push_loc (void)
 Push the current (chapter, page) on the back-stack, capacity permitting.
uint32_t er_spine_count (void)
 Number of chapters in the (mock) spine.
bool er_apply_pageturn (er_dir_t dir)
 Apply a page turn to the reading location (touch + button shared path).
static bool er_nav_fragment (uint32_t off, uint32_t frag_off, uint32_t frag_len)
 Follow a same-chapter #fragment: jump to the anchored page.
static bool er_nav_chapter (uint32_t off, uint32_t path_len)
 Follow a cross-chapter link: resolve the path against the mock spine.
bool er_reading_link_tap (int32_t x, int32_t y)
 Follow an in-content <a> tap in the Reading body (#110).

Variables

const uint8_t g_ra8_font_literata_latin1 []
 Baked Latin-1 font array (generated at build time).
const unsigned int g_ra8_font_literata_latin1_len
static ra8_box_t s_nodes [k_er_max_nodes]
 Box-tree node storage for chrome layout.
static const char * s_label [k_er_max_nodes]
 Per-node text label (NULL if the node draws no text).
static uint32_t s_label_col [k_er_max_nodes]
 Per-node text colour.
static int16_t s_progress [k_er_max_nodes]
 Per-node progress percent, or -1 for "not a progress bar".
static uint16_t s_lib_node_count
 Library box-node count (set by er_render_library for the band widgets).
static uint16_t s_lib_body_first = 2U
 First Library body box-node (root=0, status bar=1, body from here).
static const char k_er_logo_svg []
 In-content SVG (#112): a navy field, a gold disc, and a crimson block.
static const ra8_widget_vtable_t k_er_lib_sb_vt = {.render = er_lib_sb_render}
 Vtables for the Library status-bar / body band widgets.
static const ra8_widget_vtable_t k_er_lib_body_vt = {.render = er_lib_body_render}
static bool s_read_reflowed = false
 Stash: did the body band reflow live text?
static const ra8_widget_vtable_t k_er_read_sb_vt = {.render = er_read_sb_render}
 Vtables for the Reading status-bar / body / footer band widgets.
static const ra8_widget_vtable_t k_er_read_body_vt = {.render = er_read_body_render}
static const ra8_widget_vtable_t k_er_read_footer_vt = {.render = er_read_footer_render}

Detailed Description

E-reader UI chrome – Library + Reading rendering and in-content nav.

Tag
[Ring 6 / APP] {World: S}

Split out of ereader_ui/main.c to keep every translation unit under the repository's 1000-line cap (a pure code move). This unit owns the box-model Library screen (status bar, toolbar, book grid, bottom nav), the Reading screen (status bar, reflowed / bitmap-fallback body, footer), the shared bundled-font text helpers, and the in-content navigation that follows <a href> links and page turns across the mock spine. The composited chrome is byte-identical to the pre-split monolith.

Since
0.1.0

Definition in file ereader_ui_screens.c.

Enumeration Type Documentation

◆ er_filter_t

enum er_filter_t : uint32_t

Search-filter scan bound (NASA Rule 2).

Enumerator
k_er_match_scan_max 

Max title chars scanned for a match.

Definition at line 346 of file ereader_ui_screens.c.

◆ er_svg_len_t

enum er_svg_len_t : uint32_t

SVG fixture size + the .svg extension length for href routing.

Enumerator
k_er_logo_svg_len 

SVG byte count.

k_er_ext_len 

Length of ".svg".

Definition at line 79 of file ereader_ui_screens.c.

Function Documentation

◆ er_add_book_tile()

void er_add_book_tile ( ra8_box_tree_t * tree,
int16_t grid,
const er_book_t * book )
static

Add one book card (cover, title, author, progress) under a grid.

Parameters
[in,out]treeTree builder bound to s_nodes.
[in]gridGrid container index.
[in]bookBook to render in the card.
Precondition
tree references s_nodes; grid is a valid grid; book valid.
Side tables are reset.
Postcondition
A vertical card subtree is appended to grid.
The title/author labels and progress are recorded.
Note
Not thread-safe.
Since
0.1.0

Definition at line 286 of file ereader_ui_screens.c.

References er_book_t::author, er_container(), er_leaf(), k_er_act_open_book, k_er_card_bar_h, k_er_card_label_h, k_er_fill, k_er_ink, k_er_ink_muted, k_er_rule_soft, k_er_tile_gap, k_ra8_box_no_colour, k_ra8_box_stack_v, er_book_t::pct, ra8_box_add(), s_label, s_label_col, s_progress, ra8_box_t::tag, and er_book_t::title.

Referenced by er_build_library().

◆ er_apply_pageturn()

bool er_apply_pageturn ( er_dir_t dir)

Apply a page turn to the reading location (touch + button shared path).

Parameters
[in]dirDirection (k_er_dir_prev / k_er_dir_next / k_er_dir_none).
Returns
true iff the reading location changed (caller must re-render).
Return values
trueA page turn was applied.
falseNo turn (book end, or k_er_dir_none).
Precondition
The Reading view is active and a chapter is laid out (s_reading_pages).
s_chapter_idx / s_reading_page are the visible location.
Postcondition
On true the location advanced and s_pending_event reflects the kind.
On false no state changed.
Note
Not thread-safe.
Since
0.1.0

Definition at line 888 of file ereader_ui_screens.c.

References er_pageturn_step(), er_spine_count(), g_er_turns, k_display_event_chapter, k_display_event_turn, s_chapter_idx, s_pending_event, s_reading_page, and s_reading_pages.

Referenced by er_handle_reading_tap(), and er_poll_buttons().

◆ er_bind_glyph_atlas()

void er_bind_glyph_atlas ( void )
static

Bind the Layer-3 glyph atlas (#164) to the reflow engine.

A page turn re-renders the same body glyphs, so caching the rasterised bitmaps (cells in SDRAM, like the framebuffer + decode arena) avoids re-running stb_truetype every frame. Re-bound on each relayout (reflow_init zeroes the engine); the cache clears per chapter, the natural working-set boundary. Output is byte-identical to the direct path – oversized glyphs fall back to direct rasterisation. The caller-owned storage is function-static (single reflow engine, single-threaded UI loop).

Precondition
s_reflow_engine has been initialised by reflow_init().
The SDRAM .sdram_data section is mapped (post ra8_sdramc_init()).
Postcondition
s_reflow_engine renders body glyphs through the glyph cache.
The cache starts empty (re-init clears it).
Note
Not thread-safe.
Since
0.1.0

Definition at line 594 of file ereader_ui_screens.c.

References k_er_glyph_buckets, k_er_glyph_cell_bytes, k_er_glyph_cells, reflow_set_glyph_atlas(), and s_reflow_engine.

Referenced by er_reflow_relayout().

◆ er_book_matches()

bool er_book_matches ( const er_book_t * book)
static

Does book pass the committed search query (true if no filter)?

Definition at line 376 of file ereader_ui_screens.c.

References er_ci_contains(), s_query, and er_book_t::title.

Referenced by er_build_library().

◆ er_build_library()

void er_build_library ( ra8_box_tree_t * tree,
const ra8_ui_rect_t * frame )
static

Build the Library box tree (status bar, toolbar, grid, nav).

Parameters
[in,out]treeTree builder bound to s_nodes.
[in]frameScreen rectangle to lay out within.
Precondition
ra8_gfx is bound; tree references s_nodes.
s_book table populated.
Postcondition
tree holds the laid-out Library; side tables hold text/progress.
Every node has its rect computed.
Note
Not thread-safe.
Since
0.1.0

Definition at line 398 of file ereader_ui_screens.c.

References er_add_book_tile(), er_book_matches(), er_build_nav(), er_build_toolbar(), er_container(), er_leaf(), er_reset_side_tables(), k_er_book_count, k_er_books, k_er_grid_cols, k_er_grid_gap, k_er_lib_heading, k_er_max_nodes, k_er_pad_ui, k_er_statusbar_h, k_ra8_box_grid, k_ra8_box_no_colour, k_ra8_box_none, k_ra8_box_stack_v, ra8_box_add(), ra8_box_layout(), ra8_box_tree_init(), s_label, s_lib_body_first, and s_nodes.

Referenced by er_render_library().

◆ er_build_nav()

void er_build_nav ( ra8_box_tree_t * tree,
int16_t parent )
static

Add the bottom navigation strip under a parent.

Parameters
[in,out]treeTree builder bound to s_nodes.
[in]parentParent container index (the screen column).
Precondition
tree references s_nodes; parent is a valid container.
Side tables are reset.
Postcondition
A horizontal nav strip with one flex item per destination.
The active (first) item is inked, the rest muted.
Note
Not thread-safe.
Since
0.1.0

Definition at line 325 of file ereader_ui_screens.c.

References er_container(), er_leaf(), k_er_act_settings, k_er_ink, k_er_ink_muted, k_er_nav_count, k_er_nav_h, k_er_nav_idx_setting, k_er_nav_items, k_ra8_box_no_colour, k_ra8_box_stack_h, ra8_box_add(), s_label, s_label_col, and ra8_box_t::tag.

Referenced by er_build_library().

◆ er_build_toolbar()

void er_build_toolbar ( ra8_box_tree_t * tree,
int16_t parent )
static

Add the toolbar (search field + book-count chip) under a parent.

Parameters
[in,out]treeTree builder bound to s_nodes.
[in]parentParent container index (the screen column).
Precondition
tree references s_nodes; parent is a valid container.
Side tables are reset.
Postcondition
A horizontal toolbar with two children is appended.
Their labels/colours are recorded in the side tables.
Note
Not thread-safe.
Since
0.1.0

Definition at line 249 of file ereader_ui_screens.c.

References er_container(), er_leaf(), k_er_act_search, k_er_count_text, k_er_count_w, k_er_ink, k_er_ink_muted, k_er_pad_ui, k_er_search_hint, k_er_toolbar_h, k_ra8_box_no_colour, k_ra8_box_stack_h, ra8_box_add(), s_label, s_label_col, and ra8_box_t::tag.

Referenced by er_build_library().

◆ er_ci_contains()

bool er_ci_contains ( const char * hay,
const char * needle )
static

Case-insensitive: does needle occur within hay?

Definition at line 357 of file ereader_ui_screens.c.

References er_lc(), k_er_match_scan_max, and k_ra8_kbd_text_max.

Referenced by er_book_matches().

◆ er_collect_targets()

void er_collect_targets ( const ra8_box_tree_t * tree)
static

Collect tap targets from a laid-out tree's tagged nodes.

Parameters
[in]treeLaid-out box tree.
Precondition
tree is laid out.
None.
Postcondition
s_targets holds (rect, action) for each tagged node, capped.
s_target_count is the number collected.
Note
Not thread-safe.
Since
0.1.0

Definition at line 487 of file ereader_ui_screens.c.

References ra8_box_tree_t::count, k_er_max_targets, k_ra8_box_none, ra8_box_tree_t::nodes, ra8_box_t::rect, s_target_count, s_targets, and ra8_box_t::tag.

Referenced by er_render_library().

◆ er_container()

ra8_box_t er_container ( ra8_box_kind_t kind,
int16_t fixed,
int16_t pad,
int16_t gap,
uint8_t cols )
static

Make a container box template (stack or grid).

Parameters
[in]kindContainer kind.
[in]fixedFixed main-axis extent (0 => flex).
[in]padInner padding.
[in]gapGap between children.
[in]colsGrid columns (>= 1).
Returns
A container ra8_box_t template.
Return values
nodeConfigured container node template.
Precondition
kind is a container kind.
None.
Postcondition
Returned node has the requested kind / sizing / spacing.
Flex defaults to 1 so it fills its parent unless fixed is set.
Note
Pure.
Since
0.1.0

Definition at line 222 of file ereader_ui_screens.c.

References ra8_box_t::fixed, ra8_box_t::flex, ra8_box_t::gap, ra8_box_t::grid_cols, k_ra8_box_none, ra8_box_t::kind, ra8_box_t::pad, and ra8_box_t::tag.

Referenced by er_add_book_tile(), er_build_library(), er_build_nav(), and er_build_toolbar().

◆ er_draw_reading_body()

bool er_draw_reading_body ( int32_t height)
static

Paint the Reading body: reflowed text (SD or baked font), else bitmap.

Parameters
[in]heightFramebuffer height in pixels.
Returns
true if the body was reflowed (paginated); false on the bitmap fallback.
Return values
truereflow painted the current page (SD font or the baked font).
falseThe bundled bitmap lines were drawn (reflow-engine failure).
Precondition
ra8_gfx is bound.
height matches the bound framebuffer.
Postcondition
The body band holds reflowed text or the bitmap fallback.
Drawing stops before the footer band.
Note
Not thread-safe.
Since
0.1.0

Definition at line 758 of file ereader_ui_screens.c.

References er_draw_reading_body_reflow(), er_text_left(), k_er_blank_lines, k_er_body_gap, k_er_body_line_count, k_er_body_lines, k_er_chapter, k_er_footer_h, k_er_glyph_h, k_er_ink, k_er_line_h, k_er_margin_x, and k_er_statusbar_h.

Referenced by er_read_body_render().

◆ er_draw_reading_body_reflow()

bool er_draw_reading_body_reflow ( int32_t body_top,
int32_t height )
static

Render the Reading body through reflow when an SD font is loaded.

Lays the chapter XHTML out against the body rectangle (inset below the status bar, above the footer) and paints the current page (s_reading_page) there via reflow_render_page_at. er_render_reading has already cleared the framebuffer to paper and the body colour is dark ink, so the text shows (the reflow_init colour args are the text colours, not the background). Publishes the layout's page count to s_reading_pages and clamps s_reading_page into range.

Parameters
[in]body_topTop y of the body band (pixels).
[in]heightFramebuffer height (pixels).
Returns
true if reflowed text was painted; false to use the bitmap fallback.
Return values
truereflow rendered the body.
falseNo font / init / layout failure – caller draws the bitmap body.
Precondition
ra8_gfx is bound and the body region is cleared to paper.
height matches the bound framebuffer.
Postcondition
On true, s_reading_page of the chapter is blitted into the body rect and s_reading_pages holds the total page count.
On false, nothing is drawn.
Note
Not thread-safe.
Since
0.1.0

Definition at line 707 of file ereader_ui_screens.c.

References er_reflow_relayout(), g_ra8_font_literata_latin1, g_ra8_font_literata_latin1_len, k_er_body_gap, k_er_footer_h, k_er_margin_x, k_er_statusbar_h, reflow_render_page_at(), s_chapter_idx, s_fb, s_font_buf, s_font_len, s_have_font, s_reading_page, s_reading_pages, s_reflow_chapter, s_reflow_engine, s_reflow_h, s_reflow_open, and s_reflow_w.

Referenced by er_draw_reading_body().

◆ er_image_loader()

ra8_err_t er_image_loader ( void * ctx,
const char * href,
uint32_t href_len,
const uint8_t ** out_bytes,
size_t * out_len )
static

reflow image loader: resolve any <img src> to the baked figure.

The mock library has no EPUB ZIP to read resources from, so every <img> in the demo chapter resolves to the one bundled figure (k_er_figure_png). A real EPUB-backed build would map href to a manifest item and return its bytes; the engine contract is identical either way.

Parameters
[in]ctxUnused loader context.
[in]hrefImage src (unused; single bundled figure).
[in]href_lenLength of href.
[out]out_bytesReceives the encoded PNG bytes.
[out]out_lenReceives the encoded byte count.
Returns
k_ra8_ok always (the figure is always available).
Return values
k_ra8_okThe bundled figure bytes were returned.
Precondition
out_bytes and out_len are non-null.
The bundled figure is a valid encoded image.
Postcondition
*out_bytes / *out_len describe k_er_figure_png.
No state mutated.
Note
Not thread-safe (single-threaded UI loop).
Since
0.1.0

Definition at line 106 of file ereader_ui_screens.c.

References k_er_ext_len, k_er_figure_png, k_er_figure_png_len, k_er_logo_svg, k_er_logo_svg_len, k_ra8_ok, and memcmp().

Referenced by er_reflow_relayout().

◆ er_lc()

char er_lc ( char c)
static

Lower-case an ASCII letter (identity for non-letters).

Definition at line 351 of file ereader_ui_screens.c.

Referenced by er_ci_contains().

◆ er_leaf()

ra8_box_t er_leaf ( int16_t fixed,
uint16_t flex,
uint32_t fill,
uint32_t border )
static

Make a leaf box template carrying fill / border.

Parameters
[in]fixedFixed main-axis extent (0 => flex).
[in]flexFlex weight when not fixed.
[in]fillFill colour, or k_ra8_box_no_colour.
[in]borderBorder colour, or k_ra8_box_no_colour.
Returns
A leaf ra8_box_t template.
Return values
nodeConfigured leaf node template.
Precondition
None.
None.
Postcondition
Returned node has kind leaf and the requested sizing/colours.
Tree links are left for ra8_box_add to set.
Note
Pure.
Since
0.1.0

Definition at line 187 of file ereader_ui_screens.c.

References ra8_box_t::border, ra8_box_t::border_w, ra8_box_t::fill, ra8_box_t::fixed, ra8_box_t::flex, ra8_box_t::grid_cols, k_er_border_w, k_ra8_box_leaf, k_ra8_box_no_colour, k_ra8_box_none, ra8_box_t::kind, and ra8_box_t::tag.

Referenced by er_add_book_tile(), er_build_library(), er_build_nav(), and er_build_toolbar().

◆ er_lib_body_render()

void er_lib_body_render ( ra8_widget_t * w)
static

Body band widget: toolbar + book grid + nav nodes + the above-nav rule.

Definition at line 529 of file ereader_ui_screens.c.

References er_render_boxnodes(), k_er_hair, k_er_nav_h, k_er_rule, ra8_gfx_rect(), s_fb, s_lib_body_first, and s_lib_node_count.

◆ er_lib_sb_render()

void er_lib_sb_render ( ra8_widget_t * w)
static

Render the full Library screen.

Precondition
ra8_gfx is bound; s_fb reflects the framebuffer geometry.
None.
Postcondition
The framebuffer holds the Library screen; s_targets set.
Caller flushes the panel to make it visible.
Note
Not thread-safe.
Since
0.1.0

Definition at line 512 of file ereader_ui_screens.c.

References er_render_boxnodes(), er_text_right(), k_er_hair, k_er_ink_muted, k_er_pad_ui, k_er_rule, k_er_status_right, k_er_statusbar_h, k_er_text_inset_y, ra8_gfx_rect(), s_fb, and s_lib_body_first.

◆ er_nav_chapter()

bool er_nav_chapter ( uint32_t off,
uint32_t path_len )
static

Follow a cross-chapter link: resolve the path against the mock spine.

Parameters
[in]offHref text-pool offset.
[in]path_lenLength of the path part (excluding any fragment).
Returns
true iff a different chapter was loaded (old location pushed for Back).

Definition at line 940 of file ereader_ui_screens.c.

References er_push_loc(), er_spine_count(), k_er_spine, memcmp(), s_chapter_idx, s_reading_page, and s_reflow_engine.

Referenced by er_reading_link_tap().

◆ er_nav_fragment()

bool er_nav_fragment ( uint32_t off,
uint32_t frag_off,
uint32_t frag_len )
static

Follow a same-chapter #fragment: jump to the anchored page.

Parameters
[in]offHref text-pool offset.
[in]frag_offFragment offset within the href.
[in]frag_lenFragment length.
Returns
true iff the page changed (old location pushed for Back).

Definition at line 917 of file ereader_ui_screens.c.

References er_push_loc(), k_ra8_ok, reflow_find_anchor(), s_reading_page, and s_reflow_engine.

Referenced by er_reading_link_tap().

◆ er_push_loc()

void er_push_loc ( void )

Push the current (chapter, page) on the back-stack, capacity permitting.

Precondition
s_chapter_idx / s_reading_page are the visible location.
None.
Postcondition
On free capacity the location is appended to s_loc_back.
s_loc_back_count is bounded by k_er_page_back_cap.
Note
Not thread-safe.
Since
0.1.0

Definition at line 874 of file ereader_ui_screens.c.

References k_er_page_back_cap, s_chapter_idx, s_loc_back, s_loc_back_count, and s_reading_page.

Referenced by er_nav_chapter(), and er_nav_fragment().

◆ er_read_body_render()

void er_read_body_render ( ra8_widget_t * w)
static

Body band widget: the reflowed (or bitmap-fallback) chapter text.

Definition at line 803 of file ereader_ui_screens.c.

References er_draw_reading_body(), s_fb, and s_read_reflowed.

◆ er_read_footer_render()

◆ er_read_sb_render()

void er_read_sb_render ( ra8_widget_t * w)
static

Status-bar band widget: wordmark + book title + status-right + hairline.

Definition at line 782 of file ereader_ui_screens.c.

References er_text_left(), er_text_right(), k_er_book_title, k_er_glyph_w, k_er_hair, k_er_ink, k_er_ink_muted, k_er_pad_ui, k_er_rule, k_er_status_right, k_er_statusbar_h, k_er_text_inset_y, k_er_wordmark, ra8_gfx_rect(), and s_fb.

◆ er_reading_link_tap()

bool er_reading_link_tap ( int32_t x,
int32_t y )

Follow an in-content <a> tap in the Reading body (#110).

Parameters
[in]xTap X (panel pixels).
[in]yTap Y (panel pixels).
Returns
true iff the tap followed a link and changed the reading location.
Return values
trueA link was followed; chapter/page updated.
falseNo link hit, or an unresolved / external target.
Precondition
The Reading body was laid out (link rects reflect the chapter).
s_reading_page is the visible page.
Postcondition
On true the reading location changed and the old one is on s_loc_back.
Note
Not thread-safe.
Since
0.1.0

Definition at line 960 of file ereader_ui_screens.c.

References er_nav_chapter(), er_nav_fragment(), k_er_body_gap, k_er_margin_x, k_er_statusbar_h, k_ra8_ok, k_reflow_href_chapter, k_reflow_href_chapter_fragment, k_reflow_href_empty, k_reflow_href_fragment, reflow_hit_test_link(), reflow_href_split(), s_reading_page, and s_reflow_engine.

Referenced by er_handle_reading_tap().

◆ er_reflow_relayout()

bool er_reflow_relayout ( int32_t body_w,
int32_t body_h,
const uint8_t * font_data,
uint32_t font_len )
static

Re-init the reflow engine and lay the current chapter into the cache.

Closes any prior layout, binds the font + image arena, paginates the current chapter (s_chapter_idx) and records the cache keys (s_reflow_chapter / s_reflow_w / s_reflow_h) so subsequent same-chapter page turns skip this expensive step. The costliest part of a Reading render.

Parameters
[in]body_wBody width the chapter is paginated for (px).
[in]body_hBody height the chapter is paginated for (px).
[in]font_dataFont blob (SD-loaded or baked).
[in]font_lenFont blob length in bytes.
Returns
true if the chapter was laid out and the cache is now valid.
Return values
trueLayout succeeded; s_reflow_open is set.
falseinit / layout failed; the engine is closed.
Precondition
body_w and body_h are > 0.
font_data / font_len describe a usable face.
Postcondition
On true the cache keys reflect the laid-out chapter + geometry.
On false s_reflow_open is false.
Note
Not thread-safe.
Since
0.1.0

Definition at line 641 of file ereader_ui_screens.c.

References er_bind_glyph_atlas(), er_image_loader(), k_er_img_arena, k_er_reflow_ink, k_er_reflow_link, k_er_reflow_px, k_er_spine, k_ra8_ok, er_chapter_t::len, reflow_close(), reflow_init(), reflow_layout_chapter(), reflow_set_image_loader(), s_chapter_idx, s_img_arena_buf, s_reading_pages, s_reflow_chapter, s_reflow_engine, s_reflow_h, s_reflow_open, s_reflow_w, and er_chapter_t::xhtml.

Referenced by er_draw_reading_body_reflow().

◆ er_render_boxnodes()

void er_render_boxnodes ( uint16_t from,
uint16_t to )
static

Render box nodes [from, to) of s_nodes (fills, borders, progress bars, labels).

Parameters
[in]fromIndex of the first node to draw (inclusive).
[in]toIndex one past the last node to draw (exclusive).
Precondition
ra8_gfx is bound; the tree is laid out; side tables match its nodes.
from <= to and to is within the laid-out node count.
Postcondition
Every node in [from, to) has its fill/border/progress/label drawn.
Note
Not thread-safe.
Since
0.1.0

Definition at line 450 of file ereader_ui_screens.c.

References ra8_box_t::border, ra8_box_t::border_w, er_text_left(), ra8_box_t::fill, ra8_ui_rect_t::h, k_er_fill_deep, k_er_pct_full, k_er_text_pad, k_ra8_box_no_colour, ra8_gfx_rect(), ra8_box_t::rect, s_label, s_label_col, s_nodes, s_progress, ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by er_lib_body_render(), and er_lib_sb_render().

◆ er_render_library()

void er_render_library ( void )

Render the full Library screen.

Precondition
ra8_gfx is bound; s_fb reflects the framebuffer geometry.
None.
Postcondition
The framebuffer holds the Library screen; s_targets set.
Caller flushes the panel to make it visible.
Note
Not thread-safe.
Since
0.1.0

Definition at line 545 of file ereader_ui_screens.c.

References ra8_box_tree_t::count, er_build_library(), er_collect_targets(), k_er_lib_body_vt, k_er_lib_sb_vt, k_er_paper, k_er_statusbar_h, k_ra8_widget_axis_col, k_ra8_widget_refresh_quality, ra8_gfx_clear(), ra8_widget_invalidate(), ra8_widget_layout_stack(), ra8_widget_render_dirty(), s_fb, and s_lib_node_count.

Referenced by er_app_render().

◆ er_render_reading()

void er_render_reading ( void )

Render the full Reading screen (status bar, body, footer).

Precondition
ra8_gfx is bound; s_fb reflects the framebuffer geometry.
None.
Postcondition
The framebuffer holds the Reading screen.
Caller flushes the panel to make it visible.
Note
Not thread-safe.
Since
0.1.0

Definition at line 848 of file ereader_ui_screens.c.

References k_er_footer_h, k_er_paper, k_er_read_body_vt, k_er_read_footer_vt, k_er_read_sb_vt, k_er_statusbar_h, k_ra8_widget_axis_col, k_ra8_widget_refresh_quality, ra8_gfx_clear(), ra8_widget_invalidate(), ra8_widget_layout_stack(), ra8_widget_render_dirty(), and s_fb.

Referenced by er_app_render().

◆ er_reset_side_tables()

void er_reset_side_tables ( void )
static

Reset the per-node label / progress side tables.

Precondition
None.
None.
Postcondition
Every node slot has no label and no progress bar.
Every label colour defaults to ink.
Note
Not thread-safe.
Since
0.1.0

Definition at line 159 of file ereader_ui_screens.c.

References k_er_ink, k_er_max_nodes, s_label, s_label_col, and s_progress.

Referenced by er_build_library().

◆ er_spine_count()

uint32_t er_spine_count ( void )

Number of chapters in the (mock) spine.

Returns
Chapter count of k_er_spine.
Return values
countThe number of spine chapters.
Precondition
k_er_spine is a valid table.
None.
Postcondition
No state mutated.
Returned value is >= 1.
Note
Pure.
Since
0.1.0

Definition at line 883 of file ereader_ui_screens.c.

References k_er_spine_count.

Referenced by er_apply_pageturn(), and er_nav_chapter().

◆ er_text_left()

void er_text_left ( int32_t x,
int32_t y,
const char * str,
uint32_t color )

Draw a left-anchored text run in the bundled font.

Parameters
[in]xLeft pixel column.
[in]yTop pixel row.
[in]strASCII string (NUL-terminated).
[in]colorForeground colour (0xRRGGBB); background is paper.
Precondition
ra8_gfx is bound; str is non-NULL ASCII 0x20..0x7E.
None.
Postcondition
The run is blitted (clipped if needed).
Glyph cells are backed with paper-white.
Note
Not thread-safe.
Since
0.1.0

Definition at line 129 of file ereader_ui_screens.c.

References k_er_paper, ra8_gfx_font_8x16, and ra8_gfx_text_out().

Referenced by er_draw_reading_body(), er_kbd_search_render(), er_read_footer_render(), er_read_sb_render(), er_render_boxnodes(), and er_text_right().

◆ er_text_right()

void er_text_right ( int32_t right,
int32_t y,
const char * str,
uint32_t color )

Draw a right-anchored text run ending at column right.

Parameters
[in]rightRight pixel column the run ends at.
[in]yTop pixel row.
[in]strASCII string (NUL-terminated).
[in]colorForeground colour (0xRRGGBB); background is paper.
Precondition
ra8_gfx is bound; str is non-NULL ASCII 0x20..0x7E.
None.
Postcondition
The run is right-aligned to end near right.
Glyph cells are backed with paper-white.
Note
Not thread-safe.
Since
0.1.0

Definition at line 134 of file ereader_ui_screens.c.

References er_text_left(), k_ra8_ok, ra8_gfx_font_8x16, and ra8_gfx_text_size().

Referenced by er_lib_sb_render(), er_read_footer_render(), and er_read_sb_render().

Variable Documentation

◆ g_ra8_font_literata_latin1

const uint8_t g_ra8_font_literata_latin1[]
extern

Baked Latin-1 font array (generated at build time).

◆ g_ra8_font_literata_latin1_len

const unsigned int g_ra8_font_literata_latin1_len
extern

◆ k_er_lib_body_vt

const ra8_widget_vtable_t k_er_lib_body_vt = {.render = er_lib_body_render}
static

Definition at line 543 of file ereader_ui_screens.c.

Referenced by er_render_library().

◆ k_er_lib_sb_vt

const ra8_widget_vtable_t k_er_lib_sb_vt = {.render = er_lib_sb_render}
static

Vtables for the Library status-bar / body band widgets.

Definition at line 542 of file ereader_ui_screens.c.

Referenced by er_render_library().

◆ k_er_logo_svg

const char k_er_logo_svg[]
static
Initial value:
=
"<svg viewBox=\"0 0 120 80\">"
"<rect x=\"0\" y=\"0\" width=\"120\" height=\"80\" fill=\"#283C82\"/>"
"<circle cx=\"34\" cy=\"40\" r=\"24\" fill=\"#E6C84B\"/>"
"<path d=\"M66 62 L112 62 L89 16 Z\" fill=\"#C03A37\"/>"
"</svg>"

In-content SVG (#112): a navy field, a gold disc, and a crimson block.

Returned by er_image_loader for any *.svg <img src>; rendered as vector <rect>/<circle> shapes by ra8_svg_render (no raster decode).

Definition at line 71 of file ereader_ui_screens.c.

Referenced by er_image_loader().

◆ k_er_read_body_vt

const ra8_widget_vtable_t k_er_read_body_vt = {.render = er_read_body_render}
static

Definition at line 845 of file ereader_ui_screens.c.

Referenced by er_render_reading().

◆ k_er_read_footer_vt

const ra8_widget_vtable_t k_er_read_footer_vt = {.render = er_read_footer_render}
static

Definition at line 846 of file ereader_ui_screens.c.

Referenced by er_render_reading().

◆ k_er_read_sb_vt

const ra8_widget_vtable_t k_er_read_sb_vt = {.render = er_read_sb_render}
static

Vtables for the Reading status-bar / body / footer band widgets.

Definition at line 844 of file ereader_ui_screens.c.

Referenced by er_render_reading().

◆ s_label

const char* s_label[k_er_max_nodes]
static

Per-node text label (NULL if the node draws no text).

Definition at line 51 of file ereader_ui_screens.c.

◆ s_label_col

uint32_t s_label_col[k_er_max_nodes]
static

Per-node text colour.

Definition at line 54 of file ereader_ui_screens.c.

Referenced by er_add_book_tile(), er_build_nav(), er_build_toolbar(), er_render_boxnodes(), and er_reset_side_tables().

◆ s_lib_body_first

uint16_t s_lib_body_first = 2U
static

First Library body box-node (root=0, status bar=1, body from here).

Definition at line 63 of file ereader_ui_screens.c.

Referenced by er_build_library(), er_lib_body_render(), and er_lib_sb_render().

◆ s_lib_node_count

uint16_t s_lib_node_count
static

Library box-node count (set by er_render_library for the band widgets).

Definition at line 60 of file ereader_ui_screens.c.

Referenced by er_lib_body_render(), and er_render_library().

◆ s_nodes

ra8_box_t s_nodes[k_er_max_nodes]
static

Box-tree node storage for chrome layout.

Definition at line 48 of file ereader_ui_screens.c.

◆ s_progress

int16_t s_progress[k_er_max_nodes]
static

Per-node progress percent, or -1 for "not a progress bar".

Definition at line 57 of file ereader_ui_screens.c.

Referenced by er_add_book_tile(), er_render_boxnodes(), and er_reset_side_tables().

◆ s_read_reflowed

bool s_read_reflowed = false
static

Stash: did the body band reflow live text?

The footer bar tracks it.

Definition at line 779 of file ereader_ui_screens.c.

Referenced by er_read_body_render(), and er_read_footer_render().