portico/Sources/Portico/Generated/CarouselIndicatorLines.swift

138 lines
6.6 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: Adw.CarouselIndicatorLines
/// A lines indicator for [class`Carousel`].
///
/// <picture>
/// <source srcset="carousel-indicator-lines-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="carousel-indicator-lines.png" alt="carousel-indicator-lines">
/// </picture>
///
/// The `AdwCarouselIndicatorLines` widget shows a set of lines for each page of
/// a given [class`Carousel`]. The carousel's active page is shown as another line
/// that moves between them to match the carousel's position.
///
/// See also [class`CarouselIndicatorDots`].
///
/// ## CSS nodes
///
/// `AdwCarouselIndicatorLines` has a single CSS node with name
/// `carouselindicatorlines`.
///
/// A Portico view that mounts a `Adw.CarouselIndicatorLines`.
@MainActor public struct CarouselIndicatorLines: View {
private let make: (MountContext) -> Adw.CarouselIndicatorLines
private var configure: [(Adw.CarouselIndicatorLines, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.CarouselIndicatorLines.init()
/// Creates a new `AdwCarouselIndicatorLines`.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter carousel: The displayed carousel.
public init(carousel: Adw.Carousel? = nil) {
make = { _ in Adw.CarouselIndicatorLines() }
configure.append { w, _ in
if let carousel { w.setCarousel(carousel: carousel) }
}
}
}
extension CarouselIndicatorLines: WidgetView {
public typealias Target = Adw.CarouselIndicatorLines
@_spi(Portico) public func appending(
_ step: @escaping (Adw.CarouselIndicatorLines, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension CarouselIndicatorLines: 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.CarouselIndicatorLines
/// Modifiers for `Adw.CarouselIndicatorLines`, available on every Portico view whose
/// backing widget is `Adw.CarouselIndicatorLines` or one of its subclasses.
extension WidgetView where Target: Adw.CarouselIndicatorLines {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.CarouselIndicatorLines.setCarousel(carousel:)
/// Sets the displayed carousel.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter carousel: The displayed carousel.
/// - Returns: A copy of this view with the modifier applied.
public func carousel(_ carousel: Adw.Carousel?) -> Self {
appending { w, _ in
w.setCarousel(carousel: carousel)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.CarouselIndicatorLines.setCarousel(carousel:), GObject.Object.connectNotify(detail:_:), Adw.CarouselIndicatorLines.getCarousel()
/// Sets the displayed carousel.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Carousel?` 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 carousel<W: Adw.Carousel>(_ carousel: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, carousel, registry: ctx.registry, notifyDetail: "carousel",
read: { [w] in w.getCarousel() as? W },
write: { [w] v in w.setCarousel(carousel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.CarouselIndicatorLines.setCarousel(carousel:), GObject.Object.connectNotify(detail:_:), Adw.CarouselIndicatorLines.getCarousel()
/// Sets the displayed carousel.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Carousel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Carousel?>` to be able to clear the property.
/// When `Adw.Carousel` 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 carousel<W: Adw.Carousel>(_ carousel: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, carousel, registry: ctx.registry, notifyDetail: "carousel",
read: { [w] in w.getCarousel() as? W },
write: { [w] v in w.setCarousel(carousel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.CarouselIndicatorLines.setCarousel(carousel:)
/// Sets the displayed carousel.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.CarouselIndicatorLines.setCarousel(carousel:)`.
///
/// - Parameter carousel: The displayed carousel.
/// - Returns: A copy of this view with the modifier applied.
public func carousel(_ carousel: @escaping () -> Adw.Carousel?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCarousel(carousel: carousel()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}