339 lines
17 KiB
Swift
339 lines
17 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.Box
|
|
/// Arranges child widgets into a single row or column.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="box-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkBox" src="box.png">
|
|
/// </picture>
|
|
///
|
|
/// Whether it is a row or column depends on the value of its
|
|
/// [property`Gtk`.Orientable:orientation] property. Within the other
|
|
/// dimension, all children are allocated the same size. The
|
|
/// [property`Gtk`.Widget:halign] and [property`Gtk`.Widget:valign]
|
|
/// properties can be used on the children to influence their allocation.
|
|
///
|
|
/// Use repeated calls to [method`Gtk`.Box.append] to pack widgets into a
|
|
/// `GtkBox` from start to end. Use [method`Gtk`.Box.remove] to remove widgets
|
|
/// from the `GtkBox`. [method`Gtk`.Box.insert_child_after] can be used to add
|
|
/// a child at a particular position.
|
|
///
|
|
/// Use [method`Gtk`.Box.set_homogeneous] to specify whether or not all children
|
|
/// of the `GtkBox` are forced to get the same amount of space.
|
|
///
|
|
/// Use [method`Gtk`.Box.set_spacing] to determine how much space will be minimally
|
|
/// placed between all children in the `GtkBox`. Note that spacing is added
|
|
/// *between* the children.
|
|
///
|
|
/// Use [method`Gtk`.Box.reorder_child_after] to move a child to a different
|
|
/// place in the box.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkBox` uses a single CSS node with name box.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// Until GTK 4.10, `GtkBox` used the [enum`Gtk`.AccessibleRole.group] role.
|
|
///
|
|
/// Starting from GTK 4.12, `GtkBox` uses the [enum`Gtk`.AccessibleRole.generic] role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Box`.
|
|
@MainActor public struct Box: View {
|
|
private let make: (MountContext) -> Gtk.Box
|
|
private var configure: [(Gtk.Box, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Box.init(orientation:spacing:)
|
|
/// Creates a new box.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
|
/// An empty closure adds no children and leaves slots unset.
|
|
/// A `ForEach` in the `children:` closure spreads its rows directly into this widget, with no wrapper, when the widget supports ordered insertion.
|
|
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
|
///
|
|
/// - Parameter orientation: The `orientation` value forwarded to `Gtk.Box`.
|
|
/// - Parameter spacing: The amount of space between children.
|
|
/// - Parameter baselineChild: The position of the child that determines the baseline.
|
|
/// - Parameter baselinePosition: How to position baseline-aligned widgets if extra space is available.
|
|
/// - Parameter homogeneous: Whether the children should all be the same size.
|
|
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
|
|
public init(orientation: Gtk.Orientation, spacing: Int32, baselineChild: Int32? = nil, baselinePosition: Gtk.BaselinePosition? = nil, homogeneous: Bool? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Gtk.Box(orientation: orientation, spacing: spacing) }
|
|
configure.append { w, ctx in
|
|
if let baselineChild { w.setBaselineChild(child: baselineChild) }
|
|
if let baselinePosition { w.setBaselinePosition(position: baselinePosition) }
|
|
if let homogeneous { w.setHomogeneous(homogeneous: homogeneous) }
|
|
Portico.mountChildren(children, into: w, ctx) { c in w.append(child: c) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Box: WidgetView {
|
|
public typealias Target = Gtk.Box
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Box, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Box: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.Box
|
|
/// Modifiers for `Gtk.Box`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Box` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Box {
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Gtk.Box.append(child:)
|
|
/// Adds a child at the end.
|
|
///
|
|
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
|
|
///
|
|
/// - Parameter child: A child widget to add.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func append(_ child: Gtk.Widget) -> Self {
|
|
appending { w, _ in
|
|
w.append(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Gtk.Box.append(child:)
|
|
/// Adds a child at the end.
|
|
///
|
|
/// Every view the closure produces is added at mount, in order.
|
|
///
|
|
/// - Parameter child: A closure producing child views.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func append(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
for v in childViews { w.append(child: v.makeWidget(ctx)) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Box.setBaselineChild(child:)
|
|
/// Sets the baseline child of a box.
|
|
///
|
|
/// This affects only vertical boxes.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter baselineChild: The position of the child that determines the baseline.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselineChild(_ baselineChild: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setBaselineChild(child: baselineChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Box.setBaselineChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Box.getBaselineChild()
|
|
/// Sets the baseline child of a box.
|
|
///
|
|
/// This affects only vertical boxes.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Int32` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselineChild(_ baselineChild: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, baselineChild, registry: ctx.registry, notifyDetail: "baseline-child",
|
|
read: { [w] in w.getBaselineChild() },
|
|
write: { [w] v in w.setBaselineChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Box.setBaselineChild(child:)
|
|
/// Sets the baseline child of a box.
|
|
///
|
|
/// This affects only vertical boxes.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Box.setBaselineChild(child:)`.
|
|
///
|
|
/// - Parameter baselineChild: The position of the child that determines the baseline.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselineChild(_ baselineChild: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setBaselineChild(child: baselineChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Box.setBaselinePosition(position:)
|
|
/// Sets the baseline position of a box.
|
|
///
|
|
/// This affects only horizontal boxes with at least one baseline
|
|
/// aligned child. If there is more vertical space available than
|
|
/// requested, and the baseline is not allocated by the parent then
|
|
/// `position` is used to allocate the baseline with respect to the
|
|
/// extra space available.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter baselinePosition: How to position baseline-aligned widgets if extra space is available.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselinePosition(_ baselinePosition: Gtk.BaselinePosition) -> Self {
|
|
appending { w, _ in
|
|
w.setBaselinePosition(position: baselinePosition)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Box.setBaselinePosition(position:), GObject.Object.connectNotify(detail:_:), Gtk.Box.getBaselinePosition()
|
|
/// Sets the baseline position of a box.
|
|
///
|
|
/// This affects only horizontal boxes with at least one baseline
|
|
/// aligned child. If there is more vertical space available than
|
|
/// requested, and the baseline is not allocated by the parent then
|
|
/// `position` is used to allocate the baseline with respect to the
|
|
/// extra space available.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.BaselinePosition` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselinePosition(_ baselinePosition: Portico.Binding<Gtk.BaselinePosition>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, baselinePosition, registry: ctx.registry, notifyDetail: "baseline-position",
|
|
read: { [w] in w.getBaselinePosition() },
|
|
write: { [w] v in w.setBaselinePosition(position: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Box.setBaselinePosition(position:)
|
|
/// Sets the baseline position of a box.
|
|
///
|
|
/// This affects only horizontal boxes with at least one baseline
|
|
/// aligned child. If there is more vertical space available than
|
|
/// requested, and the baseline is not allocated by the parent then
|
|
/// `position` is used to allocate the baseline with respect to the
|
|
/// extra space available.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Box.setBaselinePosition(position:)`.
|
|
///
|
|
/// - Parameter baselinePosition: How to position baseline-aligned widgets if extra space is available.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func baselinePosition(_ baselinePosition: @escaping () -> Gtk.BaselinePosition) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setBaselinePosition(position: baselinePosition()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Box.setHomogeneous(homogeneous:)
|
|
/// Sets whether or not all children are given equal space
|
|
/// in the box.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter homogeneous: Whether the children should all be the same size.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func homogeneous(_ homogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHomogeneous(homogeneous: homogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Box.setHomogeneous(homogeneous:), GObject.Object.connectNotify(detail:_:), Gtk.Box.getHomogeneous()
|
|
/// Sets whether or not all children are given equal space
|
|
/// in the box.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func homogeneous(_ homogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, homogeneous, registry: ctx.registry, notifyDetail: "homogeneous",
|
|
read: { [w] in w.getHomogeneous() },
|
|
write: { [w] v in w.setHomogeneous(homogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Box.setHomogeneous(homogeneous:)
|
|
/// Sets whether or not all children are given equal space
|
|
/// in the box.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Box.setHomogeneous(homogeneous:)`.
|
|
///
|
|
/// - Parameter homogeneous: Whether the children should all be the same size.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func homogeneous(_ homogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHomogeneous(homogeneous: homogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Box.setSpacing(spacing:)
|
|
/// Sets the number of pixels to place between children.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter spacing: The amount of space between children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func spacing(_ spacing: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setSpacing(spacing: spacing)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Box.setSpacing(spacing:), GObject.Object.connectNotify(detail:_:), Gtk.Box.getSpacing()
|
|
/// Sets the number of pixels to place between children.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Int32` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func spacing(_ spacing: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, spacing, registry: ctx.registry, notifyDetail: "spacing",
|
|
read: { [w] in w.getSpacing() },
|
|
write: { [w] v in w.setSpacing(spacing: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Box.setSpacing(spacing:)
|
|
/// Sets the number of pixels to place between children.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Box.setSpacing(spacing:)`.
|
|
///
|
|
/// - Parameter spacing: The amount of space between children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func spacing(_ spacing: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setSpacing(spacing: spacing()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
}
|