portico/Sources/Portico/Generated/Scrollbar.swift

94 lines
3.5 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.Scrollbar
/// Shows a horizontal or vertical scrollbar.
///
/// <picture>
/// <source srcset="scrollbar-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkScrollbar" src="scrollbar.png">
/// </picture>
///
/// Its position and movement are controlled by the adjustment that is passed to
/// or created by [ctor`Gtk`.Scrollbar.new]. See [class`Gtk`.Adjustment] for more
/// details. The [property`Gtk`.Adjustment:value] field sets the position of the
/// thumb and must be between [property`Gtk`.Adjustment:lower] and
/// [property`Gtk`.Adjustment:upper] - [property`Gtk`.Adjustment:page-size].
/// The [property`Gtk`.Adjustment:page-size] represents the size of the visible
/// scrollable area.
///
/// The fields [property`Gtk`.Adjustment:step-increment] and
/// [property`Gtk`.Adjustment:page-increment] fields are added to or subtracted
/// from the [property`Gtk`.Adjustment:value] when the user asks to move by a step
/// (using e.g. the cursor arrow keys) or by a page (using e.g. the Page Down/Up
/// keys).
///
/// # CSS nodes
///
/// ```
/// scrollbar
/// range[.fine-tune]
/// trough
/// slider
/// ```
///
/// `GtkScrollbar` has a main CSS node with name scrollbar and a subnode for its
/// contents. The main node gets the .horizontal or .vertical style classes applied,
/// depending on the scrollbar's orientation.
///
/// The range node gets the style class .fine-tune added when the scrollbar is
/// in 'fine-tuning' mode.
///
/// Other style classes that may be added to scrollbars inside
/// [class`Gtk`.ScrolledWindow] include the positional classes (.left, .right,
/// .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator,
/// .dragging, .hovering).
///
/// # Accessibility
///
/// `GtkScrollbar` uses the [enum`Gtk`.AccessibleRole.scrollbar] role.
///
/// A Portico view that mounts a `Gtk.Scrollbar`.
@MainActor public struct Scrollbar: View {
private let make: (MountContext) -> Gtk.Scrollbar
private var configure: [(Gtk.Scrollbar, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Scrollbar.init(orientation:adjustment:)
/// Creates a new scrollbar with the given orientation.
///
/// 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 orientation: The `orientation` value forwarded to `Gtk.Scrollbar`.
/// - Parameter adjustment: The `GtkAdjustment` controlled by this scrollbar.
public init(orientation: Gtk.Orientation, adjustment: Gtk.Adjustment?) {
make = { _ in Gtk.Scrollbar(orientation: orientation, adjustment: adjustment) }
}
}
extension Scrollbar: WidgetView {
public typealias Target = Gtk.Scrollbar
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Scrollbar, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Scrollbar: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}