portico/Sources/Portico/Generated/ActionBar.swift

155 lines
6.4 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.ActionBar
/// Presents contextual actions.
///
/// <picture>
/// <source srcset="action-bar-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkActionBar" src="action-bar.png">
/// </picture>
///
/// `GtkActionBar` is expected to be displayed below the content and expand
/// horizontally to fill the area.
///
/// It allows placing children at the start or the end. In addition, it
/// contains an internal centered box which is centered with respect to
/// the full width of the box, even if the children at either side take
/// up different amounts of space.
///
/// # GtkActionBar as GtkBuildable
///
/// The `GtkActionBar` implementation of the `GtkBuildable` interface supports
/// adding children at the start or end sides by specifying start or end as
/// the type attribute of a `<child>` element, or setting the center widget
/// by specifying center value.
///
/// # CSS nodes
///
/// ```
/// actionbar
/// revealer
/// box
/// box.start
/// [start children]
/// [center widget]
/// box.end
/// [end children]
/// ```
///
/// A `GtkActionBar`'s CSS node is called `actionbar`. It contains a `revealer`
/// subnode, which contains a `box` subnode, which contains two `box` subnodes at
/// the start and end of the action bar, with `start` and `end` style classes
/// respectively, as well as a center node that represents the center child.
///
/// Each of the boxes contains children packed for that side.
///
/// A Portico view that mounts a `Gtk.ActionBar`.
@MainActor public struct ActionBar: View {
private let make: (MountContext) -> Gtk.ActionBar
private var configure: [(Gtk.ActionBar, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.ActionBar.init()
/// Creates a new action bar widget.
///
/// 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 revealed: Controls whether the action bar shows its contents.
public init(revealed: Bool? = nil) {
make = { _ in Gtk.ActionBar() }
configure.append { w, _ in
if let revealed { w.setRevealed(revealed: revealed) }
}
}
}
extension ActionBar: WidgetView {
public typealias Target = Gtk.ActionBar
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.ActionBar, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension ActionBar: 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.ActionBar
/// Modifiers for `Gtk.ActionBar`, available on every Portico view whose
/// backing widget is `Gtk.ActionBar` or one of its subclasses.
extension WidgetView where Target: Gtk.ActionBar {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ActionBar.setRevealed(revealed:)
/// Reveals or conceals the content of the action bar.
///
/// Note: this does not show or hide the action bar in the
/// [property`Gtk`.Widget:visible] sense, so revealing has
/// no effect if the action bar is hidden.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter revealed: Controls whether the action bar shows its contents.
/// - Returns: A copy of this view with the modifier applied.
public func revealed(_ revealed: Bool) -> Self {
appending { w, _ in
w.setRevealed(revealed: revealed)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ActionBar.setRevealed(revealed:), GObject.Object.connectNotify(detail:_:), Gtk.ActionBar.getRevealed()
/// Reveals or conceals the content of the action bar.
///
/// Note: this does not show or hide the action bar in the
/// [property`Gtk`.Widget:visible] sense, so revealing has
/// no effect if the action bar is hidden.
///
/// 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 revealed(_ revealed: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, revealed, registry: ctx.registry, notifyDetail: "revealed",
read: { [w] in w.getRevealed() },
write: { [w] v in w.setRevealed(revealed: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ActionBar.setRevealed(revealed:)
/// Reveals or conceals the content of the action bar.
///
/// Note: this does not show or hide the action bar in the
/// [property`Gtk`.Widget:visible] sense, so revealing has
/// no effect if the action bar is hidden.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ActionBar.setRevealed(revealed:)`.
///
/// - Parameter revealed: Controls whether the action bar shows its contents.
/// - Returns: A copy of this view with the modifier applied.
public func revealed(_ revealed: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setRevealed(revealed: revealed()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}