818 lines
45 KiB
Swift
818 lines
45 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.Leaflet
|
|
/// An adaptive container acting like a box or a stack.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="leaflet-wide-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="leaflet-wide.png" alt="leaflet-wide">
|
|
/// </picture>
|
|
/// <picture>
|
|
/// <source srcset="leaflet-narrow-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="leaflet-narrow.png" alt="leaflet-narrow">
|
|
/// </picture>
|
|
///
|
|
/// The `AdwLeaflet` widget can display its children like a [class`Gtk`.Box] does
|
|
/// or like a [class`Gtk`.Stack] does, adapting to size changes by switching
|
|
/// between the two modes.
|
|
///
|
|
/// When there is enough space the children are displayed side by side, otherwise
|
|
/// only one is displayed and the leaflet is said to be “folded”.
|
|
/// The threshold is dictated by the preferred minimum sizes of the children.
|
|
/// When a leaflet is folded, the children can be navigated using swipe gestures.
|
|
///
|
|
/// The “over” and “under” transition types stack the children one on top of the
|
|
/// other, while the “slide” transition puts the children side by side. While
|
|
/// navigating to a child on the side or below can be performed by swiping the
|
|
/// current child away, navigating to an upper child requires dragging it from
|
|
/// the edge where it resides. This doesn't affect non-dragging swipes.
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `AdwLeaflet` has a single CSS node with name `leaflet`. The node will get the
|
|
/// style classes `.folded` when it is folded, `.unfolded` when it's not, or none
|
|
/// if it hasn't computed its fold yet.
|
|
///
|
|
/// A Portico view that mounts a `Adw.Leaflet`.
|
|
@MainActor public struct Leaflet: View {
|
|
private let make: (MountContext) -> Adw.Leaflet
|
|
private var configure: [(Adw.Leaflet, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.Leaflet.init()
|
|
/// Creates a new `AdwLeaflet`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
|
/// An empty closure adds no children and leaves slots unset.
|
|
/// A `ForEach` in the `children:` closure spreads its rows directly into this widget, with no wrapper, when the widget supports ordered insertion.
|
|
/// 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 canNavigateBack: Whether gestures and shortcuts for navigating backward are enabled.
|
|
/// - Parameter canNavigateForward: Whether gestures and shortcuts for navigating forward are enabled.
|
|
/// - Parameter canUnfold: Whether or not the leaflet can unfold.
|
|
/// - Parameter childTransitionParams: The child transition spring parameters.
|
|
/// - Parameter foldThresholdPolicy: Determines when the leaflet will fold.
|
|
/// - Parameter homogeneous: Whether the leaflet allocates the same size for all children when folded.
|
|
/// - Parameter modeTransitionDuration: The mode transition animation duration, in milliseconds.
|
|
/// - Parameter transitionType: The type of animation used for transitions between modes and children.
|
|
/// - Parameter visibleChildName: The name of the widget currently visible when the leaflet is folded.
|
|
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
|
|
public init(canNavigateBack: Bool? = nil, canNavigateForward: Bool? = nil, canUnfold: Bool? = nil, childTransitionParams: Adw.SpringParams? = nil, foldThresholdPolicy: Adw.FoldThresholdPolicy? = nil, homogeneous: Bool? = nil, modeTransitionDuration: UInt32? = nil, transitionType: Adw.LeafletTransitionType? = nil, visibleChildName: String? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }) {
|
|
make = { _ in Adw.Leaflet() }
|
|
configure.append { w, ctx in
|
|
if let canNavigateBack { w.setCanNavigateBack(canNavigateBack: canNavigateBack) }
|
|
if let canNavigateForward { w.setCanNavigateForward(canNavigateForward: canNavigateForward) }
|
|
if let canUnfold { w.setCanUnfold(canUnfold: canUnfold) }
|
|
if let childTransitionParams { w.setChildTransitionParams(params: childTransitionParams) }
|
|
if let foldThresholdPolicy { w.setFoldThresholdPolicy(policy: foldThresholdPolicy) }
|
|
if let homogeneous { w.setHomogeneous(homogeneous: homogeneous) }
|
|
if let modeTransitionDuration { w.setModeTransitionDuration(duration: modeTransitionDuration) }
|
|
if let transitionType { w.setTransitionType(transition: transitionType) }
|
|
if let visibleChildName { w.setVisibleChildName(name: visibleChildName) }
|
|
Portico.mountChildren(children, into: w, ctx) { c in _ = w.append(child: c) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Leaflet: WidgetView {
|
|
public typealias Target = Adw.Leaflet
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.Leaflet, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Leaflet: 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.Leaflet
|
|
/// Modifiers for `Adw.Leaflet`, available on every Portico view whose
|
|
/// backing widget is `Adw.Leaflet` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.Leaflet {
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.Leaflet.append(child:)
|
|
/// Adds a child to `self`.
|
|
///
|
|
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
|
|
///
|
|
/// - Parameter child: A child widget to add.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func append(_ child: Gtk.Widget) -> Self {
|
|
appending { w, _ in
|
|
_ = w.append(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.Leaflet.append(child:)
|
|
/// Adds a child to `self`.
|
|
///
|
|
/// Every view the closure produces is added at mount, in order.
|
|
///
|
|
/// - Parameter child: A closure producing child views.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func append(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
for v in childViews { _ = w.append(child: v.makeWidget(ctx)) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setCanNavigateBack(canNavigateBack:)
|
|
/// Sets whether gestures and shortcuts for navigating backward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↑</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canNavigateBack: Whether gestures and shortcuts for navigating backward are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateBack(_ canNavigateBack: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanNavigateBack(canNavigateBack: canNavigateBack)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setCanNavigateBack(canNavigateBack:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getCanNavigateBack()
|
|
/// Sets whether gestures and shortcuts for navigating backward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↑</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// 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 canNavigateBack(_ canNavigateBack: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canNavigateBack, registry: ctx.registry, notifyDetail: "can-navigate-back",
|
|
read: { [w] in w.getCanNavigateBack() },
|
|
write: { [w] v in w.setCanNavigateBack(canNavigateBack: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setCanNavigateBack(canNavigateBack:)
|
|
/// Sets whether gestures and shortcuts for navigating backward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↑</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setCanNavigateBack(canNavigateBack:)`.
|
|
///
|
|
/// - Parameter canNavigateBack: Whether gestures and shortcuts for navigating backward are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateBack(_ canNavigateBack: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanNavigateBack(canNavigateBack: canNavigateBack()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setCanNavigateForward(canNavigateForward:)
|
|
/// Sets whether gestures and shortcuts for navigating forward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>→</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↓</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canNavigateForward: Whether gestures and shortcuts for navigating forward are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateForward(_ canNavigateForward: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanNavigateForward(canNavigateForward: canNavigateForward)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setCanNavigateForward(canNavigateForward:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getCanNavigateForward()
|
|
/// Sets whether gestures and shortcuts for navigating forward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>→</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↓</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// 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 canNavigateForward(_ canNavigateForward: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canNavigateForward, registry: ctx.registry, notifyDetail: "can-navigate-forward",
|
|
read: { [w] in w.getCanNavigateForward() },
|
|
write: { [w] v in w.setCanNavigateForward(canNavigateForward: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setCanNavigateForward(canNavigateForward:)
|
|
/// Sets whether gestures and shortcuts for navigating forward are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back/forward mouse buttons
|
|
///
|
|
/// The keyboard back/forward keys are also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>→</kbd> shortcut for horizontal orientation, or
|
|
/// <kbd>Alt</kbd>+<kbd>↓</kbd> for vertical orientation.
|
|
///
|
|
/// If the orientation is horizontal, for right-to-left locales, gestures and
|
|
/// shortcuts are reversed.
|
|
///
|
|
/// Only children that have [property`LeafletPage`:navigatable] set to `TRUE` can
|
|
/// be navigated to.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setCanNavigateForward(canNavigateForward:)`.
|
|
///
|
|
/// - Parameter canNavigateForward: Whether gestures and shortcuts for navigating forward are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateForward(_ canNavigateForward: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanNavigateForward(canNavigateForward: canNavigateForward()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setCanUnfold(canUnfold:)
|
|
/// Sets whether `self` can unfold.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canUnfold: Whether or not the leaflet can unfold.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canUnfold(_ canUnfold: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanUnfold(canUnfold: canUnfold)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setCanUnfold(canUnfold:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getCanUnfold()
|
|
/// Sets whether `self` can unfold.
|
|
///
|
|
/// 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 canUnfold(_ canUnfold: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canUnfold, registry: ctx.registry, notifyDetail: "can-unfold",
|
|
read: { [w] in w.getCanUnfold() },
|
|
write: { [w] v in w.setCanUnfold(canUnfold: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setCanUnfold(canUnfold:)
|
|
/// Sets whether `self` can unfold.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setCanUnfold(canUnfold:)`.
|
|
///
|
|
/// - Parameter canUnfold: Whether or not the leaflet can unfold.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canUnfold(_ canUnfold: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanUnfold(canUnfold: canUnfold()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setChildTransitionParams(params:)
|
|
/// Sets the child transition spring parameters for `self`.
|
|
///
|
|
/// The default value is equivalent to:
|
|
///
|
|
/// ```c
|
|
/// adw_spring_params_new (1, 0.5, 500)
|
|
/// ```
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter childTransitionParams: The child transition spring parameters.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func childTransitionParams(_ childTransitionParams: Adw.SpringParams) -> Self {
|
|
appending { w, _ in
|
|
w.setChildTransitionParams(params: childTransitionParams)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setChildTransitionParams(params:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getChildTransitionParams()
|
|
/// Sets the child transition spring parameters for `self`.
|
|
///
|
|
/// The default value is equivalent to:
|
|
///
|
|
/// ```c
|
|
/// adw_spring_params_new (1, 0.5, 500)
|
|
/// ```
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.SpringParams` 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 childTransitionParams(_ childTransitionParams: Portico.Binding<Adw.SpringParams>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, childTransitionParams, registry: ctx.registry, notifyDetail: "child-transition-params",
|
|
read: { [w] in w.getChildTransitionParams() },
|
|
write: { [w] v in w.setChildTransitionParams(params: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setChildTransitionParams(params:)
|
|
/// Sets the child transition spring parameters for `self`.
|
|
///
|
|
/// The default value is equivalent to:
|
|
///
|
|
/// ```c
|
|
/// adw_spring_params_new (1, 0.5, 500)
|
|
/// ```
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setChildTransitionParams(params:)`.
|
|
///
|
|
/// - Parameter childTransitionParams: The child transition spring parameters.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func childTransitionParams(_ childTransitionParams: @escaping () -> Adw.SpringParams) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setChildTransitionParams(params: childTransitionParams()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setFoldThresholdPolicy(policy:)
|
|
/// Sets the fold threshold policy for `self`.
|
|
///
|
|
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only fold when the
|
|
/// children cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural], it
|
|
/// will fold as soon as children don't get their natural size.
|
|
///
|
|
/// This can be useful if you have a long ellipsizing label and want to let it
|
|
/// ellipsize instead of immediately folding.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter foldThresholdPolicy: Determines when the leaflet will fold.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func foldThresholdPolicy(_ foldThresholdPolicy: Adw.FoldThresholdPolicy) -> Self {
|
|
appending { w, _ in
|
|
w.setFoldThresholdPolicy(policy: foldThresholdPolicy)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setFoldThresholdPolicy(policy:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getFoldThresholdPolicy()
|
|
/// Sets the fold threshold policy for `self`.
|
|
///
|
|
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only fold when the
|
|
/// children cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural], it
|
|
/// will fold as soon as children don't get their natural size.
|
|
///
|
|
/// This can be useful if you have a long ellipsizing label and want to let it
|
|
/// ellipsize instead of immediately folding.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.FoldThresholdPolicy` 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 foldThresholdPolicy(_ foldThresholdPolicy: Portico.Binding<Adw.FoldThresholdPolicy>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, foldThresholdPolicy, registry: ctx.registry, notifyDetail: "fold-threshold-policy",
|
|
read: { [w] in w.getFoldThresholdPolicy() },
|
|
write: { [w] v in w.setFoldThresholdPolicy(policy: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setFoldThresholdPolicy(policy:)
|
|
/// Sets the fold threshold policy for `self`.
|
|
///
|
|
/// If set to [enum`Adw`.FoldThresholdPolicy.minimum], it will only fold when the
|
|
/// children cannot fit anymore. With [enum`Adw`.FoldThresholdPolicy.natural], it
|
|
/// will fold as soon as children don't get their natural size.
|
|
///
|
|
/// This can be useful if you have a long ellipsizing label and want to let it
|
|
/// ellipsize instead of immediately folding.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setFoldThresholdPolicy(policy:)`.
|
|
///
|
|
/// - Parameter foldThresholdPolicy: Determines when the leaflet will fold.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func foldThresholdPolicy(_ foldThresholdPolicy: @escaping () -> Adw.FoldThresholdPolicy) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setFoldThresholdPolicy(policy: foldThresholdPolicy()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setHomogeneous(homogeneous:)
|
|
/// Sets `self` to be homogeneous or not.
|
|
///
|
|
/// If set to `FALSE`, different children can have different size along the
|
|
/// opposite orientation.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter homogeneous: Whether the leaflet allocates the same size for all children when folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func homogeneous(_ homogeneous: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHomogeneous(homogeneous: homogeneous)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setHomogeneous(homogeneous:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getHomogeneous()
|
|
/// Sets `self` to be homogeneous or not.
|
|
///
|
|
/// If set to `FALSE`, different children can have different size along the
|
|
/// opposite orientation.
|
|
///
|
|
/// 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 homogeneous(_ homogeneous: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, homogeneous, registry: ctx.registry, notifyDetail: "homogeneous",
|
|
read: { [w] in w.getHomogeneous() },
|
|
write: { [w] v in w.setHomogeneous(homogeneous: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setHomogeneous(homogeneous:)
|
|
/// Sets `self` to be homogeneous or not.
|
|
///
|
|
/// If set to `FALSE`, different children can have different size along the
|
|
/// opposite orientation.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setHomogeneous(homogeneous:)`.
|
|
///
|
|
/// - Parameter homogeneous: Whether the leaflet allocates the same size for all children when folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func homogeneous(_ homogeneous: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHomogeneous(homogeneous: homogeneous()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setModeTransitionDuration(duration:)
|
|
/// Sets the mode transition animation duration for `self`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter modeTransitionDuration: The mode transition animation duration, in milliseconds.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func modeTransitionDuration(_ modeTransitionDuration: UInt32) -> Self {
|
|
appending { w, _ in
|
|
w.setModeTransitionDuration(duration: modeTransitionDuration)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setModeTransitionDuration(duration:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getModeTransitionDuration()
|
|
/// Sets the mode transition animation duration for `self`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `UInt32` 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 modeTransitionDuration(_ modeTransitionDuration: Portico.Binding<UInt32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, modeTransitionDuration, registry: ctx.registry, notifyDetail: "mode-transition-duration",
|
|
read: { [w] in w.getModeTransitionDuration() },
|
|
write: { [w] v in w.setModeTransitionDuration(duration: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setModeTransitionDuration(duration:)
|
|
/// Sets the mode transition animation duration for `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setModeTransitionDuration(duration:)`.
|
|
///
|
|
/// - Parameter modeTransitionDuration: The mode transition animation duration, in milliseconds.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func modeTransitionDuration(_ modeTransitionDuration: @escaping () -> UInt32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setModeTransitionDuration(duration: modeTransitionDuration()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setTransitionType(transition:)
|
|
/// Sets the type of animation used for transitions between modes and children.
|
|
///
|
|
/// The transition type can be changed without problems at runtime, so it is
|
|
/// possible to change the animation based on the mode or child that is about to
|
|
/// become current.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter transitionType: The type of animation used for transitions between modes and children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionType(_ transitionType: Adw.LeafletTransitionType) -> Self {
|
|
appending { w, _ in
|
|
w.setTransitionType(transition: transitionType)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setTransitionType(transition:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getTransitionType()
|
|
/// Sets the type of animation used for transitions between modes and children.
|
|
///
|
|
/// The transition type can be changed without problems at runtime, so it is
|
|
/// possible to change the animation based on the mode or child that is about to
|
|
/// become current.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.LeafletTransitionType` 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 transitionType(_ transitionType: Portico.Binding<Adw.LeafletTransitionType>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, transitionType, registry: ctx.registry, notifyDetail: "transition-type",
|
|
read: { [w] in w.getTransitionType() },
|
|
write: { [w] v in w.setTransitionType(transition: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setTransitionType(transition:)
|
|
/// Sets the type of animation used for transitions between modes and children.
|
|
///
|
|
/// The transition type can be changed without problems at runtime, so it is
|
|
/// possible to change the animation based on the mode or child that is about to
|
|
/// become current.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setTransitionType(transition:)`.
|
|
///
|
|
/// - Parameter transitionType: The type of animation used for transitions between modes and children.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func transitionType(_ transitionType: @escaping () -> Adw.LeafletTransitionType) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTransitionType(transition: transitionType()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setVisibleChild(visibleChild:)
|
|
/// Sets the widget currently visible when the leaflet is folded.
|
|
///
|
|
/// The transition is determined by [property`Leaflet`:transition-type] and
|
|
/// [property`Leaflet`:child-transition-params]. The transition can be cancelled
|
|
/// by the user, in which case visible child will change back to the previously
|
|
/// visible child.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: Adw.Widget) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChild(visibleChild: visibleChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.Leaflet.setVisibleChild(visibleChild:)
|
|
/// Sets the widget currently visible when the leaflet is folded.
|
|
///
|
|
/// The transition is determined by [property`Leaflet`:transition-type] and
|
|
/// [property`Leaflet`:child-transition-params]. The transition can be cancelled
|
|
/// by the user, in which case visible child will change back to the previously
|
|
/// visible child.
|
|
///
|
|
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
|
/// Additional views are ignored; an empty closure leaves the slot unset.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(@ViewBuilder _ visibleChild: () -> [AnyView]) -> Self {
|
|
let visibleChildViews = visibleChild()
|
|
return appending { w, ctx in
|
|
guard let v = visibleChildViews.first else { return }
|
|
w.setVisibleChild(visibleChild: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setVisibleChild(visibleChild:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getVisibleChild()
|
|
/// Sets the widget currently visible when the leaflet is folded.
|
|
///
|
|
/// The transition is determined by [property`Leaflet`:transition-type] and
|
|
/// [property`Leaflet`:child-transition-params]. The transition can be cancelled
|
|
/// by the user, in which case visible child will change back to the previously
|
|
/// visible child.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.Widget` 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 visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChild, registry: ctx.registry, notifyDetail: "visible-child",
|
|
read: { [w] in w.getVisibleChild() as? W },
|
|
write: { [w] v in w.setVisibleChild(visibleChild: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Adw.Leaflet.setVisibleChild(visibleChild:)
|
|
/// Sets the widget currently visible when the leaflet is folded.
|
|
///
|
|
/// The transition is determined by [property`Leaflet`:transition-type] and
|
|
/// [property`Leaflet`:child-transition-params]. The transition can be cancelled
|
|
/// by the user, in which case visible child will change back to the previously
|
|
/// visible child.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding (what a `WidgetRef` projects) and ignores `nil` values. Binds one way only.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild<W: Gtk.Widget>(_ visibleChild: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
if let v = visibleChild.untrackedValue { w.setVisibleChild(visibleChild: v) }
|
|
ctx.registry.add(visibleChild.subscribe { [w] v in if let v { w.setVisibleChild(visibleChild: v) } })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setVisibleChild(visibleChild:)
|
|
/// Sets the widget currently visible when the leaflet is folded.
|
|
///
|
|
/// The transition is determined by [property`Leaflet`:transition-type] and
|
|
/// [property`Leaflet`:child-transition-params]. The transition can be cancelled
|
|
/// by the user, in which case visible child will change back to the previously
|
|
/// visible child.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setVisibleChild(visibleChild:)`.
|
|
///
|
|
/// - Parameter visibleChild: The widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChild(_ visibleChild: @escaping () -> Adw.Widget) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChild(visibleChild: visibleChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Leaflet.setVisibleChildName(name:)
|
|
/// Makes the child with the name `name` visible.
|
|
///
|
|
/// See [property`Leaflet`:visible-child].
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func visibleChildName<S: StringProtocol>(_ visibleChildName: S) -> Self {
|
|
appending { w, _ in
|
|
w.setVisibleChildName(name: String(visibleChildName))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Leaflet.setVisibleChildName(name:), GObject.Object.connectNotify(detail:_:), Adw.Leaflet.getVisibleChildName()
|
|
/// Makes the child with the name `name` visible.
|
|
///
|
|
/// See [property`Leaflet`:visible-child].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String` 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 visibleChildName(_ visibleChildName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visibleChildName, registry: ctx.registry, notifyDetail: "visible-child-name",
|
|
read: { [w] in w.getVisibleChildName() },
|
|
write: { [w] v in w.setVisibleChildName(name: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Leaflet.setVisibleChildName(name:)
|
|
/// Makes the child with the name `name` visible.
|
|
///
|
|
/// See [property`Leaflet`:visible-child].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Leaflet.setVisibleChildName(name:)`.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisibleChildName(name: visibleChildName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.Leaflet.setVisibleChildName(name:)
|
|
/// Makes the child with the name `name` visible.
|
|
///
|
|
/// See [property`Leaflet`:visible-child].
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.Leaflet.setVisibleChildName(name:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter visibleChildName: The name of the widget currently visible when the leaflet is folded.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visibleChildName(_ visibleChildName: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(visibleChildName, registry: ctx.registry) { [w] v in w.setVisibleChildName(name: v) }
|
|
}
|
|
}
|
|
|
|
}
|