Skip to content

feat(ui): support an image behind the candidate panel (back_image) - #1192

Open
IrisRainbowNeko wants to merge 1 commit into
rime:masterfrom
IrisRainbowNeko:feat/back-image
Open

IrisRainbowNeko wants to merge 1 commit into
rime:masterfrom
IrisRainbowNeko:feat/back-image

Conversation

@IrisRainbowNeko

Copy link
Copy Markdown

Implements the request in #743, kept small and opt-in.

A color scheme can now draw an image behind the panel, as image themes do in Fcitx5 and Weasel skins. Three optional keys under preset_color_schemes/<name>:

back_image: skins/panel.png      # relative to the Rime user directory; ~ is expanded
back_image_slice: { left: 40, right: 60, top: 20, bottom: 30 }     # nine-slice, in image points
back_image_padding: { left: 30, right: 50, top: 16, bottom: 24 }   # room around the panel where only the image shows
  • The corners of the slice keep their size, the edges and the center stretch (CALayer.contentsCenter). HiDPI images are drawn at their point size.
  • The panel itself is unchanged and sits inside the padding; back_color: 0x00ffffff lets the image show under the candidates.
  • The window is never smaller than the fixed corners; extra room goes to the right and bottom so the panel stays at the caret.
  • The image stays upright in vertical mode, and is not used in full-screen mode.
  • Schemes without back_image behave exactly as before: the image layer stays hidden and the padding is zero.

The change is small (3 files, +93/-11): two NSEdgeInsets and a CGImage in SquirrelTheme, and in SquirrelPanel a panelView that holds the existing views and is inset by the padding, with an image view under it.

Tested on GitHub arm64 runners — this branch on macOS 26, the same change backported to 1.1.2 on macOS 15 — by showing SquirrelPanel with a test image (colored corners of different sizes, striped center) in linear, stacked, vertical and single-candidate layouts and capturing the window. SwiftLint and Periphery report nothing new.

在配色方案中可用一张图片作候选窗背景(九宫格拉伸),对应 #743 的需求;不设 back_image 时行为不变。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant