318 lines
17 KiB
Swift
318 lines
17 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.Revealer
|
|
/// Animates the transition of its child from invisible to visible.
|
|
///
|
|
/// The style of transition can be controlled with
|
|
/// [method`Gtk`.Revealer.set_transition_type].
|
|
///
|
|
/// These animations respect the [property`Gtk`.Settings:gtk-enable-animations]
|
|
/// setting.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkRevealer` has a single CSS node with name revealer.
|
|
/// When styling `GtkRevealer` using CSS, remember that it only hides its contents,
|
|
/// not itself. That means applied margin, padding and borders will be visible even
|
|
/// when the [property`Gtk`.Revealer:reveal-child] property is set to `false`.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkRevealer` uses the [enum`Gtk`.AccessibleRole.group] role.
|
|
///
|
|
/// The child of `GtkRevealer`, if set, is always available in the accessibility
|
|
/// tree, regardless of the state of the revealer widget.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Revealer`.
|
|
@MainActor public struct Revealer: View {
|
|
private let make: (MountContext) -> Gtk.Revealer
|
|
private var configure: [(Gtk.Revealer, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Revealer.init()
|
|
/// Creates a new `GtkRevealer`.
|
|
///
|
|
/// 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 revealChild: Whether the revealer should reveal the child.
|
|
/// - Parameter transitionDuration: The animation duration, in milliseconds.
|
|
/// - Parameter transitionType: The type of animation used to transition.
|
|
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
|
public init(revealChild: Bool? = nil, transitionDuration: UInt32? = nil, transitionType: Gtk.RevealerTransitionType? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Gtk.Revealer() }
|
|
configure.append { w, ctx in
|
|
if let revealChild { w.setRevealChild(revealChild: revealChild) }
|
|
if let transitionDuration { w.setTransitionDuration(duration: transitionDuration) }
|
|
if let transitionType { w.setTransitionType(transition: transitionType) }
|
|
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Revealer: WidgetView {
|
|
public typealias Target = Gtk.Revealer
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Revealer, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Revealer: 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.Revealer
|
|
/// Modifiers for `Gtk.Revealer`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Revealer` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Revealer {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Revealer.setChild(child:)
|
|
/// Sets the child widget of `revealer`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: Gtk.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setChild(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Revealer.setChild(child:)
|
|
/// Sets the child widget of `revealer`.
|
|
///
|
|
/// 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 child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
guard let v = childViews.first else { return }
|
|
w.setChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Revealer.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Revealer.getChild()
|
|
/// Sets the child widget of `revealer`.
|
|
///
|
|
/// 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Revealer.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Revealer.getChild()
|
|
/// Sets the child widget of `revealer`.
|
|
///
|
|
/// 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Revealer.setChild(child:)
|
|
/// Sets the child widget of `revealer`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Revealer.setChild(child:)`.
|
|
///
|
|
/// - Parameter child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: @escaping () -> Gtk.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setChild(child: child()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Revealer.setRevealChild(revealChild:)
|
|
/// Tells the `GtkRevealer` to reveal or conceal its child.
|
|
///
|
|
/// The transition will be animated with the current
|
|
/// transition type of `revealer`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter revealChild: Whether the revealer should reveal the child.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func revealChild(_ revealChild: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setRevealChild(revealChild: revealChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Revealer.setRevealChild(revealChild:), GObject.Object.connectNotify(detail:_:), Gtk.Revealer.getRevealChild()
|
|
/// Tells the `GtkRevealer` to reveal or conceal its child.
|
|
///
|
|
/// The transition will be animated with the current
|
|
/// transition type of `revealer`.
|
|
///
|
|
/// 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 revealChild(_ revealChild: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, revealChild, registry: ctx.registry, notifyDetail: "reveal-child",
|
|
read: { [w] in w.getRevealChild() },
|
|
write: { [w] v in w.setRevealChild(revealChild: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Revealer.setRevealChild(revealChild:)
|
|
/// Tells the `GtkRevealer` to reveal or conceal its child.
|
|
///
|
|
/// The transition will be animated with the current
|
|
/// transition type of `revealer`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Revealer.setRevealChild(revealChild:)`.
|
|
///
|
|
/// - Parameter revealChild: Whether the revealer should reveal the child.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func revealChild(_ revealChild: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setRevealChild(revealChild: revealChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Revealer.setTransitionDuration(duration:)
|
|
/// Sets the duration that transitions 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.Revealer.setTransitionDuration(duration:), GObject.Object.connectNotify(detail:_:), Gtk.Revealer.getTransitionDuration()
|
|
/// Sets the duration that transitions 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.Revealer.setTransitionDuration(duration:)
|
|
/// Sets the duration that transitions will take.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Revealer.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.Revealer.setTransitionType(transition:)
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions in `revealer`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// 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.RevealerTransitionType) -> Self {
|
|
appending { w, _ in
|
|
w.setTransitionType(transition: transitionType)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Revealer.setTransitionType(transition:), GObject.Object.connectNotify(detail:_:), Gtk.Revealer.getTransitionType()
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions in `revealer`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.RevealerTransitionType` 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.RevealerTransitionType>) -> 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.Revealer.setTransitionType(transition:)
|
|
/// Sets the type of animation that will be used for
|
|
/// transitions in `revealer`.
|
|
///
|
|
/// Available types include various kinds of fades and slides.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Revealer.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.RevealerTransitionType) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTransitionType(transition: transitionType()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
}
|