From 6bab3046609ecb968873600af76af6fa9508a62f Mon Sep 17 00:00:00 2001 From: AskaEth Date: Fri, 4 Sep 2026 03:53:09 +0800 Subject: [PATCH] =?UTF-8?q?style(launcher):=20=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B8=83=E5=B1=80(home=5Flayout=3Dlist)?= =?UTF-8?q?=E5=9C=86=E8=A7=92=E5=8D=A1=E5=8A=A08px=E5=A4=96=E8=B7=9D(MENU?= =?UTF-8?q?=5FLIST=5FROW=5FGAP+menu=5Frow=5Fcard=5Fy/h=E5=8D=A1=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E5=AF=B9=E7=A7=B0=E5=86=85=E7=BC=A9=E8=A1=8C=E8=B7=9D?= =?UTF-8?q?=E4=B8=8D=E5=8F=98)=20=E2=80=94=20=E5=9C=86=E8=A7=92=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B9=E7=B4=A7=E8=B4=B4=E4=BF=AE=E5=A4=8D;?= =?UTF-8?q?=E5=85=B6=E4=BD=99=E6=89=81=E5=B9=B3=E8=A1=8C(Material=E6=A0=87?= =?UTF-8?q?=E5=87=86)=E6=9C=AA=E5=8A=A8;test=5Fmenu=5Frow=5Fgap=20PASS,0wa?= =?UTF-8?q?rning,=E4=B8=8D=E5=8A=A8meow=5Fui.a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patch_v2/meow_launcherd/test_menu_row_gap.c | 67 +++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 patch_v2/meow_launcherd/test_menu_row_gap.c diff --git a/patch_v2/meow_launcherd/test_menu_row_gap.c b/patch_v2/meow_launcherd/test_menu_row_gap.c new file mode 100644 index 0000000..206c722 --- /dev/null +++ b/patch_v2/meow_launcherd/test_menu_row_gap.c @@ -0,0 +1,67 @@ +/* meow_launcherd/test_menu_row_gap.c — 宿主验证:主界面列表模式圆角卡列表项外边距 + * (item margin/gap)几何。纯整数运算,不链 SDK / 不开设备: + * gcc test_menu_row_gap.c -o test_menu_row_gap && ./test_menu_row_gap + * + * 断言集(对应「相邻 item 顶之间 = item 高 + gap」的可见形式): + * ① 相邻卡顶间距 = MENU_LIST_ROW_H(= 卡高 + gap;SDK 行距不变); + * ② 卡片间可见外距 = MENU_LIST_ROW_GAP; + * ③ 卡在其行高内上下对称内缩 → 内容(按行高垂直居中)落卡中心; + * ④ 滚动偏移只整体平移,不改变上述间距/对称。 + * + * 几何公式与 patch_v2/meow_launcherd/main_menu.c 的 menu_row_card_y/menu_row_card_h 同源: + * 卡顶 = 行顶 + gap/2;卡高 = 行高 - gap。 + */ +#include +#include + +#define MENU_LIST_ROW_H 60 /* 行距(SDK listview item_h,不变) */ +#define MENU_LIST_ROW_GAP 8 + +/* 与 main_menu.c menu_row_card_y / menu_row_card_h 同源(上下对称内缩)。 */ +static int menu_row_card_y(int row_top) { return row_top + MENU_LIST_ROW_GAP / 2; } +static int menu_row_card_h(int h) { return h - MENU_LIST_ROW_GAP; } +/* 行顶 = list_y + idx*item(SDK listview 布局:行距=item)。 */ +static int row_top(int idx, int item, int list_y, int off) { return list_y + idx * item - off; } + +int main(void) +{ + const int item = MENU_LIST_ROW_H; + const int gap = MENU_LIST_ROW_GAP; + const int list_y = 100; + + int y0 = menu_row_card_y(row_top(0, item, list_y, 0)); + int y1 = menu_row_card_y(row_top(1, item, list_y, 0)); + int h = menu_row_card_h(item); + + /* ① 卡相对行顶对称内缩 gap/2;卡高=item-gap;卡高+gap=item */ + assert(y0 == list_y + gap / 2); + assert(h == item - gap); + assert(h + gap == item); + + /* ① 相邻卡顶间距 = item(顶到顶 = 卡高 + gap) */ + assert(y1 - y0 == item); + + /* ② 卡片间可见外距 = gap(卡 0 底 到 卡 1 顶) */ + assert(y1 - (y0 + h) == gap); + + /* ③ 卡中心 == 行中心(内容按行高居中 → 落卡中心) */ + assert(y0 - gap / 2 + item / 2 == y0 + h / 2); + /* 上行底到卡底 = gap/2(下对称) */ + assert((list_y + item) - (y0 + h) == gap / 2); + + /* ④ 滚动偏移只平移,不改变间距/对称(任意 off) */ + for (int off = 0; off <= 2 * item; off += item / 2) { + int r2 = row_top(2, item, list_y, off); + int r3 = row_top(3, item, list_y, off); + int a2 = menu_row_card_y(r2); + int a3 = menu_row_card_y(r3); + assert(a3 - a2 == item); + assert(a3 - (a2 + h) == gap); + assert(a2 - r2 == gap / 2); + assert((r2 + item) - (a2 + h) == gap / 2); + } + + printf("PASS menu_row_gap=%d card_h=%d top2top=%d visible_gap=%d symmetric=1\n", + gap, h, item, gap); + return 0; +}