feat: thumbnail grid, aspect-aware templates, and UI hierarchy polish

Material list:
- Switch asset list from one-per-row to a wrapping thumbnail grid
  (IconMode cards: thumbnail + corner checkbox + elided name, subfolder
  moved to tooltip).

Templates:
- Template.to_transform_state now contains-fits the print inside the
  target box by the print's native aspect ratio (no stretch); falls back
  to the box when print size is unknown.
- Feed print native size into template_panel for aspect-aware fitting.
- Shrink built-in template boxes to realistic print proportions.

UI hierarchy:
- Promote 打开文件夹 buttons to primary (filled accent).
- Add inline 归零 (reset angle) and a 重置位置/尺寸/角度 button to the
  transform panel; wire it to re-apply the selected template.
- Hide 保存 for built-in templates instead of leaving it greyed.

Docs: record template box/contain behavior (PRD) and the grid layout,
button hierarchy, and reset/save-visibility rules (UI design).
Tests: add 3 aspect-fit cases for to_transform_state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 15:11:56 +08:00
co-authored by Claude Opus 4.8
parent df9145abdb
commit 8a34fe93ff
9 changed files with 273 additions and 78 deletions
+9 -5
View File
@@ -67,19 +67,21 @@
模板是一组可复用的合成参数。
模板字段:
模板使用**比例坐标**存储,以适配任意尺寸的衣服底图(字段为相对衣服宽高的比例 `x_ratio` / `y_ratio` / `width_ratio` / `height_ratio` 及 `rotation`),应用时再换算为像素:
```json
{
"name": "左胸小号模板",
"x": 120,
"y": 180,
"width": 160,
"height": 160,
"x_ratio": 0.50,
"y_ratio": 0.22,
"width_ratio": 0.16,
"height_ratio": 0.16,
"rotation": 0
}
```
其中 `width_ratio` / `height_ratio` 表示目标框,而非印花最终尺寸;印花在框内按原始宽高比 contain 适配(详见 6.6)。
## 6. 功能需求
### 6.1 图片加载
@@ -159,6 +161,8 @@
- 用户点击模板后,印花位置、尺寸、旋转参数立即应用到当前预览。
- 模板参数应基于衣服底图尺寸计算,避免只适配单一图片分辨率。
- 模板的 `width_ratio` / `height_ratio` 定义衣服上的**目标框**,而非强制拉伸尺寸。已知印花原始尺寸时,印花按自身宽高比缩放后 contain 进目标框并居中,不被拉伸变形;未知印花尺寸时退化为铺满目标框。
- 内置模板尺寸以贴近真实印花占比为准(例如正方形模板约为衣服宽度的 1/3),避免印花占据过大面积。
### 6.7 自定义模板