「仓输入法皮肤」迁移指南
背景及前景样式添加 buttonStyleType 参数
Section titled “背景及前景样式添加 buttonStyleType 参数”新增必选参数 buttonStyleType,用于设定样式的类型。
确保背景样式(backgroundStyle)及前景样式(foregroundStyle)中都指定了 buttonStyleType 参数,否则无法解析已定义的样式。
示例:
# 改造前foregroundStyle: qButtonForegroundStyleqButtonForegroundStyle: text: "q"
# 改造后
foregroundStyle: qButtonForegroundStyleqButtonForegroundStyle: buttonStyleType: text text: "q"根据你想要添加的样式内容,为 buttonStyleType 指定相应的值,具体内容请查阅 buttonStyleType 配置参考。
在新版中,文字样式的初始位置为「居中」对齐。如果之前为文字样式添加了 center 属性,需要将其移除或者调整其值,使文字显示在您想要的位置。
JavaScript 脚本内容移除
Section titled “JavaScript 脚本内容移除”在新版中,皮肤中的 JavaScript 脚本功能已被废除。这意味着之前通过 JavaScript 动态生成的样式名称或文本内容将不再有效。
- 事件通知:用来监听某个键盘的状态变化,当状态改变时,更新相应的样。使用场景:根据输入了某个按键,切换另一个按键的样式;回车键根据环境变化。
- 条件样式:用来初始化按键的样式,根据某个条件来决定使用哪种样式。使用场景:中英切换,简繁切换。
示例:
lockButton: backgroundStyle: systemButtonBackgroundStyle
foregroundStyle: |- // JavaScript function getText() { return $getSymbolicKeyboardLockState() ? "lockButtonForegroundStyle" : "unlockButtonForegroundStyle"; }
lockButtonForegroundStyle: systemImageName: "lock" normalColor: 000000 highlightColor: 000000 fontSize: 20
unlockButtonForegroundStyle: systemImageName: "lock.open" normalColor: 000000 highlightColor: 000000 fontSize: 20lockButton: backgroundStyle: systemButtonBackgroundStyle
foregroundStyle: - { styleName: unlockButtonForegroundStyle, conditionKey: $symbolicKeyboardLockState, conditionValue: false, } - { styleName: lockButtonForegroundStyle, conditionKey: $symbolicKeyboardLockState, conditionValue: true, }
lockButtonForegroundStyle: buttonStyleType: systemImage systemImageName: "lock" normalColor: 000000 highlightColor: 000000 fontSize: 20
unlockButtonForegroundStyle: buttonStyleType: systemImage systemImageName: "lock.open" normalColor: 000000 highlightColor: 000000 fontSize: 20按键长按显示符号样式调整
Section titled “按键长按显示符号样式调整”在新版本中使用 hintSymbolsStyle(旧版本为:holdSymbolsStyle)来定义按键长按时显示的符号样式。
示例:
qButton:
holdSymbolsStyle: qButtonHoldSymbolsStyle
hintSymbolsStyle: qButtonHintSymbolsStyle同时,里面的参数也发生了一些变化。
- 新增可选
size参数,可自定义符号列表中符号的大小,如果不指定,默认与当前按键的可视区域大小相同。 - 旧版本使用
selectedStyle定义选中后的符号高亮样式,新版本中使用selectedBackgroundStyle参数。 - 旧版本使用
foregroundStyle与actions联合定义一个符号的外观及它的行为。新版本新增symbolStyles参数,用于定义长按后显示的每个符号的样式。
qButtonHoldSymbolsStyle: backgroundStyle: alphabeticHoldSymbolsBackgroundStyle
foregroundStyle: - qButtonHoldSymbolsOfqForegroundStyle - qButtonHoldSymbolsOf1ForegroundStyle - qButtonHoldSymbolsOfQForegroundStyle actions: - { character: q } - { symbol: 1 } - { character: Q }
selectedStyle: alphabeticHoldSymbolsSelectedStyle selectedIndex: 0qButtonHintSymbolsStyle:
size: width: 50 height: 50 insets: { top: 4, bottom: 4, left: 4, right: 4 }
backgroundStyle: alphabeticHoldSymbolsBackgroundStyle
selectedBackgroundStyle: alphabeticHoldSymbolsSelectedStyle
selectedIndex: 0
symbolStyles: - qButtonHintSymbolsOf1Style - qButtonHintSymbolsOf2Style - qButtonHintSymbolsOf3Style现在单个符号的样式与键盘按键样式是相同的。如:
qButtonHintSymbolsOf1Style: foregroundStyle: qButtonHoldSymbolsOfqForegroundStyle action: { character: q }旧版本的动画定义是在背景样式或前景样式中定义的,而新版本中,动画必须定义在「按键」的样式下。
示例:
# 字母按键背景样式alphabeticBackgroundStyle: ... animation: alphabeticBackgroundAnimation
# 字母按键背景动画
alphabeticBackgroundAnimation: # type: 动画类型 # - bounds: 尺寸大小变化动画 - type: bounds duration: 40 # 动画时长,单位毫秒 repeatCount: 1 fromScale: 1 toScale: 0.87 - type: bounds duration: 80 repeatCount: 1 fromScale: 0.87 toScale: 1 - type: apng file: animationqButton: backgroundStyle: qButtonBackgroundStyle
animation: - scaleAnimation - cartoonAnimation - physicsAnimation
# 放大或缩小的动画scaleAnimation: animationType: scale isAutoReverse: false scale: 0.80 pressDuration: 40 releaseDuration: 80
# 用于替代 apng 图片类型的动画cartoonAnimation: animationType: cartoon # 默认60,可不设置 fps: 60 images: - lleeimage_0.png - lleeimage_1.png
# 用于替换之前 emit 动画
physicsAnimation: animationType: physics duration: 1500 images: - 01.png - 02.png randomImage: true randomPosition: { x: 50, y: 10 } startPosition: { x: 0, y: 0 } endPosition: { x: 0, y: -70 } useOpacity: true startOpacity: 1 endOpacity: 0.2 useRotation: true randomAngle: 6.28 startAngle: 0 endAngle: 6.28在按键的定义中,新增了 animation 参数,用于定义按键的动画效果。其中每个动画通过 animationType 参数来指定动画类型,不同的动画类型有不同的参数和动画效果。
具体参数说明请查阅参数字典。
预编辑区调整
Section titled “预编辑区调整”预编辑区样式关键字变更
#preedit:
preeditStyle: insets: { left: 4, top: 1 } backgroundStyle: preeditBackgroundStyle foregroundStyle: preeditForegroundStyle工具栏调整结构
- 将工具栏样式与工具栏布局单独为两个属性:
toolbarStyle与toolbarLayout, - 删除原候选文字栏设置相关属性
工具栏布局
toolbarLayout与按键区域布局逻辑相同
# toolbar: backgroundStyle: toolbarBackgroundStyle # primaryButtonStyle: primaryButtonStyle secondaryButtonStyle: - toolbarButton1Style - toolbarButton2Style - toolbarButton3Style - toolbarButton4Style horizontalCandidateStyle: horizontalCandidateStyle verticalCandidateStyle: verticalCandidateStyle
# 工具栏样式 toolbarStyle: insets: { left: 50, right: 50 } backgroundStyle: toolbarBackgroundStyle # 工具栏布局 toolbarLayout: - HStack: subviews: - Cell: horizontalNumberSymbols - Cell: leftArrowButton - Cell: downArrowButton - Cell: rightArrowButton横向候选文字栏调整
Section titled “横向候选文字栏调整”横向候选文字栏从原 toolbar 属性中拆分,独立为 horizontalCandidatesStyle,horizontalCandidatesLayout 两个属性。
horizontalCandidatesStyle:用于设置文字栏整体的外观样式horizontalCandidatesLayout:用于设置文字栏的内部空间的布局,与按键区域布局逻辑相同
# toolbar: ... horizontalCandidateStyle: horizontalCandidateStyle
# 横向候选文字栏调整 horizontalCandidatesStyle: insets: { left: 3, bottom: 1, top: 3 } backgroundStyle: horizontalCandidatesBackgroundStyle # 横向候选文字栏布局 horizontalCandidatesLayout: - HStack: subviews: - Cell: horizontalCandidates - Cell: clearPreeditButton - Cell: expandButton纵向候选文字栏调整
Section titled “纵向候选文字栏调整”纵向候选文字栏也从原 toolbar 属性中拆分,独立为样式 verticalCandidatesStyle 布局 verticalCandidatesLayout 两个属性。
verticalCandidatesStyle:用于设置文字栏整体的外观样式verticalCandidatesLayout:用于设置文字栏的内部空间的布局,与按键区域布局逻辑相同
# toolbar: ... verticalCandidateStyle: verticalCandidateStyle
# 纵向候选文字栏样式 verticalCandidatesStyle: insets: { top: 3, bottom: 3, left: 4, right: 4 } backgroundStyle: verticalCandidateBackgroundStyle # 纵向候选文字栏布局 verticalCandidatesLayout: - HStack: subviews: - Cell: verticalCandidates - HStack: style: verticalLastRowStyle subviews: - Cell: verticalPageUpButton - Cell: verticalPageDownButton - Cell: collapseCandidatesButton - Cell: candidateBackspaceButton候选字长按列表调整
Section titled “候选字长按列表调整”候选字长按列表 candidateContextMenu 属性从 toolbar 中拆分。
# toolbar: ... candidateContextMenu: candidateContextMenu
candidateContextMenu: - name: "测试删除" action: { sendKeys: "Shift+Delete" }
candidateContextMenu: - name: "测试删除" action: { sendKeys: "Shift+Delete" }新增横向自定义符号列表
Section titled “新增横向自定义符号列表” horizontalNumberSymbols:
type: horizontalSymbols size: width: 2/3 # (非必须,默认为 5)用来调整显示区域内最大列数 maxColumns: 10 # (非必须,默认为 false)用来调整显示区域内的内容是否从右向左排列 contentRightToLeft: true insets: { left: 3, right: 3 } backgroundStyle: alphabeticBackgroundStyle dataSource: horizontalSymbolsDataSource # 用于定义符号列表中每个符号的样式(仅支持文本) cellStyle: collectionCellStyle
collectionCellStyle: backgroundStyle: collectionCellBackgroundStyle foregroundStyle: collectionCellForegroundStyle
collectionCellBackgroundStyle: buttonStyleType: fileImage highlightImage: file: anjian image: image11
collectionCellForegroundStyle: buttonStyleType: text normalColor: 000000 badgeNormalColor: 575757 badgeHighlightColor: 575757 fontSize: 18 fontWeight: bold
# 数据源无需定义在 dataSource 之下 horizontalSymbolsDataSource: - { label: '1', action: tab } - 2 - 3 - 4数据源的定义目前支持三种方式
- 纯字符串
horizontalSymbolsDataSource: - 1 - 2 ...- 显示与输出分开定义
horizontalSymbolsDataSource: - { label: '1', value: "a" } ...注意:这种方式会使用 symbol 类型直接上屏,不会发送给 rime 引擎。
- 独立 action 定义
horizontalSymbolsDataSource: - { label: '1', action: tab } ...这种方式有最大的灵活度,你可以为每个数据源自定义按键动作。
数据源对象新增 styleName 参数,用于指定自定义样式。
- 可选参数,默认为空,如果不指定,则使用
cellStyle定义的文本样式。
注意:此参数必须与
label一起使用。
horizontalSymbolsDataSource: - { label: '1', action: tab, styleName: 'leftArrowButton'} - { label: '1', value: "1", styleName: 'leftArrowButton'} - 2 - 3 - 4leftArrowButton: backgroundStyle: alphabeticBackgroundStyle foregroundStyle: - leftArrowButtonForegroundStylestyleName 引用的样式与按键样式定义相同。
注意:动作
action的定义需要放在数据源中,样式引用中的定义的action是无效的。
新增横向候选字列表类型
Section titled “新增横向候选字列表类型”为了支持横向候选文字栏可以自定义布局,新增了 horizontalCandidates 类型。
用于在自定义布局中,自定义一块区域用来显示横向候选文字。
注意:此类型仅适用于 horizontalCandidatesLayout 布局中,如果在其他布局中使用,会出现不显示候选字的问题。
horizontalCandidates: # 定义一个横向候选文字展示区域 type: horizontalCandidates size: width: 2/3 # (非必须,默认值为 7)用于定义显示区域内最大候选文字数量 maxColumns: 10 insets: { left: 3, right: 3 } backgroundStyle: alphabeticBackgroundStyle # 用于定义候选文字显示样式 candidateStyle: candidateStyle
candidateStyle: insets: { left: 3, right: 3 } highlightBackgroundColor: ffffff preferredBackgroundColor: ffffff preferredIndexColor: 000000 preferredTextColor: 000000 preferredCommentColor: 000000 indexColor: 000000 textColor: 000000 commentColor: 000000 indexFontSize: 18 textFontSize: 18 commentFontSize: 18新增纵向候选文字列表类型
Section titled “新增纵向候选文字列表类型”为了支持纵向候选文字区域可以自定义布局,新增了 verticalCandidates 类型。
用于在自定义布局中,自定义一块区域用来显示纵向候选文字。
注意:此类型仅适用于 verticalCandidatesLayout 布局中,如果在其他布局中使用,会出现不显示候选字的问题。
verticalCandidates: # 定义一个纵向候选文字显示区域 type: verticalCandidates insets: { left: 3, right: 3 } # (非必须,默认值为 4)显示区域内候选文字最大行数 maxRows: 8 # (非必须,默认值为 5)显示区域内候选文字最大列数 maxColumns: 10 # (非必须)显示区域内分割线颜色 separatorColor: '#33338888' backgroundStyle: alphabeticBackgroundStyle # 候选文字样式 candidateStyle: verticalCandidateCellStyle
verticalCandidateCellStyle: highlightBackgroundColor: ffffff preferredBackgroundColor: ffffff preferredIndexColor: 1a73e9 preferredTextColor: 1a73e9 preferredCommentColor: 1a73e9 indexColor: 000000 textColor: 000000 commentColor: 000000 indexFontSize: 16 textFontSize: 16 commentFontSize: 16 bottomRowHeight: 50符号列表的数据源,无需在放在 dataSource 下。
#dataSource: category: [ "常用", "中文", ... ] 常用: - "," - "。" - "?" ...
category: [ "常用", "中文", ... ]常用: - "," - "。" - "?" ...