29 lines
924 B
Swift
29 lines
924 B
Swift
import Gtk
|
|
|
|
/// A horizontal container backed by `Gtk.Box(orientation: .horizontal)`.
|
|
@MainActor public struct HStack: View {
|
|
let spacing: Int32
|
|
let content: () -> [AnyView]
|
|
public var body: Never { fatalError() }
|
|
|
|
/// Creates a horizontal stack with the given spacing and children.
|
|
///
|
|
/// - Parameters:
|
|
/// - spacing: Spacing between children in pixels.
|
|
/// - content: A ``ViewBuilder`` closure producing the children.
|
|
public init(
|
|
spacing: Int32 = 0,
|
|
@ViewBuilder content: @escaping () -> [AnyView]
|
|
) {
|
|
self.spacing = spacing
|
|
self.content = content
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension HStack: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let box = Gtk.Box(orientation: .horizontal, spacing: spacing)
|
|
mountChildren(content, into: box, ctx) { box.appendChild($0) }
|
|
return box
|
|
}
|
|
}
|