/* 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 #include 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); }