feat(image-annotate): v1.7.0 图层面板补齐(缩略图 / 重命名 / 不透明度)
按通读代码后定的顺序处理 P3 剩余项里最有价值的三条。
1) 不透明度真正可调
opacity 字段一直在(合成/合并/导出/快照都读它),但面板没有任何控件能写它,
roadmap 里标的「已有」与事实不符。现在选中层后在该项下方展开滑杆:
- 位图走 canvas 的 CSS opacity(像素不动),导出/合并时乘 globalAlpha,所见即所得
- 文字/形状改完重绘矢量层(不透明度已烘进像素,不能再叠 CSS)
- input 第一次到达才拍快照,一次拖动只产生 1 条历史;双击滑杆复位 100%
- 非 100% 且未选中的层在名字旁挂百分比角标
2) 缩略图 + 双击重命名
- 22px 缩略图(canvas 44 设备像素),等比缩放居中;空图层透出类型图标兜底
- 绘制合批 90ms,避免每次 renderLayerPanel 都重画几十张
- 双击名字改名(Enter 提交 / Esc 放弃),改名期间禁用整项拖动
3) 顺手清理
- 删除 .iwb-layer-color / .iwb-layer-width 两个永远看不见的死控件
(CSS display:none !important 写了三遍),连同绑定与死样式
- pasteImageFromUrl 的 window.alert 改 toast(阻塞弹窗在宿主里会卡整页)
- resetState() 补清 layerMulti / hoverPos / lastClick / lastNameClick / altPicker
关键修正:矢量层不透明度只能乘一次。
drawVectorToCanvas / drawShape 已把 opacity 画进像素,getCompositeCanvas 与
composeUnitsInto 再乘 globalAlpha 就是双倍透明 —— 两处都改为只对位图乘。
验证:harness 133 项全通(新增 4 项)、validate 9/9、产物 331811 B。
harness 的版本断言改为读 package.json,不再硬编码。
This commit is contained in:
1 parent
7c2e23e4e3
commit
3e76f2792e
11 files changed
+593
-105
No files matched your search
@@ -753,17 +753,21 @@
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
/* 图层项 */
|
||||
/* 图层项:整项改成「行 + 可选的不透明度行」,两行都靠 .iwb-layer-row 保持原来的横向排布 */
|
||||
.iwb-layer-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
display: block;
|
||||
padding: 5px 8px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.iwb-layer-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.iwb-layer-item:hover { background: #313244; }
|
||||
.iwb-layer-item.active {
|
||||
background: #313244;
|
||||
@@ -775,9 +779,71 @@
|
||||
.iwb-layer-item.drop-target { outline: 1px dashed #e8a735; background: rgba(232, 167, 53, 0.16); }
|
||||
/* 画笔/橡皮作用目标:与「选中」分离,避免出现两个图层同时高亮 */
|
||||
.iwb-layer-paint { flex: 0 0 auto; color: #a6adc8; font-size: 11px; opacity: 0.85; }
|
||||
.iwb-layer-color { width: 22px; height: 22px; padding: 0; border: 1px solid #45475a; border-radius: 50%; background: transparent; cursor: pointer; flex: 0 0 auto; }
|
||||
.iwb-layer-width { width: 42px; height: 22px; padding: 2px 3px; border: 1px solid #45475a; border-radius: 4px; background: #1e1e2e; color: #e8a735; font-size: 11px; text-align: center; flex: 0 0 auto; }
|
||||
.iwb-layer-width:focus { outline: none; border-color: #e8a735; }
|
||||
/* 不透明度角标:只有非 100% 才出现,一眼看出哪层被调淡了 */
|
||||
.iwb-layer-op { flex: 0 0 auto; font-size: 10px; color: #a6adc8; font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* 缩略图:canvas 画内容,类型图标垫在下面当兜底(空图层的缩略图是全透明的) */
|
||||
.iwb-layer-thumb {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
background-color: #1e1e2e;
|
||||
background-image: linear-gradient(45deg, #33334a 25%, transparent 25%), linear-gradient(-45deg, #33334a 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #33334a 75%), linear-gradient(-45deg, transparent 75%, #33334a 75%);
|
||||
background-size: 8px 8px;
|
||||
background-position: 0 0, 0 4px, 4px -4px, -4px 0;
|
||||
box-shadow: inset 0 0 0 1px #45475a;
|
||||
}
|
||||
.iwb-layer-thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
|
||||
.iwb-layer-thumb .iwb-layer-icon {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #7f849c;
|
||||
}
|
||||
|
||||
/* 不透明度行:只出现在选中项下,拖动时不能被重绘打断 */
|
||||
.iwb-layer-op-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 4px 0 1px 26px;
|
||||
}
|
||||
.iwb-layer-opacity {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
height: 14px;
|
||||
accent-color: #e8a735;
|
||||
cursor: pointer;
|
||||
}
|
||||
.iwb-layer-op-val {
|
||||
flex: 0 0 auto;
|
||||
width: 32px;
|
||||
text-align: right;
|
||||
font-size: 10px;
|
||||
color: #a6adc8;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 可重命名的图层名:悬停给个提示,进入编辑时换成输入框 */
|
||||
.iwb-layer-name.renamable:hover { color: #e8a735; }
|
||||
.iwb-layer-name-input {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
padding: 1px 4px;
|
||||
border: 1px solid #e8a735;
|
||||
border-radius: 3px;
|
||||
background: #1e1e2e;
|
||||
color: #cdd6f4;
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.iwb-layer-vis {
|
||||
background: none;
|
||||
@@ -865,7 +931,6 @@
|
||||
.iwb-editor-panel-width { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #a6adc8; font-size: 11px; }
|
||||
.iwb-editor-panel-width-range { flex: 1; min-width: 60px; }
|
||||
.iwb-editor-panel-width-num { width: 42px; padding: 3px; background: #313244; color: #e8a735; border: 1px solid #45475a; border-radius: 4px; text-align: center; }
|
||||
.iwb-layer-color, .iwb-layer-width { display: none !important; }
|
||||
|
||||
/* 顶部独立操作区,避免操作按钮被竖向工具栏裁切 */
|
||||
.iwb-editor-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; flex: 0 0 auto; }
|
||||
@@ -917,12 +982,10 @@
|
||||
.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }
|
||||
.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }
|
||||
.iwb-editor-footer { display: none !important; }
|
||||
.iwb-layer-color, .iwb-layer-width { display: none !important; }
|
||||
|
||||
.iwb-editor-export-actions { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }
|
||||
.iwb-editor-export-actions .iwb-editor-btn { padding: 6px 10px; font-size: 11px; }
|
||||
.iwb-editor-footer { display: none !important; }
|
||||
.iwb-layer-color, .iwb-layer-width { display: none !important; }
|
||||
|
||||
/* 顶部七个操作按钮统一文本按钮样式,自适应中文宽度。 */
|
||||
.iwb-editor-actions { gap: 6px; }
|
||||
|
||||
Reference in new issue
Block a user