fix(image-annotate): v1.9.1 文字输入框贴住点击点、选区图标归位、底色一选就生效

1) 输入框偏到左上:showTextInput 用 canvasStack 的矩形换算,但 stack 尺寸是
(imgW + 2*overlayPad)*scale、图片在 stack 内还偏移 pad*scale(图层 canvas 的
left/top)。比例偏小又漏偏移,两个误差同向叠加。改用 textCanvas 的矩形
(与图层 canvas 同基准,精确等于图片显示区域),并按 textarea 的边框 2px +
内边距 8/4px 反向偏移,让输入框里的文字起点正压在点击点上;提交后
drawTextObject 也从 t.x/t.y 起画,所见即所得。

2) 选「选择」工具后三个选区图标不见了:两处叠加。
   - selCmdHTML 排在 hint 之后,而 .iwb-opt-hint 带 margin-left:auto;
   - 更关键的是 .iwb-opt-sep 写成 margin: 0 4px 0 auto,分隔线自带 auto,
     会把分隔线之后的内容整组推到最右,选项栏排满时直接滚出可视区。
修法:分隔线只分组(margin: 0 2px),留白交给末尾 hint;选区按钮排在 hint 之前。
现在「文字」「选择」两个工具下都是同一组三个图标,未选中元素时也在。

3) 设了底色看不到:底色一直在画,只是「只改颜色没点开关」时 bgFill 仍是 false。
   - 改 bgColor 时自动打开 bgFill,按钮 active 同步;
   - 顺带修掉更硬的 bug:「底色」按钮只能开不能关 —— data-value 在生成 HTML 时
     写死,状态变了没人更新,每次点都传「开启」。改由 syncOptionBar 按当前状态翻面;
   - 默认底色透明度 0.55 → 0.68(浅色/花色底图上 0.55 太透,容易被当成没生效)。

harness 158 → 162 条全通(新增输入框落点误差 ≤3px、Esc 不留空对象、
选择工具未选中仍有 3 个图标、只选颜色即自动开底色);validate 9/9。
This commit is contained in:
qiqi committed 2026-11-08 20:53:58 +08:00
1 parent e699c22fa0
commit 73a29715d3
9 files changed
+169 -28

No files matched your search

+5 -1
View File
@@ -1674,7 +1674,11 @@
.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:hover:not(:disabled) { background: #45475a; }
.iwb-editor-header > .iwb-editor-commands .iwb-editor-layer-btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* 选区命令(全选/反选/取消):v1.2.5 起放在「选择」工具的选项栏里,不再占竖工具条 */
.iwb-opt-sep { width: 1px; height: 18px; background: #313244; margin: 0 4px 0 auto; flex: 0 0 auto; }
/* 分隔线只负责「分组」,不负责「推到右边」。
原来写的是 margin: 0 4px 0 auto —— auto 会把分隔线之后的内容整组推到最右侧,
在选项栏已经排满的情况下(文字样式那一行)直接把后面的选区按钮顶出可视区,
看起来就是「这个工具下没有那几个按钮」。留白交给末尾的 .iwb-opt-hint。 */
.iwb-opt-sep { width: 1px; height: 18px; background: #313244; margin: 0 2px; flex: 0 0 auto; }
.iwb-opt-selcmd {
width: 26px; height: 26px; min-width: 26px; padding: 0; border: 0; border-radius: 7px;
background: #26263a; color: #cdd6f4; flex: 0 0 auto;