- 新增顶层 tuku/ 工程(package dev.tuku.app、二进制 tuku):app.c/internal 头/logic/ui 分层、app.json、build/pack 脚本 - 书库:从 TF 卡根浏览文件夹,含图目录=一本书;logic/library 纯 C 扫描+自然排序(page2<page10) - 流式缩略图:后台线程解码+meow_img_downscale(96),首帧/滚动不阻塞;磁盘缓存 MeowData/<pkg>/cache(mtime 失效+LRU) - 列表 meow_listview 虚拟化 + meow_scroll fling/snap;行=缩略图+目录名+页数 - 主题:全部语义色 + meow_theme_add_listener 即时重绘;明暗/风格族两态可读 - 导航:meow_view page push/pop、TopAppBar ⚙→设置;reader/settings/lock 最小桩 - 接缝:mr_reader_get/set_direction(默认 RTL)、lock_view_should_show()(桩 0) - 宿主 gcc 测试 46 项 PASS;交叉构建静态 MIPS32r2 ELF、-Wall -Wextra 零警告
86 lines
2.8 KiB
C
86 lines
2.8 KiB
C
/* ui/reader/reader.c — 阅读器页(ACT_READER,全屏)M3 骨架。
|
|
*
|
|
* M4 在此实现翻页/图片显示;本批只落可编译桩 + 既有接缝:
|
|
* - 书库经 mr_reader_open_dir(path) 导航进来(app.c/library.c 不改);
|
|
* - 方向状态走 logic/reader 的 mr_reader_get/set_direction(默认 RTL)。
|
|
* 绘制走 view on_draw(注册表驱动),主题切换由 app.c 的 listener invalidate 全屏重画。
|
|
*/
|
|
#include "tuku_internal.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static mr_page_ctrl g_ctrl;
|
|
static char g_dir[MR_PATH_MAX];
|
|
|
|
const char *mr_reader_dir(void)
|
|
{
|
|
return g_dir;
|
|
}
|
|
|
|
void mr_reader_open_dir(const char *path)
|
|
{
|
|
if (!path) return;
|
|
snprintf(g_dir, sizeof g_dir, "%s", path);
|
|
meow_log(MEOW_LOG_INFO, "reader open: %s", g_dir);
|
|
meow_view_page_push(ACT_READER);
|
|
}
|
|
|
|
void reader_on_tap(int x, int y)
|
|
{
|
|
(void)x; (void)y;
|
|
if (!g_ctrl.active) return;
|
|
mr_reader_set_direction(mr_reader_get_direction() == MR_DIR_RTL ? MR_DIR_LTR : MR_DIR_RTL);
|
|
meow_ui_invalidate(0, 0, meow_ui_width(), meow_ui_height());
|
|
}
|
|
|
|
static void reader_draw(meow_view *v, const meow_theme *th, void *ctx)
|
|
{
|
|
(void)v; (void)ctx;
|
|
int w = meow_ui_width();
|
|
const char *dir = g_dir[0] ? g_dir : "(no directory)";
|
|
size_t n = strlen(dir);
|
|
if (n > 64) dir += n - 64;
|
|
|
|
meow_ui_text_center(w / 2, 160, "READER", th->font_title, th->primary);
|
|
meow_ui_text_center(w / 2, 200, "(M4 will render pages here)", th->font_body,
|
|
th->onSurfaceVariant);
|
|
meow_ui_text_center(w / 2, 280, "Folder:", th->font_body, th->onSurfaceVariant);
|
|
meow_ui_text_center(w / 2, 308, dir, th->font_body, th->onSurface);
|
|
meow_ui_text_center(w / 2, 372,
|
|
mr_reader_get_direction() == MR_DIR_RTL ? "Direction: RTL" : "Direction: LTR",
|
|
th->font_body, th->onSurface);
|
|
meow_ui_text_center(w / 2, 420, "tap = toggle direction", th->font_body, th->onSurfaceVariant);
|
|
meow_ui_text_center(w / 2, 448, "left-edge swipe = back", th->font_body, th->onSurfaceVariant);
|
|
}
|
|
|
|
static void reader_page_enter(meow_view *v, void *ctx)
|
|
{
|
|
((mr_page_ctrl *)ctx)->active = 1;
|
|
v->x = 0;
|
|
v->y = 0;
|
|
v->w = meow_ui_width();
|
|
v->h = meow_ui_height();
|
|
meow_ui_set_fullscreen(1); /* app.json route.reader.fullscreen 的运行时兜底 */
|
|
meow_ui_set_page_bg(meow_theme_get()->bg);
|
|
mr_nav_report();
|
|
meow_ui_paint_full();
|
|
}
|
|
|
|
static void reader_page_leave(meow_view *v, void *ctx)
|
|
{
|
|
(void)v;
|
|
((mr_page_ctrl *)ctx)->active = 0;
|
|
meow_ui_set_fullscreen(0);
|
|
}
|
|
|
|
meow_view *reader_view_create(void)
|
|
{
|
|
static const meow_view_hooks h = {
|
|
.on_enter = reader_page_enter,
|
|
.on_leave = reader_page_leave,
|
|
.on_draw = reader_draw,
|
|
};
|
|
return meow_view_create(ACT_READER, MEOW_VIEW_ACTIVITY, &h, &g_ctrl);
|
|
}
|