portico/Sources/Portico/Core/WidgetView.swift

19 lines
961 B
Swift

import Gtk
/// A ``View`` that mounts one concrete GTK widget class and can accumulate
/// configuration steps applied to that widget at mount time.
///
/// Generated widget structs conform. Every generated modifier is declared in a
/// ``WidgetView`` extension constrained on ``Target``, so a view automatically
/// receives the modifiers of its own widget class, of every ancestor class,
/// and of every GTK interface that class implements Swift's own conformance
/// lookup supplies the lineage, so nothing is duplicated per widget.
public protocol WidgetView: View {
/// The concrete GTK widget class this view mounts.
associatedtype Target: Gtk.Widget
/// Returns a copy of this view with `step` appended to its configuration
/// pipeline. Steps run once, at mount, in the order they were added,
/// after the widget has been created.
@_spi(Portico) func appending(_ step: @escaping (Target, MountContext) -> Void) -> Self
}