fix: M6.41批 — 启动失败原因透传 + 阅读器左缘返回/阅读页接入view栈 + 后台管理按钮点不动 + 阅读器瘦身(fonts common+页位图释放) + files txt换行
- launcher(453): app_launcher.c g_launch_fail_reason+launch_fail()统一出口(5失败点 fork OOM/exec/no such file/missing dep/execpipe)+main_menu.c launch_fail_toast(缺依赖/CANNOT START: name(reason))+toast256 - launcher(457): bg_page.c bgm_enumerate跳过term_at_ms(杀后当下消失)+不可杀行按钮置灰+row_tap/top_action返回1; subpage.c 消warning - reader(454): reader_on_swipe LEFT/RIGHT→返回(先关overlay否则page_pop回书架)+app.c书架根LEFT→exit - reader(458瘦身A+B): app.json fonts full→common(省13MB atlas)+reader.c RD_PAGE_CACHE 3→2+g_anim_old懒分配/anim_done释放+on_enter/on_leave页位图离开释放重建 - reader(459导航): reader_open返回int+shelf点书push ACT_READER(阅读页接入view栈,on_enter/on_leave驱动) — 使454左缘返回+458瘦身B真正生效 - files(455): viewer.c viewer_cp_len+按码位折行(txt中文不冲出右缘) 0warning;宿主测试全过;files二进制已热更
This commit is contained in:
1 parent
626a87a30d
commit
ddc8d35eb9
11 files changed
+154
-66
No files matched your search
@@ -29,7 +29,11 @@ static void app_on_swipe(int dir, int dx, int dy)
|
||||
(void)dy; (void)dx;
|
||||
if (settings_is_active()) { return; } /* 设置页滑动不翻页 */
|
||||
if (reader_is_active()) { reader_on_swipe(dir, dx, dy); return; }
|
||||
if (shelf_is_active()) { shelf_on_swipe(dir, dx, dy); return; }
|
||||
if (shelf_is_active()) {
|
||||
/* 书架根页左缘右滑(返回手势)→ 退出 App(镜像 hello_app/files_app 的 LEFT→返回)。 */
|
||||
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); return; }
|
||||
shelf_on_swipe(dir, dx, dy); return;
|
||||
}
|
||||
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); }
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"name":"Reader","exec":"/usr/data/mnt/sd_0/MeowAPPs/os.meow.reader/reader","package":"os.meow.reader","version":"0.1","version_code":1,"framework":1,"fonts":"full","author":"MeowOS","icon":"icon.png","volume_page":true}
|
||||
{"name":"Reader","exec":"/usr/data/mnt/sd_0/MeowAPPs/os.meow.reader/reader","package":"os.meow.reader","version":"0.1","version_code":1,"framework":1,"fonts":"common","author":"MeowOS","icon":"icon.png","volume_page":true}
|
||||
@@ -28,9 +28,9 @@ static int g_reader_active;
|
||||
static meow_widget *g_canvas;
|
||||
static int g_pw, g_ph, g_top, g_mx, g_my;
|
||||
static int g_fs, g_ls;
|
||||
#define RD_PAGE_CACHE 3
|
||||
#define RD_PAGE_SLOT_CUR 1
|
||||
static uint16_t *g_page_buf[RD_PAGE_CACHE]; /* [0]=prev [1]=cur [2]=next(FreeType 页位图) */
|
||||
#define RD_PAGE_CACHE 2
|
||||
#define RD_PAGE_SLOT_CUR 0
|
||||
static uint16_t *g_page_buf[RD_PAGE_CACHE]; /* [0]=cur [1]=next(FreeType 页位图;B.1 降 3→2 槽,省 1 页 0.69MB) */
|
||||
static int g_has_font; /* 1=FreeType 路径;0=SDK 字库兜底 */
|
||||
static int g_menu_open;
|
||||
static int g_ui_open; /* 「界面」排版面板(B) */
|
||||
@@ -500,7 +500,19 @@ static void reader_free_page_bufs(void)
|
||||
if (g_anim_old) { free(g_anim_old); g_anim_old = NULL; }
|
||||
}
|
||||
|
||||
/* 渲染当前页 + 前后各一页到 3 槽缓存(对齐设计「当前±前±后」;动画档为 无/滑动/淡入 R1 默认无)。 */
|
||||
/* 分配 FreeType 页位图槽(cur+next 两槽)。已备当前槽则幂等返回(开书/重入共用)。
|
||||
* 动画快照 g_anim_old 不在此常驻:翻页时懒分配、动画完成即释放(见 turn_animated/anim_done)。
|
||||
* 分配失败 → g_has_font=0,走字库兜底路径。 */
|
||||
static void reader_alloc_page_bufs(void)
|
||||
{
|
||||
if (!(g_has_font || rd_book_is_image(g_book))) return;
|
||||
if (g_page_buf[RD_PAGE_SLOT_CUR]) return; /* 已备当前槽(重入)→ 幂等 */
|
||||
for (int i = 0; i < RD_PAGE_CACHE; i++)
|
||||
g_page_buf[i] = (uint16_t *)malloc((size_t)g_pw * (size_t)g_ph * 2);
|
||||
if (!g_page_buf[RD_PAGE_SLOT_CUR]) { reader_free_page_bufs(); g_has_font = 0; }
|
||||
}
|
||||
|
||||
/* 渲染当前页 + 下一预取页到 2 槽缓存(B.1:降 3→2,去 prev 槽;动画档 无/滑动/淡入 R1 默认无)。 */
|
||||
static int reader_refill_page(void)
|
||||
{
|
||||
if (!g_book) return -1;
|
||||
@@ -508,7 +520,7 @@ static int reader_refill_page(void)
|
||||
uint16_t bg = rgb565(g_page_bg), fg = rgb565(g_page_fg);
|
||||
int cur = rd_book_current(g_book);
|
||||
int np = rd_book_pages(g_book);
|
||||
int slots[RD_PAGE_CACHE] = { cur - 1, cur, cur + 1 };
|
||||
int slots[RD_PAGE_CACHE] = { cur, cur + 1 };
|
||||
for (int i = 0; i < RD_PAGE_CACHE; i++) {
|
||||
int p = slots[i];
|
||||
if (p >= 0 && p < np) rd_book_render(g_book, p, g_page_buf[i], g_pw * 2, bg, fg);
|
||||
@@ -539,6 +551,8 @@ static void reader_anim_done(meow_anim *a, int canceled, void *ctx)
|
||||
{
|
||||
(void)a; (void)ctx;
|
||||
g_anim = NULL;
|
||||
/* 动画完成/取消即释放旧页快照位图,不驻留;下一翻页懒分配(见 reader_turn_animated)。 */
|
||||
if (g_anim_old) { free(g_anim_old); g_anim_old = NULL; }
|
||||
if (!canceled) { reader_redraw(); reader_reflow_persist(); } /* 顶栏 n/N+% 更新 + 进度保存 */
|
||||
}
|
||||
static void reader_turn_animated(int dir)
|
||||
@@ -619,9 +633,9 @@ static void reader_scrub_begin(int x, int y)
|
||||
}
|
||||
|
||||
/* ---------- 打开 ---------- */
|
||||
void reader_open(const char *path)
|
||||
int reader_open(const char *path)
|
||||
{
|
||||
if (!path || !path[0]) return;
|
||||
if (!path || !path[0]) return -1;
|
||||
if (g_book) { rd_book_close(g_book); g_book = NULL; }
|
||||
reader_free_page_bufs();
|
||||
|
||||
@@ -653,16 +667,13 @@ void reader_open(const char *path)
|
||||
meow_log(MEOW_LOG_WARN, "book open failed rc=%d path=%s", rc, path);
|
||||
g_book = NULL; g_has_font = 0;
|
||||
g_notice_ms = 3000;
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
chapter_name();
|
||||
|
||||
if (g_has_font || rd_book_is_image(g_book)) {
|
||||
reader_free_page_bufs();
|
||||
for (int i = 0; i < RD_PAGE_CACHE; i++)
|
||||
g_page_buf[i] = (uint16_t *)malloc((size_t)g_pw * (size_t)g_ph * 2);
|
||||
if (!g_page_buf[RD_PAGE_SLOT_CUR]) { reader_free_page_bufs(); g_has_font = 0; }
|
||||
else g_anim_old = (uint16_t *)malloc((size_t)g_pw * (size_t)g_ph * 2); /* 动画快照位图 */
|
||||
reader_free_page_bufs(); /* 丢弃上一本书的页位图(重开/换书) */
|
||||
reader_alloc_page_bufs(); /* 重建 cur+next 两槽;g_anim_old 翻页时懒分配 */
|
||||
}
|
||||
|
||||
/* 复位动画/刮擦状态(跨书) */
|
||||
@@ -691,6 +702,7 @@ void reader_open(const char *path)
|
||||
reader_refill_page();
|
||||
|
||||
if (g_reader_active) reader_redraw();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------- 视图生命周期 ---------- */
|
||||
@@ -699,13 +711,18 @@ static void reader_on_enter(meow_view *v, void *ctx)
|
||||
{
|
||||
(void)v; (void)ctx;
|
||||
g_reader_active = 1;
|
||||
if (g_book) { reader_refill_page(); chapter_name(); }
|
||||
if (g_book) {
|
||||
reader_alloc_page_bufs(); /* 离开已释放页位图 → 重建;未释放则幂等返回 */
|
||||
reader_refill_page();
|
||||
chapter_name();
|
||||
}
|
||||
reader_redraw();
|
||||
}
|
||||
static void reader_on_leave(meow_view *v, void *ctx)
|
||||
{
|
||||
(void)v; (void)ctx;
|
||||
reader_reflow_persist(); /* 离开保存进度 */
|
||||
reader_free_page_bufs(); /* 离开阅读页释放页位图(cur+next 两槽+动画快照)→ on_enter 重建 */
|
||||
g_reader_active = 0;
|
||||
}
|
||||
static void reader_on_destroy(meow_view *v, void *ctx)
|
||||
@@ -842,10 +859,18 @@ void reader_on_swipe(int dir, int dx, int dy)
|
||||
(void)dx; (void)dy;
|
||||
if (!g_book) return;
|
||||
if (g_scrub) g_scrub = 0; /* 刮擦中被滑走 → 退出刮擦 */
|
||||
if (g_ui_open) { g_ui_open = 0; reader_redraw(); return; }
|
||||
/* 水平滑 = 返回语义(镜像菜单「返回书架」,见上文 g_menu_open 分支)。SDK 把「左缘右滑
|
||||
* (返回手势)」判为 MEOW_SWIPE_LEFT 下发;旧语义拿去翻下一页,会与 SDK 自绘的左缘返回
|
||||
* 指示条错位(M6.40 真机 bug:有指示条却翻页/不返回)。故水平滑统一「先关一层 overlay,
|
||||
* 否则回书架」。翻页不再交给水平滑——保留三区点按(左 1/3 上页 / 右 1/3 下页)与右缘
|
||||
* 刮擦(reader_scrub_begin,由 touch_down/move 驱动)两条既有路径。 */
|
||||
if (g_ui_open) { g_ui_open = 0; reader_redraw(); return; }
|
||||
if (g_dir_open) { g_dir_open = 0; reader_redraw(); return; }
|
||||
if (g_menu_open) { g_menu_open = 0; reader_redraw(); return; }
|
||||
if (dir == MEOW_SWIPE_LEFT) reader_turn_animated(1);
|
||||
else if (dir == MEOW_SWIPE_RIGHT) reader_turn_animated(-1);
|
||||
if (dir == MEOW_SWIPE_LEFT || dir == MEOW_SWIPE_RIGHT) {
|
||||
reader_reflow_persist();
|
||||
meow_view_page_pop();
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- R3 段刮擦触控(app.c on_touch_down/on_touch_move 路由) ---- */
|
||||
|
||||
@@ -171,7 +171,9 @@ static void shelf_list_tapcb(int idx, int op, void *ctx)
|
||||
if (idx < 0 || idx >= g_nrows || g_rows[idx].section) return;
|
||||
int bi = g_rows[idx].book;
|
||||
if (bi < 0 || bi >= g_nbooks) return;
|
||||
reader_open(g_books[bi].path);
|
||||
/* 点书开读:reader_open 打开书(含页位图)→ push ACT_READER 让阅读页成为 view activity,
|
||||
* 驱动 reader_on_enter/on_leave(重建/释放页位图);「返回书架」/左缘返回走 page_pop 回书架。 */
|
||||
if (reader_open(g_books[bi].path) == 0) meow_view_page_push(ACT_READER);
|
||||
}
|
||||
|
||||
/* ---- grid 数据源(meow_lazygrid,4 列封面卡) ---- */
|
||||
@@ -228,7 +230,7 @@ static void shelf_grid_tapcb(int idx, void *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
if (idx < 0 || idx >= g_nbooks) return;
|
||||
reader_open(g_books[idx].path);
|
||||
if (reader_open(g_books[idx].path) == 0) meow_view_page_push(ACT_READER);
|
||||
}
|
||||
|
||||
/* ---- 控件装配(按当前布局重建 list / grid) ---- */
|
||||
|
||||
@@ -30,8 +30,9 @@ void reader_on_tick(uint64_t now);
|
||||
void reader_on_touch_down(int x, int y); /* R3 段刮擦:右缘拖动快速定位 */
|
||||
void reader_on_touch_move(int x, int y);
|
||||
|
||||
/* 打开一本书(书架调;成功进入阅读页)。path=TXT 完整路径。 */
|
||||
void reader_open(const char *path);
|
||||
/* 打开一本书(书架调;成功后由书架 push ACT_READER 进入阅读页)。path=TXT 完整路径。
|
||||
* 返回 0=成功(书已打开、页位图已备、可 push);非 0=失败(未能打开,调用方不 push)。 */
|
||||
int reader_open(const char *path);
|
||||
|
||||
/* ---- 全局设置页(app/settings.c,C)---- */
|
||||
meow_view *settings_view_create(void);
|
||||
|
||||
Reference in new issue
Block a user