portico/Sources/Portico/Generated/Squeezer.swift

587 lines
32 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Adw.Squeezer
/// A best fit container.
///
/// <picture>
/// <source srcset="squeezer-wide-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="squeezer-wide.png" alt="squeezer-wide">
/// </picture>
/// <picture>
/// <source srcset="squeezer-narrow-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="squeezer-narrow.png" alt="squeezer-narrow">
/// </picture>
///
/// The `AdwSqueezer` widget is a container which only shows the first of its
/// children that fits in the available size. It is convenient to offer different
/// widgets to represent the same data with different levels of detail, making
/// the widget seem to squeeze itself to fit in the available space.
///
/// Transitions between children can be animated as fades. This can be controlled
/// with [property`Squeezer`:transition-type].
///
/// ## CSS nodes
///
/// `AdwSqueezer` has a single CSS node with name `squeezer`.
///
/// A Portico view that mounts a `Adw.Squeezer`.
@MainActor public struct Squeezer: View {
private let make: (MountContext) -> Adw.Squeezer
private var configure: [(Adw.Squeezer, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.Squeezer.init()
/// Creates a new `AdwSqueezer`.
///
/// 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 allowNone: Whether to allow squeezing beyond the last child's minimum size.
/// - Parameter homogeneous: Whether all children have the same size for the opposite orientation.
/// - Parameter interpolateSize: Whether the squeezer interpolates its size when changing the visible child.
/// - Parameter switchThresholdPolicy: The switch threshold policy.
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
/// - Parameter transitionType: The type of animation used for transitions between children.
/// - Parameter xalign: The horizontal alignment, from 0 (start) to 1 (end).
/// - Parameter yalign: The vertical alignment, from 0 (top) to 1 (bottom).
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
public init(allowNone: Bool? = nil, homogeneous: Bool? = nil, interpolateSize: Bool? = nil, switchThresholdPolicy: Adw.FoldThresholdPolicy? = nil, transitionDuration: UInt32? = nil, transitionType: Adw.SqueezerTransitionType? = nil, xalign: Float? = nil, yalign: Float? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }) {
make = { _ in Adw.Squeezer() }
configure.append { w, ctx in
if let allowNone { w.setAllowNone(allowNone: allowNone) }
if let homogeneous { w.setHomogeneous(homogeneous: homogeneous) }
if let interpolateSize { w.setInterpolateSize(interpolateSize: interpolateSize) }
if let switchThresholdPolicy { w.setSwitchThresholdPolicy(policy: switchThresholdPolicy) }
if let transitionDuration { w.setTransitionDuration(duration: transitionDuration) }
if let transitionType { w.setTransitionType(transition: transitionType) }
if let xalign { w.setXalign(xalign: xalign) }
if let yalign { w.setYalign(yalign: yalign) }
Portico.mountChildren(children, into: w, ctx) { c in _ = w.add(child: c) }
}
}
}
extension Squeezer: WidgetView {
public typealias Target = Adw.Squeezer
@_spi(Portico) public func appending(
_ step: @escaping (Adw.Squeezer, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Squeezer: 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: Adw.Squeezer
/// Modifiers for `Adw.Squeezer`, available on every Portico view whose
/// backing widget is `Adw.Squeezer` or one of its subclasses.
extension WidgetView where Target: Adw.Squeezer {
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.Squeezer.add(child:)
/// Adds a child to `self`.
///
/// 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 add(_ child: Gtk.Widget) -> Self {
appending { w, _ in
_ = w.add(child: child)
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.Squeezer.add(child:)
/// Adds a child to `self`.
///
/// 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 add(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
for v in childViews { _ = w.add(child: v.makeWidget(ctx)) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setAllowNone(allowNone:)
/// Sets whether to allow squeezing beyond the last child's minimum size.
///
/// If set to `TRUE`, the squeezer can shrink to the point where no child can be
/// shown. This is functionally equivalent to appending a widget with 0×0 minimum
/// size.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter allowNone: Whether to allow squeezing beyond the last child's minimum size.
/// - Returns: A copy of this view with the modifier applied.
public func allowNone(_ allowNone: Bool) -> Self {
appending { w, _ in
w.setAllowNone(allowNone: allowNone)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setAllowNone(allowNone:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getAllowNone()
/// Sets whether to allow squeezing beyond the last child's minimum size.
///
/// If set to `TRUE`, the squeezer can shrink to the point where no child can be
/// shown. This is functionally equivalent to appending a widget with 0×0 minimum
/// size.
///
/// 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 allowNone(_ allowNone: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, allowNone, registry: ctx.registry, notifyDetail: "allow-none",
read: { [w] in w.getAllowNone() },
write: { [w] v in w.setAllowNone(allowNone: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setAllowNone(allowNone:)
/// Sets whether to allow squeezing beyond the last child's minimum size.
///
/// If set to `TRUE`, the squeezer can shrink to the point where no child can be
/// shown. This is functionally equivalent to appending a widget with 0×0 minimum
/// size.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setAllowNone(allowNone:)`.
///
/// - Parameter allowNone: Whether to allow squeezing beyond the last child's minimum size.
/// - Returns: A copy of this view with the modifier applied.
public func allowNone(_ allowNone: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAllowNone(allowNone: allowNone()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setHomogeneous(homogeneous:)
/// Sets whether all children have the same size for the opposite orientation.
///
/// For example, if a squeezer is horizontal and is homogeneous, it will request
/// the same height for all its children. If it isn't, the squeezer may change
/// size when a different child becomes visible.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter homogeneous: Whether all children have the same size for the opposite orientation.
/// - 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: Adw.Squeezer.setHomogeneous(homogeneous:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getHomogeneous()
/// Sets whether all children have the same size for the opposite orientation.
///
/// For example, if a squeezer is horizontal and is homogeneous, it will request
/// the same height for all its children. If it isn't, the squeezer may change
/// size when a different child becomes visible.
///
/// 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: Adw.Squeezer.setHomogeneous(homogeneous:)
/// Sets whether all children have the same size for the opposite orientation.
///
/// For example, if a squeezer is horizontal and is homogeneous, it will request
/// the same height for all its children. If it isn't, the squeezer may change
/// size when a different child becomes visible.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setHomogeneous(homogeneous:)`.
///
/// - Parameter homogeneous: Whether all children have the same size for the opposite orientation.
/// - 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: Adw.Squeezer.setInterpolateSize(interpolateSize:)
/// Sets whether `self` interpolates its size when changing the visible child.
///
/// If `TRUE`, the squeezer will interpolate its size between the one of the
/// previous visible child and the one of the new visible child, according to the
/// set transition duration and the orientation, e.g. if the squeezer is
/// horizontal, it will interpolate the its height.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter interpolateSize: Whether the squeezer interpolates its size when changing the visible child.
/// - Returns: A copy of this view with the modifier applied.
public func interpolateSize(_ interpolateSize: Bool) -> Self {
appending { w, _ in
w.setInterpolateSize(interpolateSize: interpolateSize)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setInterpolateSize(interpolateSize:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getInterpolateSize()
/// Sets whether `self` interpolates its size when changing the visible child.
///
/// If `TRUE`, the squeezer will interpolate its size between the one of the
/// previous visible child and the one of the new visible child, according to the
/// set transition duration and the orientation, e.g. if the squeezer is
/// horizontal, it will interpolate the its 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 interpolateSize(_ interpolateSize: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, interpolateSize, registry: ctx.registry, notifyDetail: "interpolate-size",
read: { [w] in w.getInterpolateSize() },
write: { [w] v in w.setInterpolateSize(interpolateSize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setInterpolateSize(interpolateSize:)
/// Sets whether `self` interpolates its size when changing the visible child.
///
/// If `TRUE`, the squeezer will interpolate its size between the one of the
/// previous visible child and the one of the new visible child, according to the
/// set transition duration and the orientation, e.g. if the squeezer is
/// horizontal, it will interpolate the its height.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setInterpolateSize(interpolateSize:)`.
///
/// - Parameter interpolateSize: Whether the squeezer interpolates its size when changing the visible child.
/// - Returns: A copy of this view with the modifier applied.
public func interpolateSize(_ interpolateSize: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInterpolateSize(interpolateSize: interpolateSize()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setSwitchThresholdPolicy(policy:)
/// Sets the switch threshold policy for `self`.
///
/// Determines when the squeezer will switch children.
///
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only switch when
/// the visible child cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural],
/// it will switch as soon as the visible child doesn't get their natural size.
///
/// This can be useful if you have a long ellipsizing label and want to let it
/// ellipsize instead of immediately switching.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter switchThresholdPolicy: The switch threshold policy.
/// - Returns: A copy of this view with the modifier applied.
public func switchThresholdPolicy(_ switchThresholdPolicy: Adw.FoldThresholdPolicy) -> Self {
appending { w, _ in
w.setSwitchThresholdPolicy(policy: switchThresholdPolicy)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setSwitchThresholdPolicy(policy:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getSwitchThresholdPolicy()
/// Sets the switch threshold policy for `self`.
///
/// Determines when the squeezer will switch children.
///
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only switch when
/// the visible child cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural],
/// it will switch as soon as the visible child doesn't get their natural size.
///
/// This can be useful if you have a long ellipsizing label and want to let it
/// ellipsize instead of immediately switching.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.FoldThresholdPolicy` 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 switchThresholdPolicy(_ switchThresholdPolicy: Portico.Binding<Adw.FoldThresholdPolicy>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, switchThresholdPolicy, registry: ctx.registry, notifyDetail: "switch-threshold-policy",
read: { [w] in w.getSwitchThresholdPolicy() },
write: { [w] v in w.setSwitchThresholdPolicy(policy: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setSwitchThresholdPolicy(policy:)
/// Sets the switch threshold policy for `self`.
///
/// Determines when the squeezer will switch children.
///
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only switch when
/// the visible child cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural],
/// it will switch as soon as the visible child doesn't get their natural size.
///
/// This can be useful if you have a long ellipsizing label and want to let it
/// ellipsize instead of immediately switching.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setSwitchThresholdPolicy(policy:)`.
///
/// - Parameter switchThresholdPolicy: The switch threshold policy.
/// - Returns: A copy of this view with the modifier applied.
public func switchThresholdPolicy(_ switchThresholdPolicy: @escaping () -> Adw.FoldThresholdPolicy) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSwitchThresholdPolicy(policy: switchThresholdPolicy()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setTransitionDuration(duration:)
/// Sets the transition animation duration for `self`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
/// - Returns: A copy of this view with the modifier applied.
public func transitionDuration(_ transitionDuration: UInt32) -> Self {
appending { w, _ in
w.setTransitionDuration(duration: transitionDuration)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setTransitionDuration(duration:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getTransitionDuration()
/// Sets the transition animation duration for `self`.
///
/// 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 transitionDuration(_ transitionDuration: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, transitionDuration, registry: ctx.registry, notifyDetail: "transition-duration",
read: { [w] in w.getTransitionDuration() },
write: { [w] v in w.setTransitionDuration(duration: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setTransitionDuration(duration:)
/// Sets the transition animation duration for `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setTransitionDuration(duration:)`.
///
/// - Parameter transitionDuration: The transition animation duration, in milliseconds.
/// - Returns: A copy of this view with the modifier applied.
public func transitionDuration(_ transitionDuration: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTransitionDuration(duration: transitionDuration()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setTransitionType(transition:)
/// Sets the type of animation used for transitions between children in `self`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter transitionType: The type of animation used for transitions between children.
/// - Returns: A copy of this view with the modifier applied.
public func transitionType(_ transitionType: Adw.SqueezerTransitionType) -> Self {
appending { w, _ in
w.setTransitionType(transition: transitionType)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setTransitionType(transition:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getTransitionType()
/// Sets the type of animation used for transitions between children in `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.SqueezerTransitionType` 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 transitionType(_ transitionType: Portico.Binding<Adw.SqueezerTransitionType>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, transitionType, registry: ctx.registry, notifyDetail: "transition-type",
read: { [w] in w.getTransitionType() },
write: { [w] v in w.setTransitionType(transition: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setTransitionType(transition:)
/// Sets the type of animation used for transitions between children in `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setTransitionType(transition:)`.
///
/// - Parameter transitionType: The type of animation used for transitions between children.
/// - Returns: A copy of this view with the modifier applied.
public func transitionType(_ transitionType: @escaping () -> Adw.SqueezerTransitionType) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTransitionType(transition: transitionType()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setXalign(xalign:)
/// Sets the horizontal alignment, from 0 (start) to 1 (end).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// start side aligned and overflow the end side, and 1 means the opposite.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter xalign: The horizontal alignment, from 0 (start) to 1 (end).
/// - Returns: A copy of this view with the modifier applied.
public func xalign(_ xalign: Float) -> Self {
appending { w, _ in
w.setXalign(xalign: xalign)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setXalign(xalign:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getXalign()
/// Sets the horizontal alignment, from 0 (start) to 1 (end).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// start side aligned and overflow the end side, and 1 means the opposite.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Float` 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 xalign(_ xalign: Portico.Binding<Float>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, xalign, registry: ctx.registry, notifyDetail: "xalign",
read: { [w] in w.getXalign() },
write: { [w] v in w.setXalign(xalign: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setXalign(xalign:)
/// Sets the horizontal alignment, from 0 (start) to 1 (end).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// start side aligned and overflow the end side, and 1 means the opposite.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setXalign(xalign:)`.
///
/// - Parameter xalign: The horizontal alignment, from 0 (start) to 1 (end).
/// - Returns: A copy of this view with the modifier applied.
public func xalign(_ xalign: @escaping () -> Float) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setXalign(xalign: xalign()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Squeezer.setYalign(yalign:)
/// Sets the vertical alignment, from 0 (top) to 1 (bottom).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// top side aligned and overflow the bottom side, and 1 means the opposite.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter yalign: The vertical alignment, from 0 (top) to 1 (bottom).
/// - Returns: A copy of this view with the modifier applied.
public func yalign(_ yalign: Float) -> Self {
appending { w, _ in
w.setYalign(yalign: yalign)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Squeezer.setYalign(yalign:), GObject.Object.connectNotify(detail:_:), Adw.Squeezer.getYalign()
/// Sets the vertical alignment, from 0 (top) to 1 (bottom).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// top side aligned and overflow the bottom side, and 1 means the opposite.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Float` 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 yalign(_ yalign: Portico.Binding<Float>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, yalign, registry: ctx.registry, notifyDetail: "yalign",
read: { [w] in w.getYalign() },
write: { [w] v in w.setYalign(yalign: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Squeezer.setYalign(yalign:)
/// Sets the vertical alignment, from 0 (top) to 1 (bottom).
///
/// This affects the children allocation during transitions, when they exceed the
/// size of the squeezer.
///
/// For example, 0.5 means the child will be centered, 0 means it will keep the
/// top side aligned and overflow the bottom side, and 1 means the opposite.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Squeezer.setYalign(yalign:)`.
///
/// - Parameter yalign: The vertical alignment, from 0 (top) to 1 (bottom).
/// - Returns: A copy of this view with the modifier applied.
public func yalign(_ yalign: @escaping () -> Float) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setYalign(yalign: yalign()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}