Commit Graph
49 Commits
Author SHA1 Message Date
fanlusky 7d66b2556c feat(server,ui,ui-html): 候选翻译文本支持在皮肤中单独配色
外部皮肤 skin.toml 的 [candidate.dark] / [candidate.light] 新增 translation 键。
不写时沿用候选文字色叠 62% 不透明度;写了就按原值绘制(含选中行)。
D2D(CandidateList::Appearance::translationColor)、WebView2 注入 CSS
和设置页外部皮肤预览三处一致;预览顺带补上此前漏掉的 number 配色。
2026-09-26 23:38:37 +08:00
fanlusky 0b4d9172f8 feat(ui): CandidateList 让贴着列表四角的项使用外框圆角
Appearance 新增 outerCornerRadius 与 outerTopCornersEnabled:选中或悬停的
填充里,真正落在列表四角上的角改用外框半径,其余角保持 cornerRadius。
既支持内缩高亮与外框同 R,也支持整行铺满、只在外框四角处贴合的皮肤。
2026-09-26 21:49:04 +08:00
fanlusky a54e2e08e8 fix(ui): 候选窗高亮行的辅助码与翻译跟随选中文字色
微信绿皮肤下高亮行的辅助码压在 #07C160 绿底上仍是暗色,与 webview 不一致。

候选行绘制里 rowTextSelected/rowLabelSelected 只覆盖候选文字和序号,辅助码
(annotation)和翻译一直无条件使用 appearance_.annotationColor。而皮肤 CSS 里
这两者是 .text 的子节点(.cand-content / .cand-translation),颜色继承自 .text,
选中行的 `.first .text { color: ... }` 会一并覆盖它们——D2D 端分开绘制,这层继承
关系就丢了。

改为在高亮行显式跟随 rowTextSelected,翻译再乘 CSS 的 opacity .62 保持原有观感。
判据是 rowTextSelected 的 alpha,所以各皮肤自动与各自 CSS 对齐:wechat 与
willow_green 白色,graphite #111827/#f1f3f5,fluent 没有 .first .text 覆盖,
沿用普通文字色不变。
2026-09-14 14:45:11 +08:00
Jia Sui 3dea733f64 fix(ui,server): 候选窗 D2D 阴影按皮肤对齐 webview——Card 支持 pass 列表
D2D 候选窗的 Card 阴影是内置 Win11 漫射三层(σ11/6/2.8,α0.42/0.30/0.48):
四边对称、无偏移,紧贴边缘合成 α≈0.49、暗晕铺到 15~20 DIP。webview 端候选窗
皮肤 CSS 用的是带右下偏移的双层软阴影(light: 8px 10px 24px rgba(0,0,0,.18)
+ 2px 3px 8px rgba(0,0,0,.10))。用户实机截图剖面实测:webview 底边峰值 α≈0.16、
D2D 0.41,差 2.5 倍,即「D2D 阴影偏重」的根因。对称三层无论怎么调参都拟合不了
带偏移的衰减曲线;浮动工具栏已有的 SetShadowScale 只缩模糊半径压不了深度
(高斯在边缘恒贡献 α/2)。

给 Card 拆出数据驱动的阴影 API,阴影参数跟皮肤走(与颜色/圆角同模式):

- ui/include/msimeui/Layout.h、ui/src/Layout.cpp:ShadowPass{σ,α,offset} +
  SetShadowPasses(空列表保持内置 Mist 三层,逐位不变)、SetShadowEnabled
  (整体开关,语义对齐 Popup 同名 API)、SetShadowOpacity(uniform 缩 α,与
  SetShadowScale 正交);渲染统一走 DrawGaussianShadowPass,无 device context
  时兜底 DrawLayeredMistShadow
- server/src/window/candidate_presenter.cpp:ApplySkin 按皮肤设阴影——内置四皮肤
  与自定义包用皮肤 CSS 标准对(σ=blur÷2)light {12,0.18,(8,10)}+{4,0.10,(2,3)}、
  dark α .34/.22;默认皮肤 webview 端 body HTML 无 box-shadow,D2D 同步关掉
- 浮动工具栏(scale=0.45)与托盘菜单(全默认)不触新 API,观感不变
- 透明垫余量重验:新 pass 可见范围(α>0.02 阈值)左16/上14/右32/下34 DIP,
  均在左32/上20/右32/下40 垫内,无裁切切痕
2026-09-14 12:34:10 +08:00
fanlusky ee5b50133f fix(ui): 竖排候选窗选中项高亮铺满整行
d2d 渲染下,竖排候选窗被卡片最小宽度撑大时,候选项的自然宽度小于卡片内宽,
选中高亮与命中区域只覆盖到文字宽度,右侧留下大片空白(候选项较长、宽度超过
卡片最小宽度时表现正常)。

