501 lines
27 KiB
Swift
501 lines
27 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.CenterBox
|
|
/// Arranges three children in a row, keeping the middle child
|
|
/// centered as well as possible.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="centerbox-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkCenterBox" src="centerbox.png">
|
|
/// </picture>
|
|
///
|
|
/// To add children to `GtkCenterBox`, use [method`Gtk`.CenterBox.set_start_widget],
|
|
/// [method`Gtk`.CenterBox.set_center_widget] and
|
|
/// [method`Gtk`.CenterBox.set_end_widget].
|
|
///
|
|
/// The sizing and positioning of children can be influenced with the
|
|
/// align and expand properties of the children.
|
|
///
|
|
/// # GtkCenterBox as GtkBuildable
|
|
///
|
|
/// The `GtkCenterBox` implementation of the `GtkBuildable` interface
|
|
/// supports placing children in the 3 positions by specifying “start”, “center”
|
|
/// or “end” as the “type” attribute of a `<child>` element.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkCenterBox` uses a single CSS node with the name “box”,
|
|
///
|
|
/// The first child of the `GtkCenterBox` will be allocated depending on the
|
|
/// text direction, i.e. in left-to-right layouts it will be allocated on the
|
|
/// left and in right-to-left layouts on the right.
|
|
///
|
|
/// In vertical orientation, the nodes of the children are arranged from top to
|
|
/// bottom.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// Until GTK 4.10, `GtkCenterBox` used the [enum`Gtk`.AccessibleRole.group] role.
|
|
///
|
|
/// Starting from GTK 4.12, `GtkCenterBox` uses the [enum`Gtk`.AccessibleRole.generic]
|
|
/// role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.CenterBox`.
|
|
@MainActor public struct CenterBox: View {
|
|
private let make: (MountContext) -> Gtk.CenterBox
|
|
private var configure: [(Gtk.CenterBox, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.CenterBox.init()
|
|
/// Creates a new `GtkCenterBox`.
|
|
///
|
|
/// 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.
|
|
/// 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 baselinePosition: The position of the baseline aligned widget if extra space is available.
|
|
/// - Parameter shrinkCenterLast: Whether to shrink the center widget after other children.
|
|
/// - Parameter centerWidget: A `ViewBuilder` closure whose first view is mounted into the `centerWidget` slot.
|
|
/// - Parameter endWidget: A `ViewBuilder` closure whose first view is mounted into the `endWidget` slot.
|
|
/// - Parameter startWidget: A `ViewBuilder` closure whose first view is mounted into the `startWidget` slot.
|
|
public init(baselinePosition: Gtk.BaselinePosition? = nil, shrinkCenterLast: Bool? = nil, @ViewBuilder centerWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder endWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder startWidget: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Gtk.CenterBox() }
|
|
configure.append { w, ctx in
|
|
if let baselinePosition { w.setBaselinePosition(position: baselinePosition) }
|
|
if let shrinkCenterLast { w.setShrinkCenterLast(shrinkCenterLast: shrinkCenterLast) }
|
|
if let v = Portico.mountSlotChild(centerWidget, ctx, onUpdate: { v in w.setCenterWidget(child: v) }) { w.setCenterWidget(child: v) }
|
|
if let v = Portico.mountSlotChild(endWidget, ctx, onUpdate: { v in w.setEndWidget(child: v) }) { w.setEndWidget(child: v) }
|
|
if let v = Portico.mountSlotChild(startWidget, ctx, onUpdate: { v in w.setStartWidget(child: v) }) { w.setStartWidget(child: v) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension CenterBox: WidgetView {
|
|
public typealias Target = Gtk.CenterBox
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.CenterBox, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension CenterBox: 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.CenterBox
|
|
/// Modifiers for `Gtk.CenterBox`, available on every Portico view whose
|
|
/// backing widget is `Gtk.CenterBox` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.CenterBox {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CenterBox.setBaselinePosition(position:)
|
|
/// Sets the baseline position of a center 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: The position of the baseline aligned widget 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.CenterBox.setBaselinePosition(position:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getBaselinePosition()
|
|
/// Sets the baseline position of a center 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.CenterBox.setBaselinePosition(position:)
|
|
/// Sets the baseline position of a center 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.CenterBox.setBaselinePosition(position:)`.
|
|
///
|
|
/// - Parameter baselinePosition: The position of the baseline aligned widget 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.CenterBox.setCenterWidget(child:)
|
|
/// Sets the center widget.
|
|
///
|
|
/// To remove the existing center widget, pass `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter centerWidget: The widget that is placed at the center position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func centerWidget(_ centerWidget: Gtk.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setCenterWidget(child: centerWidget)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.CenterBox.setCenterWidget(child:)
|
|
/// Sets the center widget.
|
|
///
|
|
/// To remove the existing center widget, pass `NULL`.
|
|
///
|
|
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
|
/// Additional views are ignored; an empty closure leaves the slot unset.
|
|
///
|
|
/// - Parameter centerWidget: The widget that is placed at the center position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func centerWidget(@ViewBuilder _ centerWidget: () -> [AnyView]) -> Self {
|
|
let centerWidgetViews = centerWidget()
|
|
return appending { w, ctx in
|
|
guard let v = centerWidgetViews.first else { return }
|
|
w.setCenterWidget(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CenterBox.setCenterWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getCenterWidget()
|
|
/// Sets the center widget.
|
|
///
|
|
/// To remove the existing center widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.Widget?` 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 centerWidget<W: Gtk.Widget>(_ centerWidget: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, centerWidget, registry: ctx.registry, notifyDetail: "center-widget",
|
|
read: { [w] in w.getCenterWidget() as? W },
|
|
write: { [w] v in w.setCenterWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CenterBox.setCenterWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getCenterWidget()
|
|
/// Sets the center widget.
|
|
///
|
|
/// To remove the existing center widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
|
|
/// When `Gtk.Widget` 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.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func centerWidget<W: Gtk.Widget>(_ centerWidget: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, centerWidget, registry: ctx.registry, notifyDetail: "center-widget",
|
|
read: { [w] in w.getCenterWidget() as? W },
|
|
write: { [w] v in w.setCenterWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CenterBox.setCenterWidget(child:)
|
|
/// Sets the center widget.
|
|
///
|
|
/// To remove the existing center widget, pass `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CenterBox.setCenterWidget(child:)`.
|
|
///
|
|
/// - Parameter centerWidget: The widget that is placed at the center position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func centerWidget(_ centerWidget: @escaping () -> Gtk.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCenterWidget(child: centerWidget()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CenterBox.setEndWidget(child:)
|
|
/// Sets the end widget.
|
|
///
|
|
/// To remove the existing end widget, pass `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter endWidget: The widget that is placed at the end position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func endWidget(_ endWidget: Gtk.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setEndWidget(child: endWidget)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.CenterBox.setEndWidget(child:)
|
|
/// Sets the end widget.
|
|
///
|
|
/// To remove the existing end widget, pass `NULL`.
|
|
///
|
|
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
|
/// Additional views are ignored; an empty closure leaves the slot unset.
|
|
///
|
|
/// - Parameter endWidget: The widget that is placed at the end position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func endWidget(@ViewBuilder _ endWidget: () -> [AnyView]) -> Self {
|
|
let endWidgetViews = endWidget()
|
|
return appending { w, ctx in
|
|
guard let v = endWidgetViews.first else { return }
|
|
w.setEndWidget(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CenterBox.setEndWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getEndWidget()
|
|
/// Sets the end widget.
|
|
///
|
|
/// To remove the existing end widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.Widget?` 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 endWidget<W: Gtk.Widget>(_ endWidget: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, endWidget, registry: ctx.registry, notifyDetail: "end-widget",
|
|
read: { [w] in w.getEndWidget() as? W },
|
|
write: { [w] v in w.setEndWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CenterBox.setEndWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getEndWidget()
|
|
/// Sets the end widget.
|
|
///
|
|
/// To remove the existing end widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
|
|
/// When `Gtk.Widget` 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.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func endWidget<W: Gtk.Widget>(_ endWidget: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, endWidget, registry: ctx.registry, notifyDetail: "end-widget",
|
|
read: { [w] in w.getEndWidget() as? W },
|
|
write: { [w] v in w.setEndWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CenterBox.setEndWidget(child:)
|
|
/// Sets the end widget.
|
|
///
|
|
/// To remove the existing end widget, pass `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CenterBox.setEndWidget(child:)`.
|
|
///
|
|
/// - Parameter endWidget: The widget that is placed at the end position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func endWidget(_ endWidget: @escaping () -> Gtk.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setEndWidget(child: endWidget()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CenterBox.setShrinkCenterLast(shrinkCenterLast:)
|
|
/// Sets whether to shrink the center widget after other children.
|
|
///
|
|
/// By default, when there's no space to give all three children their
|
|
/// natural widths, the start and end widgets start shrinking and the
|
|
/// center child keeps natural width until they reach minimum width.
|
|
///
|
|
/// If `shrink_center_last` is false, start and end widgets keep natural
|
|
/// width and the center widget starts shrinking instead.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter shrinkCenterLast: Whether to shrink the center widget after other children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func shrinkCenterLast(_ shrinkCenterLast: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setShrinkCenterLast(shrinkCenterLast: shrinkCenterLast)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CenterBox.setShrinkCenterLast(shrinkCenterLast:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getShrinkCenterLast()
|
|
/// Sets whether to shrink the center widget after other children.
|
|
///
|
|
/// By default, when there's no space to give all three children their
|
|
/// natural widths, the start and end widgets start shrinking and the
|
|
/// center child keeps natural width until they reach minimum width.
|
|
///
|
|
/// If `shrink_center_last` is false, start and end widgets keep natural
|
|
/// width and the center widget starts shrinking instead.
|
|
///
|
|
/// 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 shrinkCenterLast(_ shrinkCenterLast: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, shrinkCenterLast, registry: ctx.registry, notifyDetail: "shrink-center-last",
|
|
read: { [w] in w.getShrinkCenterLast() },
|
|
write: { [w] v in w.setShrinkCenterLast(shrinkCenterLast: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CenterBox.setShrinkCenterLast(shrinkCenterLast:)
|
|
/// Sets whether to shrink the center widget after other children.
|
|
///
|
|
/// By default, when there's no space to give all three children their
|
|
/// natural widths, the start and end widgets start shrinking and the
|
|
/// center child keeps natural width until they reach minimum width.
|
|
///
|
|
/// If `shrink_center_last` is false, start and end widgets keep natural
|
|
/// width and the center widget starts shrinking instead.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CenterBox.setShrinkCenterLast(shrinkCenterLast:)`.
|
|
///
|
|
/// - Parameter shrinkCenterLast: Whether to shrink the center widget after other children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func shrinkCenterLast(_ shrinkCenterLast: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setShrinkCenterLast(shrinkCenterLast: shrinkCenterLast()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CenterBox.setStartWidget(child:)
|
|
/// Sets the start widget.
|
|
///
|
|
/// To remove the existing start widget, pass `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter startWidget: The widget that is placed at the start position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func startWidget(_ startWidget: Gtk.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setStartWidget(child: startWidget)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.CenterBox.setStartWidget(child:)
|
|
/// Sets the start widget.
|
|
///
|
|
/// To remove the existing start widget, pass `NULL`.
|
|
///
|
|
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
|
/// Additional views are ignored; an empty closure leaves the slot unset.
|
|
///
|
|
/// - Parameter startWidget: The widget that is placed at the start position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func startWidget(@ViewBuilder _ startWidget: () -> [AnyView]) -> Self {
|
|
let startWidgetViews = startWidget()
|
|
return appending { w, ctx in
|
|
guard let v = startWidgetViews.first else { return }
|
|
w.setStartWidget(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CenterBox.setStartWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getStartWidget()
|
|
/// Sets the start widget.
|
|
///
|
|
/// To remove the existing start widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.Widget?` 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 startWidget<W: Gtk.Widget>(_ startWidget: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, startWidget, registry: ctx.registry, notifyDetail: "start-widget",
|
|
read: { [w] in w.getStartWidget() as? W },
|
|
write: { [w] v in w.setStartWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CenterBox.setStartWidget(child:), GObject.Object.connectNotify(detail:_:), Gtk.CenterBox.getStartWidget()
|
|
/// Sets the start widget.
|
|
///
|
|
/// To remove the existing start widget, pass `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
|
|
/// When `Gtk.Widget` 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.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func startWidget<W: Gtk.Widget>(_ startWidget: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, startWidget, registry: ctx.registry, notifyDetail: "start-widget",
|
|
read: { [w] in w.getStartWidget() as? W },
|
|
write: { [w] v in w.setStartWidget(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CenterBox.setStartWidget(child:)
|
|
/// Sets the start widget.
|
|
///
|
|
/// To remove the existing start widget, pass `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CenterBox.setStartWidget(child:)`.
|
|
///
|
|
/// - Parameter startWidget: The widget that is placed at the start position.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func startWidget(_ startWidget: @escaping () -> Gtk.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setStartWidget(child: startWidget()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
}
|