CocoaExtension // Allow overriding stack spacing.
This commit is contained in:
parent
169902db19
commit
5090c7e6d4
|
@ -148,6 +148,7 @@ public extension NSStackView {
|
|||
|
||||
static func buildSection(
|
||||
_ orientation: NSUserInterfaceLayoutOrientation = .vertical,
|
||||
spacing: CGFloat? = nil,
|
||||
width: CGFloat? = nil,
|
||||
withDividers: Bool = true,
|
||||
@ArrayBuilder<NSView?> views: () -> [NSView?]
|
||||
|
@ -166,7 +167,7 @@ public extension NSStackView {
|
|||
itemWidth = (width - splitterDelta) / CGFloat(viewsRendered.count) - 6
|
||||
}
|
||||
func giveViews() -> [NSView?] { viewsRendered }
|
||||
let result = build(orientation, divider: withDividers, width: itemWidth, views: giveViews)?
|
||||
let result = build(orientation, divider: withDividers, spacing: spacing, width: itemWidth, views: giveViews)?
|
||||
.withInsets(.new(all: 4))
|
||||
return result
|
||||
}
|
||||
|
@ -174,6 +175,7 @@ public extension NSStackView {
|
|||
static func build(
|
||||
_ orientation: NSUserInterfaceLayoutOrientation,
|
||||
divider: Bool = false,
|
||||
spacing: CGFloat? = nil,
|
||||
width: CGFloat? = nil,
|
||||
height: CGFloat? = nil,
|
||||
insets: NSEdgeInsets? = nil,
|
||||
|
@ -185,7 +187,7 @@ public extension NSStackView {
|
|||
.makeSimpleConstraint(.height, relation: .equal, value: height)
|
||||
}
|
||||
guard !result.isEmpty else { return nil }
|
||||
return result.stack(orientation, divider: divider)?.withInsets(insets)
|
||||
return result.stack(orientation, divider: divider, spacing: spacing)?.withInsets(insets)
|
||||
}
|
||||
|
||||
func withInsets(_ newValue: NSEdgeInsets?) -> NSStackView {
|
||||
|
@ -198,6 +200,7 @@ public extension Array where Element == NSView {
|
|||
func stack(
|
||||
_ orientation: NSUserInterfaceLayoutOrientation,
|
||||
divider: Bool = false,
|
||||
spacing: CGFloat? = nil,
|
||||
insets: NSEdgeInsets? = nil
|
||||
) -> NSStackView? {
|
||||
guard !isEmpty else { return nil }
|
||||
|
@ -212,6 +215,7 @@ public extension Array where Element == NSView {
|
|||
if #unavailable(macOS 10.10) {
|
||||
outerStack.spacing = Swift.max(1, outerStack.spacing) - 1
|
||||
}
|
||||
outerStack.spacing = spacing ?? outerStack.spacing
|
||||
|
||||
outerStack.setHuggingPriority(.fittingSizeCompression, for: .horizontal)
|
||||
outerStack.setHuggingPriority(.fittingSizeCompression, for: .vertical)
|
||||
|
|
|
@ -65,7 +65,7 @@ public extension SettingsPanesCocoa {
|
|||
NSStackView.build(.vertical, insets: .new(all: 14)) {
|
||||
NSStackView.buildSection(width: contentWidth) {
|
||||
NSStackView.build(.vertical) {
|
||||
NSStackView.build(.horizontal) {
|
||||
NSStackView.build(.horizontal, spacing: 4) {
|
||||
cmbPEInputModeMenu
|
||||
cmbPEDataTypeMenu
|
||||
NSView()
|
||||
|
|
Loading…
Reference in New Issue