diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift index a9be9ddb..d9ea605a 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidateCellData_Core.swift @@ -19,6 +19,7 @@ public class CandidateCellData: Hashable { public static var unifiedSize: Double = 16 public static var unifiedCharDimension: Double { ceil(unifiedSize * 1.0125 + 7) } public static var unifiedTextHeight: Double { ceil(unifiedSize * 19 / 16) } + static var internalPrefs = PrefMgr() public var selectionKey: String public let displayedText: String public private(set) var textDimension: NSSize @@ -81,7 +82,8 @@ public class CandidateCellData: Hashable { } public func cellLength(isMatrix: Bool = true) -> Double { - let minLength = ceil(Self.unifiedCharDimension * 2 + size * 1.25) + let factor: CGFloat = (Self.internalPrefs.minCellWidthForHorizontalMatrix == 0) ? 1.5 : 2 + let minLength = ceil(Self.unifiedCharDimension * factor + size * 1.25) if displayedText.count <= 2, isMatrix { return minLength } return textDimension.width } diff --git a/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsCocoa/VwrSettingsPaneCocoaCandidates.swift b/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsCocoa/VwrSettingsPaneCocoaCandidates.swift index 206d34be..9646e851 100644 --- a/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsCocoa/VwrSettingsPaneCocoaCandidates.swift +++ b/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsCocoa/VwrSettingsPaneCocoaCandidates.swift @@ -37,6 +37,7 @@ public extension SettingsPanesCocoa { } UserDef.kCandidateWindowShowOnlyOneLine.render(fixWidth: innerContentWidth) UserDef.kAlwaysExpandCandidateWindow.render(fixWidth: innerContentWidth) + UserDef.kMinCellWidthForHorizontalMatrix.render(fixWidth: innerContentWidth) UserDef.kRespectClientAccentColor.render(fixWidth: innerContentWidth) }?.boxed() NSView() diff --git a/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsUI/VwrSettingsPaneCandidates.swift b/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsUI/VwrSettingsPaneCandidates.swift index b8881e96..a841e30a 100644 --- a/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsUI/VwrSettingsPaneCandidates.swift +++ b/Packages/vChewing_MainAssembly/Sources/MainAssembly/Settings/SettingsUI/VwrSettingsPaneCandidates.swift @@ -26,6 +26,9 @@ public struct VwrSettingsPaneCandidates: View { @AppStorage(wrappedValue: true, UserDef.kRespectClientAccentColor.rawValue) private var respectClientAccentColor: Bool + @AppStorage(wrappedValue: 0, UserDef.kMinCellWidthForHorizontalMatrix.rawValue) + private var minCellWidthForHorizontalMatrix: Int + @AppStorage(wrappedValue: false, UserDef.kAlwaysExpandCandidateWindow.rawValue) private var alwaysExpandCandidateWindow: Bool @@ -102,6 +105,8 @@ public struct VwrSettingsPaneCandidates: View { if !candidateWindowShowOnlyOneLine { UserDef.kAlwaysExpandCandidateWindow.bind($alwaysExpandCandidateWindow).render() .disabled(candidateWindowShowOnlyOneLine) + UserDef.kMinCellWidthForHorizontalMatrix.bind($minCellWidthForHorizontalMatrix).render() + .disabled(candidateWindowShowOnlyOneLine) } UserDef.kRespectClientAccentColor.bind($respectClientAccentColor).render() } diff --git a/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift b/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift index b0c6a5e6..acd0532b 100644 --- a/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift +++ b/Packages/vChewing_Shared/Sources/Shared/PrefMgr_Core.swift @@ -149,6 +149,9 @@ import SwiftExtension @AppProperty(key: UserDef.kUseHorizontalCandidateList.rawValue, defaultValue: true) public dynamic var useHorizontalCandidateList: Bool + @AppProperty(key: UserDef.kMinCellWidthForHorizontalMatrix.rawValue, defaultValue: 0) + public dynamic var minCellWidthForHorizontalMatrix: Int + @AppProperty(key: UserDef.kChooseCandidateUsingSpace.rawValue, defaultValue: true) public dynamic var chooseCandidateUsingSpace: Bool diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift index 209c3245..1c37ff24 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift @@ -37,6 +37,7 @@ public protocol PrefMgrProtocol { var dodgeInvalidEdgeCandidateCursorPosition: Bool { get set } var useDynamicCandidateWindowOrigin: Bool { get set } var useHorizontalCandidateList: Bool { get set } + var minCellWidthForHorizontalMatrix: Int { get set } var chooseCandidateUsingSpace: Bool { get set } var allowBoostingSingleKanjiAsUserPhrase: Bool { get set } var fetchSuggestionsFromUserOverrideModel: Bool { get set } diff --git a/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift b/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift index 7dda910f..e11e6bfe 100644 --- a/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift +++ b/Packages/vChewing_Shared/Sources/Shared/UserDef/UserDef.swift @@ -57,6 +57,7 @@ public enum UserDef: String, CaseIterable, Identifiable { case kUseShiftQuestionToCallServiceMenu = "UseShiftQuestionToCallServiceMenu" case kUseDynamicCandidateWindowOrigin = "UseDynamicCandidateWindowOrigin" case kUseHorizontalCandidateList = "UseHorizontalCandidateList" + case kMinCellWidthForHorizontalMatrix = "MinCellWidthForHorizontalMatrix" case kChooseCandidateUsingSpace = "ChooseCandidateUsingSpace" case kCassetteEnabled = "CassetteEnabled" case kCNS11643Enabled = "CNS11643Enabled" @@ -184,6 +185,7 @@ public extension UserDef { case .kUseShiftQuestionToCallServiceMenu: return .bool case .kUseDynamicCandidateWindowOrigin: return .bool case .kUseHorizontalCandidateList: return .bool + case .kMinCellWidthForHorizontalMatrix: return .integer case .kChooseCandidateUsingSpace: return .bool case .kCassetteEnabled: return .bool case .kCNS11643Enabled: return .bool @@ -358,6 +360,13 @@ public extension UserDef { description: "Choose your preferred layout of the candidate window.", options: [0: "Vertical", 1: "Horizontal"] ) + case .kMinCellWidthForHorizontalMatrix: return .init( + userDef: self, shortTitle: "i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle", + options: [ + 0: "i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0", + 1: "i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1", + ] + ) case .kChooseCandidateUsingSpace: return .init( userDef: self, shortTitle: "Enable Space key for calling candidate window", description: "If disabled, this will insert space instead." diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index bbf3137d..32c87ded 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -224,6 +224,9 @@ "i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "Dodge Invalid Edge Candidate Cursor Position"; "i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "Filter Non-CNS11643 factory readings (CHT input only)"; "i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "Contents committed by Command+Option+Ctrl+Enter may vary depending on related behavior settings."; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "2 Kanjis"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "2 Emojis (Wider)"; +"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "Minimum cell width for horizontal matrix:"; "i18n:UserDef.kNumPadCharInputBehavior.description" = "Choose the behavior of numeric pad inputs."; "i18n:UserDef.kNumPadCharInputBehavior.option.0" = "Always directly commit half-width chars"; "i18n:UserDef.kNumPadCharInputBehavior.option.1" = "Always directly commit full-width chars"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 8553635a..d25f1367 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -224,6 +224,9 @@ "i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "端末での不合理的な候補選択用カーソル位置を是正"; "i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "全字庫以外の音読みを内蔵辞書繁体中国語検索結果から除く"; "i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "Command+Option+Ctrl+Enter で送り出したものは、それに関する作動設定次第です。"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "2つの漢字(幅の狭い)"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "2つの絵文字(幅の広い)"; +"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "多行横型陳列ウィンドウの候補の最小幅:"; "i18n:UserDef.kNumPadCharInputBehavior.description" = "テンキー文字の入力行為をご指定ください。"; "i18n:UserDef.kNumPadCharInputBehavior.option.0" = "いつでも半角で直接出力"; "i18n:UserDef.kNumPadCharInputBehavior.option.1" = "いつでも全角で直接出力"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index a57de2ce..7794a2f6 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -224,6 +224,9 @@ "i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "糾正不合理的端点选字游标位置"; "i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "仅繁体中文: 原厂辞典仅返回符合全字库读音的结果"; "i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "借由 Command+Option+Ctrl+Enter 输出的内容受对应的行为设定所影响。"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "两个汉字"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "两个绘文字(更宽)"; +"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "横向多列选字窗最低单元宽度:"; "i18n:UserDef.kNumPadCharInputBehavior.description" = "指定数字小键盘的输入行为。"; "i18n:UserDef.kNumPadCharInputBehavior.option.0" = "始终以半形文字直接递交"; "i18n:UserDef.kNumPadCharInputBehavior.option.1" = "始终以全形文字直接递交"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 061349f6..5d6dae23 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -224,6 +224,9 @@ "i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "糾正不合理的端點選字游標位置"; "i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "僅繁體中文: 原廠辭典僅返回符合全字庫讀音的結果"; "i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "藉由 Command+Option+Ctrl+Enter 輸出的內容受對應的行為設定所影響。"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "兩個漢字"; +"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "兩個繪文字(更寬)"; +"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "橫向多列選字窗最低單元寬度:"; "i18n:UserDef.kNumPadCharInputBehavior.description" = "指定數字小鍵盤的輸入行為。"; "i18n:UserDef.kNumPadCharInputBehavior.option.0" = "始終以半形文字直接遞交"; "i18n:UserDef.kNumPadCharInputBehavior.option.1" = "始終以全形文字直接遞交";