Skip to content

Commit

Permalink
SettingsCocoa // Lock dimensions for descriptions and titles.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Feb 13, 2024
1 parent 820ee5b commit 903faae
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public extension SettingsPanesCocoa {
}
UserDef.kAlwaysShowTooltipTextsHorizontally.render(fixWidth: contentWidth)
if Date.isTodayTheDate(from: 0401) {
UserDef.kShouldNotFartInLieuOfBeep.render { renderable in
UserDef.kShouldNotFartInLieuOfBeep.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.onFartControlChange(_:))
}
Expand All @@ -69,14 +69,16 @@ public extension SettingsPanesCocoa {
UserDef.kShareAlphanumericalModeStatusAcrossClients.render(fixWidth: contentWidth)
if #available(macOS 10.15, *) {
NSStackView.build(.vertical) {
UserDef.kTogglingAlphanumericalModeWithLShift.render { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.syncShiftKeyUpChecker(_:))
}
UserDef.kTogglingAlphanumericalModeWithRShift.render { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.syncShiftKeyUpChecker(_:))
}
UserDef.kTogglingAlphanumericalModeWithLShift
.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.syncShiftKeyUpChecker(_:))
}
UserDef.kTogglingAlphanumericalModeWithRShift
.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.syncShiftKeyUpChecker(_:))
}
var strOSReq = ""
strOSReq += String(
format: "This feature requires macOS %@ and above.".localized, arguments: ["10.15"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension SettingsPanesCocoa {
NSTabView.TabPage(title: "") {
NSStackView.buildSection(width: contentWidth) {
UserDef.kUseHorizontalCandidateList.render(fixWidth: contentWidth)
UserDef.kCandidateListTextSize.render { renderable in
UserDef.kCandidateListTextSize.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.candidateFontSizeDidSet(_:))
}
Expand All @@ -41,7 +41,7 @@ public extension SettingsPanesCocoa {
}
NSTabView.TabPage(title: "") {
NSStackView.buildSection(width: contentWidth) {
UserDef.kCandidateKeys.render { renderable in
UserDef.kCandidateKeys.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.candidateKeysDidSet(_:))
renderable.currentControl?.alignment = .right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public extension SettingsPanesCocoa {
var body: NSView? {
NSStackView.build(.vertical, insets: .new(all: 14)) {
NSStackView.buildSection(width: contentWidth) {
UserDef.kCassettePath.render { renderable in
UserDef.kCassettePath.render(fixWidth: contentWidth) { renderable in
renderable.currentControl = self.pctCassetteFilePath
renderable.mainViewOverride = self.pathControlMainView
}
UserDef.kCassetteEnabled.render { renderable in
UserDef.kCassetteEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.cassetteEnabledToggled(_:))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,33 @@ public extension SettingsPanesCocoa {
var body: NSView? {
NSStackView.build(.vertical, insets: .new(all: 14)) {
NSStackView.buildSection(width: contentWidth) {
UserDef.kUserDataFolderSpecified.render { renderable in
UserDef.kUserDataFolderSpecified.render(fixWidth: contentWidth) { renderable in
renderable.currentControl = self.pctUserDictionaryFolder
renderable.mainViewOverride = self.pathControlMainView
}
NSStackView.build(.vertical) {
UserDef.kShouldAutoReloadUserDataFiles.render { renderable in
UserDef.kShouldAutoReloadUserDataFiles.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrInitUserLMsWhenShould(_:))
}
"Due to security concerns, we don't consider implementing anything related to shell script execution here. An input method doing this without implementing App Sandbox will definitely have system-wide vulnerabilities, considering that its related UserDefaults are easily tamperable to execute malicious shell scripts. vChewing is designed to be invulnerable from this kind of attack. Also, official releases of vChewing are Sandboxed.".makeNSLabel(descriptive: true, fixWidth: contentWidth)
}
}?.boxed()
NSStackView.buildSection(width: contentWidth) {
UserDef.kUseExternalFactoryDict.render { renderable in
UserDef.kUseExternalFactoryDict.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrConnectCoreDB(_:))
}
UserDef.kFetchSuggestionsFromUserOverrideModel.render(fixWidth: contentWidth)
UserDef.kCNS11643Enabled.render { renderable in
UserDef.kCNS11643Enabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kSymbolInputEnabled.render { renderable in
UserDef.kSymbolInputEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefs(_:))
}
UserDef.kPhraseReplacementEnabled.render { renderable in
UserDef.kPhraseReplacementEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.lmmgrSyncLMPrefsWithReplacementTable(_:))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public extension SettingsPanesCocoa {
strNotice += "\n\u{2022} "
strNotice += "Note: The “Delete ⌫” key on Mac keyboard is named as “BackSpace ⌫” here in order to distinguish the real “Delete ⌦” key from full-sized desktop keyboards. If you want to use the real “Delete ⌦” key on a Mac keyboard with no numpad equipped, you have to press “Fn+⌫” instead.".localized
strNotice.makeNSLabel(descriptive: true, fixWidth: contentWidth)
UserDef.kAppleLanguages.render { renderable in
UserDef.kAppleLanguages.render(fixWidth: contentWidth) { renderable in
renderable.currentControl = self.btnLangSelector
}
}?.boxed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public extension SettingsPanesCocoa {
var body: NSView? {
NSStackView.build(.vertical, insets: .new(all: 14)) {
NSStackView.buildSection(width: contentWidth) {
UserDef.kChineseConversionEnabled.render { renderable in
UserDef.kChineseConversionEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.sanityCheckKangXi(_:))
}
UserDef.kShiftJISShinjitaiOutputEnabled.render { renderable in
UserDef.kShiftJISShinjitaiOutputEnabled.render(fixWidth: contentWidth) { renderable in
renderable.currentControl?.target = self
renderable.currentControl?.action = #selector(self.sanityCheckJIS(_:))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ public extension SettingsPanesCocoa {
txtPEField3.makeSimpleConstraint(.width, relation: .greaterThanOrEqual, value: 90)
btnPEAdd
}
UserDef.kPhraseEditorAutoReloadExternalModifications.render { renderable in
renderable.tinySize = true
}
UserDef.kPhraseEditorAutoReloadExternalModifications
.render(fixWidth: contentWidth) { renderable in
renderable.tinySize = true
}
}
}?.boxed()
NSView().makeSimpleConstraint(.height, relation: .equal, value: NSFont.systemFontSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public extension UserDefRenderableCocoa {
textField.font = NSFont.systemFont(ofSize: NSFont.smallSystemFontSize)
}
textField.preferredMaxLayoutWidth = fixedWidth ?? 0
if let fixedWidth = fixedWidth {
textField.makeSimpleConstraint(.width, relation: .lessThanOrEqual, value: fixedWidth)
textField.sizeToFit()
textField.makeSimpleConstraint(.height, relation: .lessThanOrEqual, value: textField.fittingSize.height)
}
return textField
}

Expand All @@ -130,10 +135,12 @@ public extension UserDefRenderableCocoa {
}
control
}
if let fixedWidth = fixedWidth {
if let fixedWidth = fixedWidth, let textLabel = textLabel {
let specifiedWidth = fixedWidth - controlWidth - NSFont.systemFontSize
textLabel?.preferredMaxLayoutWidth = specifiedWidth
textLabel?.makeSimpleConstraint(.width, relation: .lessThanOrEqual, value: specifiedWidth)
textLabel.preferredMaxLayoutWidth = specifiedWidth
textLabel.makeSimpleConstraint(.width, relation: .lessThanOrEqual, value: specifiedWidth)
textLabel.sizeToFit()
textLabel.makeSimpleConstraint(.height, relation: .lessThanOrEqual, value: textLabel.fittingSize.height)
}
textLabel?.sizeToFit()
return result
Expand Down

0 comments on commit 903faae

Please sign in to comment.