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

Bookshelf screen: a grid of book cards with cover thumbnails. More...

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

Go to the source code of this file.

Enumerations

enum  sh_shelf_const_t : uint32_t {
  k_sh_box_cap = 32U ,
  k_sh_sel_border = 4U ,
  k_sh_card_bord = 2U ,
  k_sh_title_gap = 6U ,
  k_sh_two = 2U ,
  k_sh_card_h = 272U
}
 Shelf-layout constants. More...

Functions

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 void sh_draw_card (ra8_ui_rect_t r, uint16_t idx)
 Draw one book card: cover thumbnail (or placeholder) + title + author.
static uint16_t sh_layout_cards (void)
 Lay out the shelf grid into sh_state_t::card_rect; returns count placed.
void sh_shelf_render (void)
 Render the shelf grid (cover cards) into the framebuffer.
int32_t sh_shelf_hit (int32_t x, int32_t y)
 Hit-test a shelf tap; returns the book index or -1.

Detailed Description

Bookshelf screen: a grid of book cards with cover thumbnails.

Lays out the unified baked+SD entry table as an ra8_box grid, drawing each book's cached cover thumbnail above its title and author. Baked thumbnails are pre-decoded gray8 arrays copied straight out of library.h at boot (sh_shelf_build_thumbs); SD covers decode lazily on first open through the demand-paged source, so the shelf paints without holding any book in RAM. The selected card is highlighted.

[Ring 6 / App] {World: NS}

Since
0.1.0

Definition in file sh_shelf.c.

Enumeration Type Documentation

◆ sh_shelf_const_t

enum sh_shelf_const_t : uint32_t

Shelf-layout constants.

Enumerator
k_sh_box_cap 

ra8_box scratch node capacity.

k_sh_sel_border 

Selected card border width.

k_sh_card_bord 

Idle card border width.

k_sh_title_gap 

Cover-to-title vertical gap.

k_sh_two 

Centring divisor.

k_sh_card_h 

Card height (cover box + 2 text lines + insets).

Definition at line 28 of file sh_shelf.c.

Function Documentation

◆ sh_decode_cover()

void sh_decode_cover ( uint16_t idx,
const book_src_t * src )

Decode the open rabook source's 4bpp cover into thumbnail slot idx.

Definition at line 37 of file sh_shelf.c.

References book_header_t::cover_image_index, g_sh, book_src_t::hdr, k_book_nil, k_ra8_ok, k_sh_thumb_h, k_sh_thumb_w, and sh_image_decode_gray8().

Referenced by sh_book_decode_thumb().

◆ sh_draw_card()

◆ sh_layout_cards()

uint16_t sh_layout_cards ( void )
static

◆ sh_shelf_build_thumbs()

void sh_shelf_build_thumbs ( void )

Copy the baked books' pre-decoded covers into sh_state_t::thumb at boot.

Definition at line 62 of file sh_shelf.c.

References sh_entry_t::from_sd, g_sh, memcpy(), sh_entry_t::thumb, sh_entry_t::thumb_h, and sh_entry_t::thumb_w.

Referenced by main().

◆ sh_shelf_hit()

int32_t sh_shelf_hit ( int32_t x,
int32_t y )

Hit-test a shelf tap; returns the book index or -1.

Definition at line 170 of file sh_shelf.c.

References g_sh, ra8_ui_rect_t::h, ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by sh_handle_tap().

◆ sh_shelf_render()

void sh_shelf_render ( void )

Render the shelf grid (cover cards) into the framebuffer.

Definition at line 160 of file sh_shelf.c.

References g_sh, k_sh_col_bg, ra8_gfx_clear(), sh_draw_card(), sh_layout_cards(), and sh_titlebar().

Referenced by sh_present().