Skip to content

Commit

Permalink
fix: correctly display right-to-left languages
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed May 5, 2020
1 parent 37d8c98 commit 89f2df4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/ui/FeedbackWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ class FeedbackWindow: NSWindow {
private func setupView() {
let appIcon = NSImageView(image: NSImage(named: "app-icon")!.resizedCopy(80, 80))
appIcon.imageScaling = .scaleNone
let appText = NSStackView(views: [
let appText = StackView([
BoldLabel(NSLocalizedString("Share improvement ideas, or report bugs", comment: "")),
HyperlinkLabel(NSLocalizedString("View existing discussions", comment: ""), App.repository + "/issues"),
])
appText.orientation = .vertical
appText.alignment = .left
], .vertical)
appText.spacing = GridView.interPadding / 2
let header = NSStackView(views: [appIcon, appText])
header.spacing = GridView.interPadding
sendButton = NSButton(title: NSLocalizedString("Send", comment: ""), target: nil, action: #selector(sendCallback))
sendButton.keyEquivalent = "\r"
sendButton.isEnabled = false
let buttons = NSStackView(views: [
NSButton(title: NSLocalizedString("Cancel", comment: ""), target: nil, action: #selector(cancelCallback)),
let buttons = StackView([
NSButton(title: NSLocalizedString("Cancel", comment: ""), target: nil, action: #selector(cancel)),
sendButton,
])
buttons.spacing = GridView.interPadding
Expand Down
2 changes: 1 addition & 1 deletion src/ui/generic-components/StackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class StackView: NSStackView {
convenience init(_ views: [NSView], _ orientation: NSUserInterfaceLayoutOrientation = .horizontal, top: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0, left: CGFloat = 0) {
self.init(views: views)
alignmentRectInsets_ = NSEdgeInsets(top: top, left: left, bottom: bottom, right: right)
alignment = orientation == .horizontal ? .firstBaseline : .left
alignment = orientation == .horizontal ? .firstBaseline : .leading
// workaround: for some reason, horizontal stackviews with a RecorderControl have extra fittingSize.height
if orientation == .horizontal && views.first(where: { $0 is CustomRecorderControl }) != nil {
fit(fittingSize.width, fittingSize.height - 7)
Expand Down
2 changes: 2 additions & 0 deletions src/ui/generic-components/text/TextArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class TextFieldCell: NSTextFieldCell {
stringValue = ""
placeholderString = placeholder
self.usesSingleLineMode = usesSingleLineMode
alignment = .natural // appkit bug: the docs say default is .natural but it's .left
}

// add padding all around
override func drawingRect(forBounds rect: NSRect) -> NSRect {
return super.drawingRect(forBounds: NSMakeRect(
rect.origin.x + TextArea.padding,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/preferences-window/LabelAndControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LabelAndControl: NSObject {

static func makeLabelWithSlider(_ labelText: String, _ rawName: String, _ minValue: Double, _ maxValue: Double, _ numberOfTickMarks: Int, _ allowsTickMarkValuesOnly: Bool, _ unitText: String = "") -> [NSView] {
let value = Preferences.getString(rawName)!
let suffixText = value + "" + unitText
let suffixText = MeasurementFormatter().string(from: Measurement(value: Double(value)!, unit: Unit(symbol: unitText)))
let slider = NSSlider()
slider.minValue = minValue
slider.maxValue = maxValue
Expand Down
4 changes: 1 addition & 3 deletions src/ui/preferences-window/tabs/UpdatesTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class UpdatesTab: NSViewController, PreferencePane {
periodicallyInstall.fit()
let policyLabel = NSTextField(wrappingLabelWithString: NSLocalizedString("Updates policy:", comment: ""))
policyLabel.isSelectable = false
let policies = NSStackView(views: [dontPeriodicallyCheck, periodicallyCheck, periodicallyInstall])
policies.alignment = .left
policies.orientation = .vertical
let policies = StackView([dontPeriodicallyCheck, periodicallyCheck, periodicallyInstall], .vertical)
policies.spacing = GridView.interPadding / 2
let grid = GridView([
[policyLabel, policies],
Expand Down

0 comments on commit 89f2df4

Please sign in to comment.