portico/Sources/Portico/Generated/Grid.swift

388 lines
19 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.Grid
/// Arranges its child widgets in rows and columns.
///
/// <picture>
/// <source srcset="grid-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkGrid" src="grid.png">
/// </picture>
///
/// It supports arbitrary positions and horizontal/vertical spans.
///
/// Children are added using [method`Gtk`.Grid.attach]. They can span multiple
/// rows or columns. It is also possible to add a child next to an existing
/// child, using [method`Gtk`.Grid.attach_next_to]. To remove a child from the
/// grid, use [method`Gtk`.Grid.remove].
///
/// The behaviour of `GtkGrid` when several children occupy the same grid
/// cell is undefined.
///
/// # GtkGrid as GtkBuildable
///
/// Every child in a `GtkGrid` has access to a custom [iface`Gtk`.Buildable]
/// element, called `<layout>`. It can by used to specify a position in the
/// grid and optionally spans. All properties that can be used in the `<layout>`
/// element are implemented by [class`Gtk`.GridLayoutChild].
///
/// It is implemented by `GtkWidget` using [class`Gtk`.LayoutManager].
///
/// To showcase it, here is a simple example:
///
/// ```xml
/// <object class="GtkGrid" id="my_grid">
/// <child>
/// <object class="GtkButton" id="button1">
/// <property name="label">Button 1</property>
/// <layout>
/// <property name="column">0</property>
/// <property name="row">0</property>
/// </layout>
/// </object>
/// </child>
/// <child>
/// <object class="GtkButton" id="button2">
/// <property name="label">Button 2</property>
/// <layout>
/// <property name="column">1</property>
/// <property name="row">0</property>
/// </layout>
/// </object>
/// </child>
/// <child>
/// <object class="GtkButton" id="button3">
/// <property name="label">Button 3</property>
/// <layout>
/// <property name="column">2</property>
/// <property name="row">0</property>
/// <property name="row-span">2</property>
/// </layout>
/// </object>
/// </child>
/// <child>
/// <object class="GtkButton" id="button4">
/// <property name="label">Button 4</property>
/// <layout>
/// <property name="column">0</property>
/// <property name="row">1</property>
/// <property name="column-span">2</property>
/// </layout>
/// </object>
/// </child>
/// </object>
/// ```
///
/// It organizes the first two buttons side-by-side in one cell each.
/// The third button is in the last column but spans across two rows.
/// This is defined by the `row-span` property. The last button is
/// located in the second row and spans across two columns, which is
/// defined by the `column-span` property.
///
/// # CSS nodes
///
/// `GtkGrid` uses a single CSS node with name `grid`.
///
/// # Accessibility
///
/// Until GTK 4.10, `GtkGrid` used the [enum`Gtk`.AccessibleRole.group] role.
///
/// Starting from GTK 4.12, `GtkGrid` uses the [enum`Gtk`.AccessibleRole.generic] role.
///
/// A Portico view that mounts a `Gtk.Grid`.
@MainActor public struct Grid: View {
private let make: (MountContext) -> Gtk.Grid
private var configure: [(Gtk.Grid, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Grid.init()
/// Creates a new grid widget.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// 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 baselineRow: The row to align to the baseline when valign is using baseline alignment.
/// - Parameter columnHomogeneous: If `true`, the columns are all the same width.
/// - Parameter columnSpacing: The amount of space between two consecutive columns.
/// - Parameter rowHomogeneous: If `true`, the rows are all the same height.
/// - Parameter rowSpacing: The amount of space between two consecutive rows.
public init(baselineRow: Int32? = nil, columnHomogeneous: Bool? = nil, columnSpacing: UInt32? = nil, rowHomogeneous: Bool? = nil, rowSpacing: UInt32? = nil) {
make = { _ in Gtk.Grid() }
configure.append { w, _ in
if let baselineRow { w.setBaselineRow(row: baselineRow) }
if let columnHomogeneous { w.setColumnHomogeneous(homogeneous: columnHomogeneous) }
if let columnSpacing { w.setColumnSpacing(spacing: columnSpacing) }
if let rowHomogeneous { w.setRowHomogeneous(homogeneous: rowHomogeneous) }
if let rowSpacing { w.setRowSpacing(spacing: rowSpacing) }
}
}
}
extension Grid: WidgetView {
public typealias Target = Gtk.Grid
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Grid, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Grid: 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.Grid
/// Modifiers for `Gtk.Grid`, available on every Portico view whose
/// backing widget is `Gtk.Grid` or one of its subclasses.
extension WidgetView where Target: Gtk.Grid {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Grid.setBaselineRow(row:)
/// Sets which row defines the global baseline for the entire grid.
///
/// Each row in the grid can have its own local baseline, but only
/// one of those is global, meaning it will be the baseline in the
/// parent of the `grid`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter baselineRow: The row to align to the baseline when valign is using baseline alignment.
/// - Returns: A copy of this view with the modifier applied.
public func baselineRow(_ baselineRow: Int32) -> Self {
appending { w, _ in
w.setBaselineRow(row: baselineRow)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Grid.setBaselineRow(row:), GObject.Object.connectNotify(detail:_:), Gtk.Grid.getBaselineRow()
/// Sets which row defines the global baseline for the entire grid.
///
/// Each row in the grid can have its own local baseline, but only
/// one of those is global, meaning it will be the baseline in the
/// parent of the `grid`.
///
/// 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 baselineRow(_ baselineRow: Portico.Binding<Int32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, baselineRow, registry: ctx.registry, notifyDetail: "baseline-row",
read: { [w] in w.getBaselineRow() },
write: { [w] v in w.setBaselineRow(row: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Grid.setBaselineRow(row:)
/// Sets which row defines the global baseline for the entire grid.
///
/// Each row in the grid can have its own local baseline, but only
/// one of those is global, meaning it will be the baseline in the
/// parent of the `grid`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Grid.setBaselineRow(row:)`.
///
/// - Parameter baselineRow: The row to align to the baseline when valign is using baseline alignment.
/// - Returns: A copy of this view with the modifier applied.
public func baselineRow(_ baselineRow: @escaping () -> Int32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setBaselineRow(row: baselineRow()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Grid.setColumnHomogeneous(homogeneous:)
/// Sets whether all columns of `grid` will have the same width.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter columnHomogeneous: If `true`, the columns are all the same width.
/// - Returns: A copy of this view with the modifier applied.
public func columnHomogeneous(_ columnHomogeneous: Bool) -> Self {
appending { w, _ in
w.setColumnHomogeneous(homogeneous: columnHomogeneous)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Grid.setColumnHomogeneous(homogeneous:), GObject.Object.connectNotify(detail:_:), Gtk.Grid.getColumnHomogeneous()
/// Sets whether all columns of `grid` will have the same width.
///
/// 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 columnHomogeneous(_ columnHomogeneous: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, columnHomogeneous, registry: ctx.registry, notifyDetail: "column-homogeneous",
read: { [w] in w.getColumnHomogeneous() },
write: { [w] v in w.setColumnHomogeneous(homogeneous: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Grid.setColumnHomogeneous(homogeneous:)
/// Sets whether all columns of `grid` will have the same width.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Grid.setColumnHomogeneous(homogeneous:)`.
///
/// - Parameter columnHomogeneous: If `true`, the columns are all the same width.
/// - Returns: A copy of this view with the modifier applied.
public func columnHomogeneous(_ columnHomogeneous: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setColumnHomogeneous(homogeneous: columnHomogeneous()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Grid.setColumnSpacing(spacing:)
/// Sets the amount of space between columns of `grid`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter columnSpacing: The amount of space between two consecutive columns.
/// - Returns: A copy of this view with the modifier applied.
public func columnSpacing(_ columnSpacing: UInt32) -> Self {
appending { w, _ in
w.setColumnSpacing(spacing: columnSpacing)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Grid.setColumnSpacing(spacing:), GObject.Object.connectNotify(detail:_:), Gtk.Grid.getColumnSpacing()
/// Sets the amount of space between columns of `grid`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` 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 columnSpacing(_ columnSpacing: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, columnSpacing, registry: ctx.registry, notifyDetail: "column-spacing",
read: { [w] in w.getColumnSpacing() },
write: { [w] v in w.setColumnSpacing(spacing: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Grid.setColumnSpacing(spacing:)
/// Sets the amount of space between columns of `grid`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Grid.setColumnSpacing(spacing:)`.
///
/// - Parameter columnSpacing: The amount of space between two consecutive columns.
/// - Returns: A copy of this view with the modifier applied.
public func columnSpacing(_ columnSpacing: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setColumnSpacing(spacing: columnSpacing()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Grid.setRowHomogeneous(homogeneous:)
/// Sets whether all rows of `grid` will have the same height.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter rowHomogeneous: If `true`, the rows are all the same height.
/// - Returns: A copy of this view with the modifier applied.
public func rowHomogeneous(_ rowHomogeneous: Bool) -> Self {
appending { w, _ in
w.setRowHomogeneous(homogeneous: rowHomogeneous)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Grid.setRowHomogeneous(homogeneous:), GObject.Object.connectNotify(detail:_:), Gtk.Grid.getRowHomogeneous()
/// Sets whether all rows of `grid` will have the same height.
///
/// 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 rowHomogeneous(_ rowHomogeneous: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, rowHomogeneous, registry: ctx.registry, notifyDetail: "row-homogeneous",
read: { [w] in w.getRowHomogeneous() },
write: { [w] v in w.setRowHomogeneous(homogeneous: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Grid.setRowHomogeneous(homogeneous:)
/// Sets whether all rows of `grid` will have the same height.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Grid.setRowHomogeneous(homogeneous:)`.
///
/// - Parameter rowHomogeneous: If `true`, the rows are all the same height.
/// - Returns: A copy of this view with the modifier applied.
public func rowHomogeneous(_ rowHomogeneous: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setRowHomogeneous(homogeneous: rowHomogeneous()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Grid.setRowSpacing(spacing:)
/// Sets the amount of space between rows of `grid`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter rowSpacing: The amount of space between two consecutive rows.
/// - Returns: A copy of this view with the modifier applied.
public func rowSpacing(_ rowSpacing: UInt32) -> Self {
appending { w, _ in
w.setRowSpacing(spacing: rowSpacing)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Grid.setRowSpacing(spacing:), GObject.Object.connectNotify(detail:_:), Gtk.Grid.getRowSpacing()
/// Sets the amount of space between rows of `grid`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` 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 rowSpacing(_ rowSpacing: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, rowSpacing, registry: ctx.registry, notifyDetail: "row-spacing",
read: { [w] in w.getRowSpacing() },
write: { [w] v in w.setRowSpacing(spacing: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Grid.setRowSpacing(spacing:)
/// Sets the amount of space between rows of `grid`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Grid.setRowSpacing(spacing:)`.
///
/// - Parameter rowSpacing: The amount of space between two consecutive rows.
/// - Returns: A copy of this view with the modifier applied.
public func rowSpacing(_ rowSpacing: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setRowSpacing(spacing: rowSpacing()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}