fix(lyric): 全局播放页进度条/按钮带局部重绘回退默认色修复 — 取色主题抽共用(np_grad_row/np_page_bg_row/np_theme_widgets),1s局部重绘也接取色(带底色渐变/进度条fill=accent/track=fg_dim/四钮accent);SDK W_PROGRESS改读opts.bg/fg向后兼容;宿主R1-R3 PASS,0warning;需重编meow_ui.a+四App重链

This commit is contained in:
AskaEth committed 2026-09-03 23:28:37 +08:00
1 parent 8971f6067b
commit a82f3f9dfa
5 files changed
+180 -30

No files matched your search

@@ -25,6 +25,7 @@
#include "meow_ui_internal.h" /* meow_ui_back_buf/pitch/bpp */
#include "np_gesture.h" /* 批4:双页方向感知手势决策(纯逻辑,宿主可单测) */
#include "meow_lyric_view.h" /* 批2:歌词页控件(批4接入,数据批3 meow_media_lyric_*) */
#include "meow_img_color.h" /* 批5b:封面取色主题派生(局部重绘进度条/按钮带取色用例) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,6 +60,8 @@ static void rd_px(int x, int y, unsigned short *p)
else *p = (unsigned short)(*(unsigned int *)(bb + (size_t)y * line + (size_t)x * 4) >> 16);
}
static unsigned short px565(int x, int y) { unsigned short p; rd_px(x, y, &p); return p; }
static unsigned short rgb565(uint32_t c)
{ return (unsigned short)(((c >> 8) & 0xF800) | ((c >> 5) & 0x07E0) | ((c >> 3) & 0x001F)); }
static int region_nonbg(int x, int y, int w, int h, uint32_t bg)
{
unsigned short bg565 = ((bg >> 8) & 0xF800) | ((bg >> 5) & 0x07E0) | ((bg >> 3) & 0x001F);
@@ -179,6 +182,103 @@ int main(void)
}
}
/* ============ R1 批5b:局部重绘取色——进度条 fill=accent/track=fg_dim + 默认回退 ============
* 镜像 np_theme_widgets(取色有效→进度条 opts.bg=fg_dim/opts.fg=accent)+ np_draw_progress。
* 用「直接 fill_rect 参考像素」对比,绕开 565 精度差异(同一渲染器同色 → 同 565)。 */
printf("R1 progress cover-theme fill/track + default fallback\n");
meow_ui_set_style(MEOW_STYLE_MD3);
meow_theme_set_mode(MEOW_THEME_DARK);
th = meow_theme_get();
meow_img_color_theme cc; memset(&cc, 0, sizeof cc);
meow_img_color_derive(0xE53935u, 0x1E88E5u, th, &cc); /* 红/蓝两色 → 派生取色主题 */
/* 覆盖取色:进度条 fill=accent / track=fg_dim */
{
meow_widget_opts op; memset(&op, 0, sizeof op);
op.bg = cc.fg_dim; op.fg = cc.accent;
meow_widget_set_opts(prog, &op);
meow_ui_clear(0);
meow_ui_fill_rect(NP_PROG_X, NP_PROG_Y, 5, 6, cc.accent); /* fill 参考 */
unsigned short ref_fill = px565(NP_PROG_X + 2, NP_PROG_Y + 3);
meow_ui_clear(0);
meow_ui_fill_rect(NP_PROG_X + NP_PROG_W - 4, NP_PROG_Y, 3, 6, cc.fg_dim); /* track 参考 */
unsigned short ref_track = px565(NP_PROG_X + NP_PROG_W - 3, NP_PROG_Y + 3);
meow_ui_clear(0);
meow_progress_set(prog, 50);
meow_widget_draw(prog);
int fill_x = NP_PROG_X + NP_PROG_W / 4; /* 50% 填充区内 */
int track_x = NP_PROG_X + NP_PROG_W - 4; /* 尾部轨道区 */
CHECK(px565(fill_x, NP_PROG_Y + 3) == ref_fill, "cover: progress fill == accent");
CHECK(px565(track_x, NP_PROG_Y + 3) == ref_track, "cover: progress track == fg_dim");
/* 默认回退:清 opts → 回到主题 primary/surfaceVariant(无取色回退默认) */
memset(&op, 0, sizeof op);
meow_widget_set_opts(prog, &op);
meow_ui_clear(0);
meow_ui_fill_rect(NP_PROG_X, NP_PROG_Y, 5, 6, th->primary);
unsigned short ref_pri = px565(NP_PROG_X + 2, NP_PROG_Y + 3);
meow_ui_clear(0);
meow_progress_set(prog, 50);
meow_widget_draw(prog);
CHECK(px565(fill_x, NP_PROG_Y + 3) == ref_pri, "default: progress fill == theme primary");
CHECK(px565(fill_x, NP_PROG_Y + 3) != ref_fill, "default vs cover fill differ");
}
/* ============ R2 批5b:进度/按钮带底色随取色渐变(非默认 surface) ============
* 镜像 np_repaint_progress 的带底色分支(np_page_bg_row 按整页 span 插值)。
* 旧 bug:本地重绘用 th->surface 清带 → 带内被刷成默认色;现应取色渐变且 != surface。 */
printf("R2 band background uses cover gradient (not default surface)\n");
{
#define NP_SB_H 28
int H = 720;
meow_ui_clear(0);
for (int yy = NP_TIME_Y; yy < NP_BTN_Y + NP_PLAY_R; yy++) {
int t = (H - NP_SB_H <= 1) ? 0 : (yy - NP_SB_H) * 255 / (H - NP_SB_H - 1);
if (t < 0) t = 0; else if (t > 255) t = 255;
int tr = (cc.bg_top >> 16) & 255, tg = (cc.bg_top >> 8) & 255, tb = cc.bg_top & 255;
int br = (cc.bg_bottom >> 16) & 255, bg = (cc.bg_bottom >> 8) & 255, bb = cc.bg_bottom & 255;
int r = tr + ((br - tr) * t + 128) / 255;
int g = tg + ((bg - tg) * t + 128) / 255;
int b = tb + ((bb - tb) * t + 128) / 255;
meow_ui_fill_rect(0, yy, 480, 1, ((uint32_t)r << 16) | ((uint32_t)g << 8) | (uint32_t)b);
}
unsigned short bandpx = px565(10, NP_TIME_Y + 55);
CHECK(bandpx != rgb565(th->surface), "cover: band bg != default surface");
CHECK(bandpx != 0, "cover: band bg rendered");
}
/* ============ R3 批5b:控制三钮(含 prev/next)随取色 accent + 默认回退 ============
* 镜像 np_theme_widgets:取色有效→四钮 opts.bg=accent/opts.fg=accent_fg(prev/next 不再默认底色)。 */
printf("R3 control buttons follow cover accent\n");
{
meow_widget_opts op; memset(&op, 0, sizeof op);
op.bg = cc.accent; op.fg = cc.accent_fg;
meow_widget_set_opts(prev, &op);
meow_widget_set_opts(next, &op);
meow_widget_set_opts(play, &op);
meow_widget_set_opts(pause, &op);
meow_ui_clear(0);
meow_ui_fill_rect(NP_PREV_CX - 2, NP_BTN_Y - 18, 4, 2, cc.accent); /* accent 参考(圆底上方、图标外) */
unsigned short ref_acct = px565(NP_PREV_CX, NP_BTN_Y - 17);
meow_ui_clear(0);
meow_widget_draw(prev); /* r=22,cy-17 在圆内且高于图标(cy-13) */
CHECK(px565(NP_PREV_CX, NP_BTN_Y - 17) == ref_acct, "cover: prev bg == accent");
meow_ui_clear(0);
meow_widget_draw(play); /* r=30,cy-26 在圆内且高于图标(cy-18) */
CHECK(px565(NP_PLAY_CX, NP_BTN_Y - 26) == ref_acct, "cover: play bg == accent");
/* 默认回退:清 prev/next opts → 回 surfaceContainerLow(无取色不回归旧形态) */
memset(&op, 0, sizeof op);
meow_widget_set_opts(prev, &op);
meow_widget_set_opts(next, &op);
meow_ui_clear(0);
meow_ui_fill_rect(NP_PREV_CX - 2, NP_BTN_Y - 18, 4, 2, th->surfaceContainerLow);
unsigned short ref_def = px565(NP_PREV_CX, NP_BTN_Y - 17);
meow_ui_clear(0);
meow_widget_draw(prev);
CHECK(px565(NP_PREV_CX, NP_BTN_Y - 17) == ref_def, "default: prev bg == surfaceContainerLow");
}
/* ============ G5 双页手势方向感知(np_gesture.h,纯逻辑) ============ */
printf("G5 dual-page direction-aware gestures\n");
/* 播放页:右→左滑 → 进歌词页 */