portico/Sources/Portico/Generated/CarouselIndicatorDots.swift

139 lines
6.7 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.CarouselIndicatorDots
/// A dots indicator for [class`Carousel`].
///
/// <picture>
/// <source srcset="carousel-indicator-dots-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="carousel-indicator-dots.png" alt="carousel-indicator-dots">
/// </picture>
///
/// The `AdwCarouselIndicatorDots` widget shows a set of dots for each page of a
/// given [class`Carousel`]. The dot representing the carousel's active page is
/// larger and more opaque than the others, the transition to the active and
/// inactive state is gradual to match the carousel's position.
///
/// See also [class`CarouselIndicatorLines`].
///
/// ## CSS nodes
///
/// `AdwCarouselIndicatorDots` has a single CSS node with name
/// `carouselindicatordots`.
///
/// A Portico view that mounts a `Adw.CarouselIndicatorDots`.
@MainActor public struct CarouselIndicatorDots: View {
private let make: (MountContext) -> Adw.CarouselIndicatorDots
private var configure: [(Adw.CarouselIndicatorDots, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.CarouselIndicatorDots.init()
/// Creates a new `AdwCarouselIndicatorDots`.
///
/// 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.CarouselIndicatorDots() }
configure.append { w, _ in
if let carousel { w.setCarousel(carousel: carousel) }
}
}
}
extension CarouselIndicatorDots: WidgetView {
public typealias Target = Adw.CarouselIndicatorDots
@_spi(Portico) public func appending(
_ step: @escaping (Adw.CarouselIndicatorDots, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension CarouselIndicatorDots: 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.CarouselIndicatorDots
/// Modifiers for `Adw.CarouselIndicatorDots`, available on every Portico view whose
/// backing widget is `Adw.CarouselIndicatorDots` or one of its subclasses.
extension WidgetView where Target: Adw.CarouselIndicatorDots {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.CarouselIndicatorDots.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.CarouselIndicatorDots.setCarousel(carousel:), GObject.Object.connectNotify(detail:_:), Adw.CarouselIndicatorDots.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.CarouselIndicatorDots.setCarousel(carousel:), GObject.Object.connectNotify(detail:_:), Adw.CarouselIndicatorDots.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.CarouselIndicatorDots.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.CarouselIndicatorDots.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)
}
}
}