feat(sdk): 控件库第二批 Material 子集(agent-152)

- 新增控件: Button五型(filled/tonal/outlined/text/elevated)/TextField(接IME: round外框idle-outline/focused-primary+占位+光标)/Card/Divider/Badge/Checkbox/Radio/ProgressBar(线圆, value=-1不定)/FAB/TopAppBar(标题+‹返回+动作)/NavigationBar(TabBar pageSwitcher)+TabBar(下划线)/LazyColumn/LazyRow(虚拟化+scroll clamp)
- Dialog(B③同构阻塞模态)/BottomSheet(B④), meow_ui_dialog.c
- meow_gfx 新增 fill_circle/line/ring_arc(无-lm, COS90象限查表)
- 结构体尾缀(对外opaque/calloc归零), 旧字段与create签名零破坏; meow_widget 类型扩到W_TEXTFIELD..W_FAB(17种)
- meow_ui.a=18c21da5 hello=5e31d919 launcher=4952261d(重编重链无回归); build_sdk 0warning; 宿主 test_meow_ui_widgets 全PASS+test_sb_collapse PASS+PPM目检正确
- 与 §5.8/§5.2-5.7 一致; 遗留真机观感/性能
This commit is contained in:
MeowOS committed 2026-08-30 22:33:51 +08:00
1 parent 2cb6a7c16f
commit 9c733fcf73
10 files changed
+1360 -24

No files matched your search

+99 -1
View File
@@ -311,7 +311,6 @@ void meow_ui_fill_rect(int x, int y, int w, int h, uint32_t color)
{
if (!g_init_ok) return;
if (w <= 0 || h <= 0) return;
int x0 = x, y0 = y;
if (x < 0) { w += x; x = 0; }
if (y < 0) { h += y; y = 0; }
if (x >= g_xres || y >= g_yres) return;
@@ -394,6 +393,105 @@ void meow_ui_draw_rect_round(int x, int y, int w, int h, int r, uint32_t color)
dirty_add(x1, y1, x2 - x1, y2 - y1);
}
/* ================= §5.8.6 batch2:圆形/线段/圆弧环(软渲,无 -lm) =================
* 无 GPU 合成、构建只链 libz+pthread(无 -lm),故不用 math.h:COS 用象限对称查表、
* 圆用 bbox 距离测试、弧带用「沿弧采样成粗线(圆帽)」近似。 */
static const int m_cos90[91] = {
1024,1024,1023,1023,1022,1020,1018,1016,
1014,1011,1008,1005,1002,998,994,989,
984,979,974,968,962,956,949,943,
935,928,920,912,904,896,887,878,
868,859,849,839,828,818,807,796,
784,773,761,749,737,724,711,698,
685,672,658,644,630,616,602,587,
573,558,543,527,512,496,481,465,
449,433,416,400,384,367,350,333,
316,299,282,265,248,230,213,195,
178,160,143,125,107,89,71,54,
36,18,0,
};
static int m_cos_deg(int deg) /* 任意角度(可负)→ cos(deg)*1024 */
{
int a = deg % 360;
if (a < 0) a += 360;
if (a <= 90) return m_cos90[a];
if (a <= 180) return -m_cos90[180 - a];
if (a <= 270) return -m_cos90[a - 180];
return m_cos90[360 - a];
}
static int m_sin_deg(int deg) { return m_cos_deg(90 - deg); }
void meow_gfx_fill_circle(int cx, int cy, int r, uint32_t color)
{
if (!g_init_ok || r <= 0) return;
int x1 = cx - r, y1 = cy - r, x2 = cx + r + 1, y2 = cy + r + 1;
if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0;
if (x2 > g_xres) x2 = g_xres; if (y2 > g_yres) y2 = g_yres;
if (x2 <= x1 || y2 <= y1) return;
int r2 = r * r;
for (int py = y1; py < y2; py++) {
int dy = py - cy;
for (int px = x1; px < x2; px++) {
int dx = px - cx;
if (dx * dx + dy * dy <= r2) put_px(px, py, color);
}
}
dirty_add(x1, y1, x2 - x1, y2 - y1);
}
void meow_gfx_line(int x0, int y0, int x1, int y1, int th, uint32_t color)
{
if (!g_init_ok) return;
int dx = x1 - x0, dy = y1 - y0;
int adx = dx < 0 ? -dx : dx, ady = dy < 0 ? -dy : dy;
int steps = (adx > ady ? adx : ady) + 1;
if (steps <= 1) { meow_gfx_fill_circle(x0, y0, th / 2 + 1, color); return; }
int cap = th / 2;
if (cap < 1) cap = 1;
for (int i = 0; i <= steps; i++) {
int x = x0 + dx * i / steps;
int y = y0 + dy * i / steps;
if (cap <= 1) put_px(x, y, color);
else meow_gfx_fill_circle(x, y, cap, color);
}
}
void meow_gfx_ring_arc(int cx, int cy, int r, int th, int start_deg, int sweep_deg, uint32_t color)
{
if (!g_init_ok || r <= 0) return;
int sw = sweep_deg % 360;
if (sw < 0) sw += 360;
if (sw >= 360) { /* 整环:bbox 距离带(无角度判定,最快) */
int r1 = r - th / 2, r2 = r + th / 2;
if (r1 < 0) r1 = 0;
int x1 = cx - r2, y1 = cy - r2, x2 = cx + r2 + 1, y2 = cy + r2 + 1;
if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0;
if (x2 > g_xres) x2 = g_xres; if (y2 > g_yres) y2 = g_yres;
if (x2 <= x1 || y2 <= y1) return;
for (int py = y1; py < y2; py++)
for (int px = x1; px < x2; px++) {
int dx = px - cx, dy = py - cy;
int d2 = dx * dx + dy * dy;
if (d2 >= r1 * r1 && d2 <= r2 * r2) put_px(px, py, color);
}
dirty_add(x1, y1, x2 - x1, y2 - y1);
return;
}
/* 弧带:沿弧采样相邻点、粗线连接(圆帽)近似。方向:deg 右(0)→上(90)→左(180)→下(270),顺时针。 */
int n = sw / 2 + 1;
if (n < 2) n = 2;
int px = cx + (m_cos_deg(start_deg) * r) / 1024;
int py = cy - (m_sin_deg(start_deg) * r) / 1024; /* 屏幕 y 向下 → sin 取负 */
for (int i = 1; i <= n; i++) {
int deg = start_deg + sw * i / n;
int nx = cx + (m_cos_deg(deg) * r) / 1024;
int ny = cy - (m_sin_deg(deg) * r) / 1024;
meow_gfx_line(px, py, nx, ny, th, color);
px = nx; py = ny;
}
}
void meow_ui_fill_rect_alpha(int x, int y, int w, int h, uint32_t color, int alpha)
{
if (!g_init_ok) return;