Skip to content

Commit

Permalink
Improve accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Jan 26, 2025
1 parent abc6c20 commit 06f719a
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,91 @@
"sourceLanguage" : "en",
"strings" : {
"%@ times" : {
"extractionState" : "stale",
"comment" : "accessibility label for line height",
"localizations" : {
"nl" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ krát"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@-fach"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ times"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ veces"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ fois"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ volte"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@倍"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@배"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ keer"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ wielkości czcionki"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ vezes"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ kere"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@倍"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@倍"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,95 @@
}
}
},
"wrapped line indent spaces" : {
"comment" : "accessibility label",
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "počet mezer pro odsazení zalomených řádků"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Einzug für umgebrochene Zeilen"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "wrapped line indent spaces"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "espacios de sangría de la línea ajustada"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "espaces indentés des retours de ligne"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "spazi rientro riga adattata"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "折り返した行のインデントのスペース数"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "줄바꿈 행 들여쓰기 간격"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "spaties voor inspringing teruggelopen regels"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "spacje wcięcia zawiniętego wiersza"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "espaços de recuo da linha ajustada"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "kaydırılan satırın girinti boşluğu"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "换行缩进空间"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "換行縮排間距"
}
}
}
},
"Writing direction:" : {
"localizations" : {
"cs" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2021-2024 1024jp
// © 2021-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -111,7 +111,8 @@ struct CharacterCountOptionsView: View {
}

if self.unit != .graphemeCluster {
Toggle(isOn: $normalizes) {
HStack(alignment: .firstTextBaseline) {
Toggle(String(localized: "Normalization:", table: "AdvancedCharacterCount", comment: "label"), isOn: $normalizes)
Picker(String(localized: "Normalization:", table: "AdvancedCharacterCount", comment: "label"), selection: $normalizationForm) {
Section {
ForEach(UnicodeNormalizationForm.standardForms, id: \.self) { form in
Expand All @@ -126,6 +127,7 @@ struct CharacterCountOptionsView: View {
}
}
}
.labelsHidden()
.disabled(!self.normalizes)
.fixedSize()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2018-2024 1024jp
// © 2018-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -302,15 +302,11 @@ struct RegularExpressionSortPatternView: View {
.accessibilityElement(children: .contain)
}

Toggle(isOn: $pattern.usesCaptureGroup) {
HStack(alignment: .firstTextBaseline) {
Text("Use captured group:", tableName: "PatternSort")
.accessibilityLabeledPair(role: .label, id: "useGroup", in: self.accessibility)
StepperNumberField(value: $pattern.group, default: 1,
in: 0...self.pattern.numberOfCaptureGroups)
HStack(alignment: .firstTextBaseline) {
Toggle(String(localized: "Use captured group:", table: "PatternSort"), isOn: $pattern.usesCaptureGroup)
StepperNumberField(value: $pattern.group, default: 1, in: 0...self.pattern.numberOfCaptureGroups)
.disabled(!self.pattern.usesCaptureGroup)
.accessibilityLabeledPair(role: .content, id: "useGroup", in: self.accessibility)
}
.accessibilityLabel(String(localized: "Use captured group:", table: "PatternSort"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2014-2024 1024jp
// © 2014-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -99,10 +99,12 @@ struct AppearanceSettingsView: View {
Stepper(value: $lineHeight, in: 0.1...10, step: 0.1, format: .number.precision(.fractionLength(1...2)), label: EmptyView.init)
.monospacedDigit()
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing)
.accessibilityValue(String(localized: "\(self.lineHeight, format: .number) times", table: "AppearanceSettings",
comment: "accessibility label for line height"))

Text("times", tableName: "AppearanceSettings", comment: "unit for line height")
.accessibilityHidden(true)
}
.accessibilityElement(children: .combine)
.accessibilityLabeledPair(role: .content, id: "lineHeight", in: self.accessibility)
}

Expand Down Expand Up @@ -135,7 +137,7 @@ struct AppearanceSettingsView: View {

TextField(value: $windowAlpha, format: .percent.precision(.fractionLength(0)), prompt: Text(1, format: .percent), label: EmptyView.init)
.monospacedDigit()
.environment(\.layoutDirection, .rightToLeft)
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing)
.frame(width: 48)
}
.accessibilityLabeledPair(role: .content, id: "windowAlpha", in: self.accessibility)
Expand Down
11 changes: 7 additions & 4 deletions CotEditor/Sources/Settings Window/Panes/EditSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2023-2024 1024jp
// © 2023-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -101,10 +101,13 @@ struct EditSettingsView: View {
Text("Delay:", tableName: "EditSettings")
.accessibilityLabeledPair(role: .label, id: "selectionInstanceHighlightDelay", in: self.accessibility)
Stepper(value: $selectionInstanceHighlightDelay, in: 0...10, step: 0.25, format: .number.precision(.fractionLength(2)), label: EmptyView.init)
.monospacedDigit()
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing) // width: 40
.accessibilityLabeledPair(role: .content, id: "selectionInstanceHighlightDelay", in: self.accessibility)
.monospacedDigit()
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing) // width: 40
.accessibilityValue(Duration.seconds(self.selectionInstanceHighlightDelay)
.formatted(.units(allowed: [.seconds], width: .wide, fractionalPart: .show(length: 2))))
.accessibilityLabeledPair(role: .content, id: "selectionInstanceHighlightDelay", in: self.accessibility)
Text("seconds", tableName: "EditSettings", comment: "init for delay time")
.accessibilityHidden(true)
}
.disabled(!self.highlightSelectionInstance)
.foregroundStyle(self.highlightSelectionInstance ? .primary : .tertiary)
Expand Down
30 changes: 14 additions & 16 deletions CotEditor/Sources/Settings Window/Panes/WindowSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2014-2024 1024jp
// © 2014-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -97,7 +97,7 @@ struct WindowSettingsView: View {
VStack(spacing: 1) {
TextField(value: $windowWidth, format: .number, prompt: Text("Auto", tableName: "WindowSettings", comment: "placeholder for window size field"), label: EmptyView.init)
.monospacedDigit()
.environment(\.layoutDirection, .rightToLeft)
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing)
.frame(width: 64)
.accessibilityLabeledPair(role: .content, id: "windowWidth", in: self.accessibility)
Text("Width", tableName: "WindowSettings")
Expand All @@ -113,7 +113,7 @@ struct WindowSettingsView: View {
VStack(spacing: 1) {
TextField(value: $windowHeight, format: .number, prompt: Text("Auto", tableName: "WindowSettings", comment: "placeholder for window size field"), label: EmptyView.init)
.monospacedDigit()
.environment(\.layoutDirection, .rightToLeft)
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing)
.frame(width: 64)
.accessibilityLabeledPair(role: .label, id: "windowHeight", in: self.accessibility)
Text("Height", tableName: "WindowSettings")
Expand Down Expand Up @@ -158,12 +158,11 @@ struct WindowSettingsView: View {
.fixedSize()

Toggle(String(localized: "Indent guides", table: "WindowSettings"), isOn: $showIndentGuides)
Toggle(isOn: $showPageGuide) {
HStack(alignment: .firstTextBaseline) {
Text("Page guide at column:", tableName: "WindowSettings")
StepperNumberField(value: $pageGuideColumn, default: UserDefaults.standard[initial: .pageGuideColumn], in: 1...999)
.disabled(!self.showPageGuide)
}
HStack(alignment: .firstTextBaseline) {
Toggle(String(localized: "Page guide at column:", table: "WindowSettings"), isOn: $showPageGuide)
StepperNumberField(value: $pageGuideColumn, default: UserDefaults.standard[initial: .pageGuideColumn], in: 1...999)
.accessibilityLabel(String(localized: "Page guide at column:", table: "WindowSettings"))
.disabled(!self.showPageGuide)
}
}
}
Expand All @@ -184,13 +183,12 @@ struct WindowSettingsView: View {

VStack(alignment: .leading, spacing: 6) {
Toggle(String(localized: "Wrap lines to editor width", table: "WindowSettings"), isOn: $wrapLines)
Toggle(isOn: $enablesHangingIndent) {
HStack {
Text("Indent wrapped lines by", tableName: "WindowSettings")
StepperNumberField(value: $hangingIndentWidth, default: UserDefaults.standard[initial: .hangingIndentWidth], in: 0...99)
.disabled(!self.enablesHangingIndent)
Text("spaces", tableName: "WindowSettings", comment: "unit for indentation")
}
HStack(alignment: .firstTextBaseline) {
Toggle(String(localized: "Indent wrapped lines by", table: "WindowSettings"), isOn: $enablesHangingIndent)
StepperNumberField(value: $hangingIndentWidth, default: UserDefaults.standard[initial: .hangingIndentWidth], in: 0...99)
.disabled(!self.enablesHangingIndent)
.accessibilityLabel(String(localized: "wrapped line indent spaces", table: "WindowSettings", comment: "accessibility label"))
Text("spaces", tableName: "WindowSettings", comment: "unit for indentation")
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion CotEditor/Sources/Views/SwiftUI/StepperNumberField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import SwiftUI

struct StepperNumberField: View {

@Environment(\.layoutDirection) private var layoutDirection

@Binding private var value: Int
private var defaultValue: Int?
private var bounds: ClosedRange<Int>
Expand Down Expand Up @@ -59,7 +61,7 @@ struct StepperNumberField: View {
HStack(spacing: 4) {
TextField(value: $value, format: .ranged(self.bounds), prompt: self.prompt, label: EmptyView.init)
.monospacedDigit()
.environment(\.layoutDirection, .rightToLeft)
.multilineTextAlignment(self.layoutDirection == .rightToLeft ? .leading : .trailing)
.frame(width: self.fieldWidth)

Stepper(value: $value, in: self.bounds, step: self.step, label: EmptyView.init)
Expand Down
Loading

0 comments on commit 06f719a

Please sign in to comment.