根因:候选项行矩形取自按自然宽度测量得到的 itemGeometry。列表虽被拉伸到卡片
内宽,但绘制前 Present 阶段会以窗口宽度重新测量,把每项宽度还原为自然宽度,而
此时排布命中缓存(矩形未变)被跳过,铺满逻辑无法重新生效。

改为在 ItemRect 中直接以列表最终布局宽度 bounds_ 计算竖排行矩形,不再依赖逐项
自然宽度,绘制与命中同时受益,且不受测量/排布缓存影响。右侧留白由卡片内边距
提供,与左侧保持一致。横排路径不变。

新增 GetItemBounds 访问器与三个回归测试,其中一个复刻了 Present 重新测量的时序,
可捕获此前方案的退化。
2026-09-14 02:04:58 +08:00
古明四季 42bfd9fc49 fix(ui): 修复候选列表溢出与换行后的点击区域 2026-09-11 23:34:57 +08:00
Jia Sui 62b4688aa1 feat(ui): DeviceResources 与 Window 支持渲染 DPI 覆写 2026-09-11 22:21:57 +08:00
Jia Sui bd7cf1114d fix(server): D2D 内置皮肤补齐 light 配色,对齐 WebView2 CSS
Signed-off-by: Jia Sui <jsfaint@gmail.com>
2026-09-11 22:19:24 +08:00
Aegon8719 dea9292814 issue-55 候选窗支持可配置的有序回落字体 2026-09-09 18:03:56 +08:00
fanlusky 43555460db fix(server): fall back to text when the icon font lacks the glyph
The floating toolbar and the emoji panel hardcoded "Segoe Fluent Icons",
which ships with Windows 11 only. DirectWrite substitutes a font silently
instead of failing, so on Windows 10 every private-use codepoint the toolbar
draws (U+E982, U+F110, U+F138, ...) rendered as a blank box: the buttons
still worked but no longer showed any state.

Resolve the font per codepoint rather than per family, because "Segoe MDL2
Assets" is a subset of Segoe Fluent Icons and swapping the family alone would
still draw tofu wherever a glyph is missing:
- add msimeui::ResolveIconGlyph(), which probes the installed icon fonts with
  IDWriteFont::HasCharacter() and returns the first family that really carries
  the glyph, or no family at all;
- give every toolbar and tab icon a text label to fall back on (中/英, 半/全,
  简/繁, ...) when neither font has the glyph;
- drop the unused ToolbarIconButton::SetGlyph/SetLabel, which would bypass the
  resolved family.

Add unit tests for the resolver, covering the missing-glyph path that cannot
be reached on a host that has Segoe Fluent Icons installed.
2026-09-08 12:41:01 +08:00
Evan 42238a2af6 style: 用 .clang-format 重排 server / windows / ui / log
一次性重排,无任何行为改动。四个目录各自的 .clang-format 放在仓库里已久,但全组织只有
MSIME-Linux 在 CI 里执行 clang-format 检查,这边 149 个文件里有 149 个不符合自己声明的风格。

已逐文件核对语义等价:去掉空白、注释与相邻字符串字面量拆分之后,全部 149 个文件与重排前逐字节
相同。差异只有三类——缩进与换行、clang-format 补的 } // namespace 结尾注释、以及长字符串被拆成
相邻字面量(C++ 保证自动拼接)。

