646 lines
34 KiB
Swift
646 lines
34 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.Stack
|
|
/// Shows one of its children at a time.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="stack-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkStack" src="stack.png">
|
|
/// </picture>
|
|
///
|
|
/// In contrast to `GtkNotebook`, `GtkStack` does not provide a means
|
|
/// for users to change the visible child. Instead, a separate widget
|
|
/// such as [class`Gtk`.StackSwitcher] or [class`Gtk`.StackSidebar] can
|
|
/// be used with `GtkStack` to provide this functionality.
|
|
///
|
|
/// Transitions between pages can be animated as slides or fades. This
|
|
/// can be controlled with [method`Gtk`.Stack.set_transition_type].
|
|
/// These animations respect the [property`Gtk`.Settings:gtk-enable-animations]
|
|
/// setting.
|
|
///
|
|
/// `GtkStack` maintains a [class`Gtk`.StackPage] object for each added
|
|
/// child, which holds additional per-child properties. You
|
|
/// obtain the `GtkStackPage` for a child with [method`Gtk`.Stack.get_page]
|
|
/// and you can obtain a `GtkSelectionModel` containing all the pages
|
|
/// with [method`Gtk`.Stack.get_pages].
|
|
///
|
|
/// # GtkStack as GtkBuildable
|
|
///
|
|
/// To set child-specific properties in a .ui file, create `GtkStackPage`
|
|
/// objects explicitly, and set the child widget as a property on it:
|
|
///
|
|
/// ```xml
|
|
/// <object class="GtkStack" id="stack">
|
|
/// <child>
|
|
/// <object class="GtkStackPage">
|
|
/// <property name="name">page1</property>
|
|
/// <property name="title">In the beginning…</property>
|
|
/// <property name="child">
|
|
/// <object class="GtkLabel">
|
|
/// <property name="label">It was dark</property>
|
|
/// </object>
|
|
/// </property>
|
|
/// </object>
|
|
/// </child>
|
|
/// ```
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkStack` has a single CSS node named stack.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkStack` uses the [enum`Gtk`.AccessibleRole.tab_panel] role for the stack
|
|
/// pages, which are the accessible parent objects of the child widgets.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Stack`.
|
|
@MainActor public struct Stack: View {
|
|
private let make: (MountContext) -> Gtk.Stack
|
|
private var configure: [(Gtk.Stack, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Stack.init()
|
|
/// Creates a new `GtkStack`.
|
|
///
|
|
/// 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 hhomogeneous: `true` if the stack allocates the same width for all children.
|
|
/// - Parameter interpolateSize: Whether or not the size should smoothly change during the transition.
|
|
/// - Parameter transitionDuration: The animation duration, in milliseconds.
|
|
/// - Parameter transitionType: The type of animation used to transition.
|
|
/// - Parameter vhomogeneous: `true` if the stack allocates the same height for all children.
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
|
|
public init(hhomogeneous: Bool? = nil, interpolateSize: Bool? = nil, transitionDuration: UInt32? = nil, transitionType: Gtk.StackTransitionType? = nil, vhomogeneous: Bool? = nil, visibleChildName: String? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Gtk.Stack() }
|
|
configure.append { w, ctx in
|
|
if let hhomogeneous { w.setHhomogeneous(hhomogeneous: hhomogeneous) }
|
|
if let interpolateSize { w.setInterpolateSize(interpolateSize: interpolateSize) }
|
|
if let transitionDuration { w.setTransitionDuration(duration: transitionDuration) }
|
|
if let transitionType { w.setTransitionType(transition: transitionType) }
|
|
if let vhomogeneous { w.setVhomogeneous(vhomogeneous: vhomogeneous) }
|
|
if let visibleChildName { w.setVisibleChildName(name: visibleChildName) }
|
|
Portico.mountChildren(children, into: w, ctx) { c in _ = w.addChild(child: c) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Stack: WidgetView {
|
|
public typealias Target = Gtk.Stack
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Stack, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Stack: 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.Stack
|
|
/// Modifiers for `Gtk.Stack`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Stack` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Stack {
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Gtk.Stack.addChild(child:)
|
|
/// Adds a child to `stack`.
|
|
///
|
|
/// 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 addChild(_ child: Gtk.Widget) -> Self {
|
|
appending { w, _ in
|
|
_ = w.addChild(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Gtk.Stack.addChild(child:)
|
|
/// Adds a child to `stack`.
|
|
///
|
|
/// 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 addChild(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
for v in childViews { _ = w.addChild(child: v.makeWidget(ctx)) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Stack.setHhomogeneous(hhomogeneous:)
|
|
/// Sets the `GtkStack` to be horizontally homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// width for all its children. If it isn't, the stack
|
|
/// may change width when a different child becomes visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter hhomogeneous: `true` if the stack allocates the same width for all children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hhomogeneous(_ hhomogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHhomogeneous(hhomogeneous: hhomogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Stack.setHhomogeneous(hhomogeneous:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getHhomogeneous()
|
|
/// Sets the `GtkStack` to be horizontally homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// width for all its children. If it isn't, the stack
|
|
/// may change width 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 hhomogeneous(_ hhomogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, hhomogeneous, registry: ctx.registry, notifyDetail: "hhomogeneous",
|
|
read: { [w] in w.getHhomogeneous() },
|
|
write: { [w] v in w.setHhomogeneous(hhomogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Stack.setHhomogeneous(hhomogeneous:)
|
|
/// Sets the `GtkStack` to be horizontally homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// width for all its children. If it isn't, the stack
|
|
/// may change width 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 `Gtk.Stack.setHhomogeneous(hhomogeneous:)`.
|
|
///
|
|
/// - Parameter hhomogeneous: `true` if the stack allocates the same width for all children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hhomogeneous(_ hhomogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHhomogeneous(hhomogeneous: hhomogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Stack.setInterpolateSize(interpolateSize:)
|
|
/// Sets whether or not `stack` will interpolate its size when
|
|
/// changing the visible child.
|
|
///
|
|
/// If the [property`Gtk`.Stack:interpolate-size] property is set
|
|
/// to `true`, `stack` will interpolate its size between the current
|
|
/// one and the one it'll take after changing the visible child,
|
|
/// according to the set transition duration.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter interpolateSize: Whether or not the size should smoothly change during the transition.
|
|
/// - 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: Gtk.Stack.setInterpolateSize(interpolateSize:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getInterpolateSize()
|
|
/// Sets whether or not `stack` will interpolate its size when
|
|
/// changing the visible child.
|
|
///
|
|
/// If the [property`Gtk`.Stack:interpolate-size] property is set
|
|
/// to `true`, `stack` will interpolate its size between the current
|
|
/// one and the one it'll take after changing the visible child,
|
|
/// according to the set transition duration.
|
|
///
|
|
/// 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: Gtk.Stack.setInterpolateSize(interpolateSize:)
|
|
/// Sets whether or not `stack` will interpolate its size when
|
|
/// changing the visible child.
|
|
///
|
|
/// If the [property`Gtk`.Stack:interpolate-size] property is set
|
|
/// to `true`, `stack` will interpolate its size between the current
|
|
/// one and the one it'll take after changing the visible child,
|
|
/// according to the set transition duration.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Stack.setInterpolateSize(interpolateSize:)`.
|
|
///
|
|
/// - Parameter interpolateSize: Whether or not the size should smoothly change during the transition.
|
|
/// - 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: Gtk.Stack.setTransitionDuration(duration:)
|
|
/// Sets the duration that transitions between pages in `stack`
|
|
/// will take.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter transitionDuration: The 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: Gtk.Stack.setTransitionDuration(duration:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getTransitionDuration()
|
|
/// Sets the duration that transitions between pages in `stack`
|
|
/// will take.
|
|
///
|
|
/// 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: Gtk.Stack.setTransitionDuration(duration:)
|
|
/// Sets the duration that transitions between pages in `stack`
|
|
/// will take.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Stack.setTransitionDuration(duration:)`.
|
|
///
|
|
/// - Parameter transitionDuration: The 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: Gtk.Stack.setTransitionType(transition:)
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions between pages in `stack`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// The transition type can be changed without problems
|
|
/// at runtime, so it is possible to change the animation
|
|
/// based on the page that is about to become current.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter transitionType: The type of animation used to transition.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionType(_ transitionType: Gtk.StackTransitionType) -> Self {
|
|
appending { w, _ in
|
|
w.setTransitionType(transition: transitionType)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Stack.setTransitionType(transition:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getTransitionType()
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions between pages in `stack`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// The transition type can be changed without problems
|
|
/// at runtime, so it is possible to change the animation
|
|
/// based on the page that is about to become current.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.StackTransitionType` 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<Gtk.StackTransitionType>) -> 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: Gtk.Stack.setTransitionType(transition:)
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions between pages in `stack`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// The transition type can be changed without problems
|
|
/// at runtime, so it is possible to change the animation
|
|
/// based on the page that is about to become current.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Stack.setTransitionType(transition:)`.
|
|
///
|
|
/// - Parameter transitionType: The type of animation used to transition.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionType(_ transitionType: @escaping () -> Gtk.StackTransitionType) -> 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: Gtk.Stack.setVhomogeneous(vhomogeneous:)
|
|
/// Sets the `GtkStack` to be vertically homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// height for all its children. If it isn't, the stack
|
|
/// may change height when a different child becomes visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter vhomogeneous: `true` if the stack allocates the same height for all children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func vhomogeneous(_ vhomogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setVhomogeneous(vhomogeneous: vhomogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Stack.setVhomogeneous(vhomogeneous:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getVhomogeneous()
|
|
/// Sets the `GtkStack` to be vertically homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// height for all its children. If it isn't, the stack
|
|
/// may change height 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 vhomogeneous(_ vhomogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, vhomogeneous, registry: ctx.registry, notifyDetail: "vhomogeneous",
|
|
read: { [w] in w.getVhomogeneous() },
|
|
write: { [w] v in w.setVhomogeneous(vhomogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Stack.setVhomogeneous(vhomogeneous:)
|
|
/// Sets the `GtkStack` to be vertically homogeneous or not.
|
|
///
|
|
/// If it is homogeneous, the `GtkStack` will request the same
|
|
/// height for all its children. If it isn't, the stack
|
|
/// may change height 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 `Gtk.Stack.setVhomogeneous(vhomogeneous:)`.
|
|
///
|
|
/// - Parameter vhomogeneous: `true` if the stack allocates the same height for all children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func vhomogeneous(_ vhomogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVhomogeneous(vhomogeneous: vhomogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Stack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `stack`.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the `child` widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: Gtk.Widget) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChild(child: visibleChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Stack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `stack`.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the `child` widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// 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 visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(@ViewBuilder _ visibleChild: () -> [AnyView]) -> Self {
|
|
let visibleChildViews = visibleChild()
|
|
return appending { w, ctx in
|
|
guard let v = visibleChildViews.first else { return }
|
|
w.setVisibleChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Stack.setVisibleChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getVisibleChild()
|
|
/// Makes `child` the visible child of `stack`.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the `child` widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// 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 visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChild, registry: ctx.registry, notifyDetail: "visible-child",
|
|
read: { [w] in w.getVisibleChild() as? W },
|
|
write: { [w] v in w.setVisibleChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Gtk.Stack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `stack`.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the `child` widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding (what a `WidgetRef` projects) and ignores `nil` values. Binds one way only.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
if let v = visibleChild.untrackedValue { w.setVisibleChild(child: v) }
|
|
ctx.registry.add(visibleChild.subscribe { [w] v in if let v { w.setVisibleChild(child: v) } })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Stack.setVisibleChild(child:)
|
|
/// Makes `child` the visible child of `stack`.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the `child` widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Stack.setVisibleChild(child:)`.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: @escaping () -> Gtk.Widget) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChild(child: visibleChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Stack.setVisibleChildName(name:)
|
|
/// Makes the child with the given name visible.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the child widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func visibleChildName<S: StringProtocol>(_ visibleChildName: S) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChildName(name: String(visibleChildName))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Stack.setVisibleChildName(name:), GObject.Object.connectNotify(detail:_:), Gtk.Stack.getVisibleChildName()
|
|
/// Makes the child with the given name visible.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the child widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String` 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 visibleChildName(_ visibleChildName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChildName, registry: ctx.registry, notifyDetail: "visible-child-name",
|
|
read: { [w] in w.getVisibleChildName() },
|
|
write: { [w] v in w.setVisibleChildName(name: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Stack.setVisibleChildName(name:)
|
|
/// Makes the child with the given name visible.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the child widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Stack.setVisibleChildName(name:)`.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChildName(name: visibleChildName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.Stack.setVisibleChildName(name:)
|
|
/// Makes the child with the given name visible.
|
|
///
|
|
/// If `child` is different from the currently visible child,
|
|
/// the transition between the two will be animated with the
|
|
/// current transition type of `stack`.
|
|
///
|
|
/// Note that the child widget has to be visible itself
|
|
/// (see [method`Gtk`.Widget.show]) in order to become the visible
|
|
/// child of `stack`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Stack.setVisibleChildName(name:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible in the stack.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(visibleChildName, registry: ctx.registry) { [w] v in w.setVisibleChildName(name: v) }
|
|
}
|
|
}
|
|
|
|
}
|