diff --git a/src/ui/FeedbackWindow.swift b/src/ui/FeedbackWindow.swift index fdbd974e..83e2436a 100644 --- a/src/ui/FeedbackWindow.swift +++ b/src/ui/FeedbackWindow.swift @@ -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 diff --git a/src/ui/generic-components/StackView.swift b/src/ui/generic-components/StackView.swift index b2b226e9..f4957eeb 100644 --- a/src/ui/generic-components/StackView.swift +++ b/src/ui/generic-components/StackView.swift @@ -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) diff --git a/src/ui/generic-components/text/TextArea.swift b/src/ui/generic-components/text/TextArea.swift index 319693bd..b6293cc9 100644 --- a/src/ui/generic-components/text/TextArea.swift +++ b/src/ui/generic-components/text/TextArea.swift @@ -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, diff --git a/src/ui/preferences-window/LabelAndControl.swift b/src/ui/preferences-window/LabelAndControl.swift index 6b83b27a..54b13acb 100644 --- a/src/ui/preferences-window/LabelAndControl.swift +++ b/src/ui/preferences-window/LabelAndControl.swift @@ -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 diff --git a/src/ui/preferences-window/tabs/UpdatesTab.swift b/src/ui/preferences-window/tabs/UpdatesTab.swift index 265456a6..3527aee7 100644 --- a/src/ui/preferences-window/tabs/UpdatesTab.swift +++ b/src/ui/preferences-window/tabs/UpdatesTab.swift @@ -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],