这个提交会写进 .git-blame-ignore-revs。
2026-09-06 12:13:47 +09:00
fanlusky a0c4daa9ad Allow Card window shadows to scale for compact surfaces
Add Card::SetShadowScale so the Win11 mist shadow can shrink with the
control. The floating toolbar can then keep the same shadow style without
clipping or a oversized host.
2026-09-02 19:12:01 +08:00
fanlusky 2ac86ea0e2 Stop mapping all Unicode through CJK fonts and cut D2D working-set growth
Custom font fallback no longer covers the whole BMP/SIP, so Segoe UI Emoji
can paint color glyphs again; CJK still prefers Noto Sans SC then YaHei.
Drop GaussianBlur compatible targets during BeginDraw (they retained GPU
memory as the candidate window grew), grow the composition swapchain in
64px steps without shrinking, and reuse Card chrome plus cached text
formats instead of reallocating them every layout.
2026-09-02 16:25:54 +08:00
fanlusky 5421c1dd1b Add SVG icon rendering, toggle switch, and font fallback for MenuFlyoutItem
MenuFlyoutItem gains leading SVG icons (ID2D1SvgDocument), an optional
trailing toggle switch, and content-based width measurement so tray-style
menu items match the HTML menu layout. Default UI font is now Noto Sans SC
with Microsoft YaHei fallback via IDWriteFontFallback; CreateTextFormat
gracefully falls back when the primary family is missing.
2026-09-02 16:03:57 +08:00
fanlusky d16f9f3fea Add DirectComposition hosting and candidate-list chrome for the IME window
Adopt an existing HWND, render through D3D11/DXGI/DirectComposition, and
extend CandidateList with horizontal layout, skin colors, click-to-commit,
and a D2D context menu. Preedit TextBlock draws a caret in a fixed insert
slot so neighboring glyphs reflow instead of using letter-spacing; the
default end caret sits slightly after the last character.
2026-09-02 15:29:14 +08:00
fanlusky 64c08a7c02 Adjust some controls for emoji panel. 2026-08-15 02:32:00 +08:00
fanlusky f3c7a9557a Set the initial position setting method for the window. 2026-07-20 23:22:05 +08:00
fanlusky 548330b8cf Make a demo of an on-screen keyboard. 2026-07-15 18:22:50 +08:00
fanlusky 3a41372f24 Adjust font size and some layouts 2026-07-15 15:50:50 +08:00
fanlusky 59a73b8476 Optimize the emoji panel size. 2026-07-15 15:43:58 +08:00
fanlusky 05a4ada19d Optimize the emoji panel. 2026-07-15 15:34:53 +08:00
fanlusky 604cf987b1 emoji panel demo step01 2026-07-15 14:49:36 +08:00
fanlusky 4f62123699 Support image render 2026-07-15 14:39:55 +08:00
fanlusky e210c8eb4c Allow popups to scroll out of view 2026-06-19 13:00:35 +08:00
fanlusky d2ca118d89 Add candidate hover highlight 2026-06-19 11:52:43 +08:00
fanlusky 33350ab7c2 Trim candidate header text metrics 2026-06-19 11:34:30 +08:00
fanlusky 718d4f9559 Align candidate preview typography 2026-06-19 11:06:54 +08:00
fanlusky 41f4571bd2 Add candidate popup keyboard navigation 2026-06-17 20:20:17 +08:00
fanlusky 10cfb70d66 Add candidate popup preview primitives 2026-06-17 19:08:27 +08:00
fanlusky e1156b32e2 Highlight scrollbar on hover 2026-06-17 16:44:51 +08:00
fanlusky 3aa1a650a6 Add centered text alignment for TextBlock 2026-06-16 18:28:50 +08:00
fanlusky f531201154 Fix popup spacing and scroll repositioning 2026-06-16 17:09:32 +08:00
fanlusky 40eb7d297b Cache text layouts for button and list controls 2026-06-16 16:29:24 +08:00
fanlusky 5c7236cfd9 Reuse TextBlock text layouts across measure and render 2026-06-15 06:52:54 +08:00
fanlusky 55293db8d6 Cache render brushes and text formats 2026-06-14 20:05:24 +08:00
fanlusky d951c0e4e6 Revert "Add keyboard navigation and menu list support"
This reverts commit a1d4df897e.
2026-06-14 19:57:00 +08:00
fanlusky a1d4df897e Add keyboard navigation and menu list support 2026-06-14 19:54:34 +08:00
fanlusky 0b8063299a Add ContextMenuHost and right-click popup routing 2026-06-14 19:45:53 +08:00
fanlusky 84b6636f89 Add ComboBox built on the popup overlay system 2026-06-14 19:41:58 +08:00
fanlusky 10b7b94c29 Add popup host and scene overlay popup system 2026-06-14 19:35:51 +08:00
fanlusky d6fde30b88 Add theme system and optimize dirty layout routing 2026-06-14 19:29:15 +08:00
fanlusky db59ca7365 Add parent-child relationship of the control tree and bubble-style invalidation propagation. 2026-06-14 15:17:44 +08:00
fanlusky df881f81bf Add invalidation mechanism 2026-06-14 15:14:03 +08:00
fanlusky 6bb9ca27d8 Add more gui controls, make caret of search box align center in vertical. 2026-06-12 23:48:02 +08:00
fanlusky ff58d90d34 Change the demo page to a scrollable layout and fix the issue of buttons being too wide in the initial state. 2026-06-12 22:53:09 +08:00
fanlusky f183070834 Add some basic controls 2026-06-12 22:42:35 +08:00
fanlusky 56199bdd87 Optimize some style 2026-06-12 19:33:40 +08:00
fanlusky 88f36a0ed9 Fix the issue with DPI conversion. 2026-06-12 15:03:39 +08:00
fanlusky f58839114c Build the basic framework of the project. 2026-06-12 10:03:15 +08:00