455 lines
26 KiB
Swift
455 lines
26 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.Scale
|
||
/// Allows to select a numeric value with a slider control.
|
||
///
|
||
/// <picture>
|
||
/// <source srcset="scales-dark.png" media="(prefers-color-scheme: dark)">
|
||
/// <img alt="An example GtkScale" src="scales.png">
|
||
/// </picture>
|
||
///
|
||
/// To use it, you’ll probably want to investigate the methods on its base
|
||
/// class, [class`Gtk`.Range], in addition to the methods for `GtkScale` itself.
|
||
/// To set the value of a scale, you would normally use [method`Gtk`.Range.set_value].
|
||
/// To detect changes to the value, you would normally use the
|
||
/// [signal`Gtk`.Range::value-changed] signal.
|
||
///
|
||
/// Note that using the same upper and lower bounds for the `GtkScale` (through
|
||
/// the `GtkRange` methods) will hide the slider itself. This is useful for
|
||
/// applications that want to show an undeterminate value on the scale, without
|
||
/// changing the layout of the application (such as movie or music players).
|
||
///
|
||
/// # GtkScale as GtkBuildable
|
||
///
|
||
/// `GtkScale` supports a custom `<marks>` element, which can contain multiple
|
||
/// `<mark\>` elements. The “value” and “position” attributes have the same
|
||
/// meaning as [method`Gtk`.Scale.add_mark] parameters of the same name. If
|
||
/// the element is not empty, its content is taken as the markup to show at
|
||
/// the mark. It can be translated with the usual ”translatable” and
|
||
/// “context” attributes.
|
||
///
|
||
/// # Shortcuts and Gestures
|
||
///
|
||
/// `GtkPopoverMenu` supports the following keyboard shortcuts:
|
||
///
|
||
/// - Arrow keys, <kbd>+</kbd> and <kbd>-</kbd> will increment or decrement
|
||
/// by step, or by page when combined with <kbd>Ctrl</kbd>.
|
||
/// - <kbd>PgUp</kbd> and <kbd>PgDn</kbd> will increment or decrement by page.
|
||
/// - <kbd>Home</kbd> and <kbd>End</kbd> will set the minimum or maximum value.
|
||
///
|
||
/// # CSS nodes
|
||
///
|
||
/// ```
|
||
/// scale[.fine-tune][.marks-before][.marks-after]
|
||
/// ├── [value][.top][.right][.bottom][.left]
|
||
/// ├── marks.top
|
||
/// │ ├── mark
|
||
/// │ ┊ ├── [label]
|
||
/// │ ┊ ╰── indicator
|
||
/// ┊ ┊
|
||
/// │ ╰── mark
|
||
/// ├── marks.bottom
|
||
/// │ ├── mark
|
||
/// │ ┊ ├── indicator
|
||
/// │ ┊ ╰── [label]
|
||
/// ┊ ┊
|
||
/// │ ╰── mark
|
||
/// ╰── trough
|
||
/// ├── [fill]
|
||
/// ├── [highlight]
|
||
/// ╰── slider
|
||
/// ```
|
||
///
|
||
/// `GtkScale` has a main CSS node with name scale and a subnode for its contents,
|
||
/// with subnodes named trough and slider.
|
||
///
|
||
/// The main node gets the style class .fine-tune added when the scale is in
|
||
/// 'fine-tuning' mode.
|
||
///
|
||
/// If the scale has an origin (see [method`Gtk`.Scale.set_has_origin]), there is
|
||
/// a subnode with name highlight below the trough node that is used for rendering
|
||
/// the highlighted part of the trough.
|
||
///
|
||
/// If the scale is showing a fill level (see [method`Gtk`.Range.set_show_fill_level]),
|
||
/// there is a subnode with name fill below the trough node that is used for
|
||
/// rendering the filled in part of the trough.
|
||
///
|
||
/// If marks are present, there is a marks subnode before or after the trough
|
||
/// node, below which each mark gets a node with name mark. The marks nodes get
|
||
/// either the .top or .bottom style class.
|
||
///
|
||
/// The mark node has a subnode named indicator. If the mark has text, it also
|
||
/// has a subnode named label. When the mark is either above or left of the
|
||
/// scale, the label subnode is the first when present. Otherwise, the indicator
|
||
/// subnode is the first.
|
||
///
|
||
/// The main CSS node gets the 'marks-before' and/or 'marks-after' style classes
|
||
/// added depending on what marks are present.
|
||
///
|
||
/// If the scale is displaying the value (see [property`Gtk`.Scale:draw-value]),
|
||
/// there is subnode with name value. This node will get the .top or .bottom style
|
||
/// classes similar to the marks node.
|
||
///
|
||
/// # Accessibility
|
||
///
|
||
/// `GtkScale` uses the [enum`Gtk`.AccessibleRole.slider] role.
|
||
///
|
||
/// A Portico view that mounts a `Gtk.Scale`.
|
||
@MainActor public struct Scale: View {
|
||
private let make: (MountContext) -> Gtk.Scale
|
||
private var configure: [(Gtk.Scale, MountContext) -> Void] = []
|
||
|
||
public var body: Never { fatalError() }
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.Scale.init(orientation:adjustment:)
|
||
/// Creates a new `GtkScale`.
|
||
///
|
||
/// 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.Scale`.
|
||
/// - Parameter adjustment: The `adjustment` value forwarded to `Gtk.Scale`.
|
||
/// - Parameter digits: The number of decimal places that are displayed in the value.
|
||
/// - Parameter drawValue: Whether the current value is displayed as a string next to the slider.
|
||
/// - Parameter hasOrigin: Whether the scale has an origin.
|
||
/// - Parameter valuePos: The position in which the current value is displayed.
|
||
/// - Parameter fillLevel: The fill level (e.g. prebuffering of a network stream).
|
||
/// - Parameter inverted: If `true`, the direction in which the slider moves is inverted.
|
||
/// - Parameter restrictToFillLevel: Controls whether slider movement is restricted to an upper boundary set by the fill level.
|
||
/// - Parameter roundDigits: The number of digits to round the value to when it changes.
|
||
/// - Parameter showFillLevel: Controls whether fill level indicator graphics are displayed on the trough.
|
||
/// - Parameter onAdjustBounds: Invoked when the widget emits the `adjust-bounds` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onChangeValue: Invoked when the widget emits the `change-value` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onMoveSlider: Invoked when the widget emits the `move-slider` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onValueChanged: Invoked when the widget emits the `value-changed` signal.
|
||
public init(orientation: Gtk.Orientation, adjustment: Gtk.Adjustment?, digits: Int32? = nil, drawValue: Bool? = nil, hasOrigin: Bool? = nil, valuePos: Gtk.PositionType? = nil, fillLevel: Double? = nil, inverted: Bool? = nil, restrictToFillLevel: Bool? = nil, roundDigits: Int32? = nil, showFillLevel: Bool? = nil, onAdjustBounds: ((Double) -> Void)? = nil, onChangeValue: ((Gtk.ScrollType, Double) -> Bool)? = nil, onMoveSlider: ((Gtk.ScrollType) -> Void)? = nil, onValueChanged: (() -> Void)? = nil) {
|
||
make = { _ in Gtk.Scale(orientation: orientation, adjustment: adjustment) }
|
||
configure.append { w, ctx in
|
||
if let digits { w.setDigits(digits: digits) }
|
||
if let drawValue { w.setDrawValue(drawValue: drawValue) }
|
||
if let hasOrigin { w.setHasOrigin(hasOrigin: hasOrigin) }
|
||
if let valuePos { w.setValuePos(pos: valuePos) }
|
||
if let fillLevel { w.setFillLevel(fillLevel: fillLevel) }
|
||
if let inverted { w.setInverted(setting: inverted) }
|
||
if let restrictToFillLevel { w.setRestrictToFillLevel(restrictToFillLevel: restrictToFillLevel) }
|
||
if let roundDigits { w.setRoundDigits(roundDigits: roundDigits) }
|
||
if let showFillLevel { w.setShowFillLevel(showFillLevel: showFillLevel) }
|
||
if let onAdjustBounds { ctx.registry.add(w.connectAdjustBounds { _, a0 in onAdjustBounds(a0) }) }
|
||
if let onChangeValue { ctx.registry.add(w.connectChangeValue { _, a0, a1 in onChangeValue(a0, a1) }) }
|
||
if let onMoveSlider { ctx.registry.add(w.connectMoveSlider { _, a0 in onMoveSlider(a0) }) }
|
||
if let onValueChanged { ctx.registry.add(w.connectValueChanged { _ in onValueChanged() }) }
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.Scale.init(orientation:min:max:step:)
|
||
/// Creates a new scale widget with a range from `min` to `max`.
|
||
///
|
||
/// The returns scale will have the given orientation and will let the
|
||
/// user input a number between `min` and `max` (including `min` and `max`)
|
||
/// with the increment `step`. `step` must be nonzero; it’s the distance
|
||
/// the slider moves when using the arrow keys to adjust the scale
|
||
/// value.
|
||
///
|
||
/// Note that the way in which the precision is derived works best if
|
||
/// `step` is a power of ten. If the resulting precision is not suitable
|
||
/// for your needs, use [method`Gtk`.Scale.set_digits] to correct it.
|
||
///
|
||
/// 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.Scale`.
|
||
/// - Parameter min: The `min` value forwarded to `Gtk.Scale`.
|
||
/// - Parameter max: The `max` value forwarded to `Gtk.Scale`.
|
||
/// - Parameter step: The `step` value forwarded to `Gtk.Scale`.
|
||
/// - Parameter digits: The number of decimal places that are displayed in the value.
|
||
/// - Parameter drawValue: Whether the current value is displayed as a string next to the slider.
|
||
/// - Parameter hasOrigin: Whether the scale has an origin.
|
||
/// - Parameter valuePos: The position in which the current value is displayed.
|
||
/// - Parameter fillLevel: The fill level (e.g. prebuffering of a network stream).
|
||
/// - Parameter inverted: If `true`, the direction in which the slider moves is inverted.
|
||
/// - Parameter restrictToFillLevel: Controls whether slider movement is restricted to an upper boundary set by the fill level.
|
||
/// - Parameter roundDigits: The number of digits to round the value to when it changes.
|
||
/// - Parameter showFillLevel: Controls whether fill level indicator graphics are displayed on the trough.
|
||
/// - Parameter onAdjustBounds: Invoked when the widget emits the `adjust-bounds` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onChangeValue: Invoked when the widget emits the `change-value` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onMoveSlider: Invoked when the widget emits the `move-slider` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onValueChanged: Invoked when the widget emits the `value-changed` signal.
|
||
public init(orientation: Gtk.Orientation, min: Double, max: Double, step: Double, digits: Int32? = nil, drawValue: Bool? = nil, hasOrigin: Bool? = nil, valuePos: Gtk.PositionType? = nil, fillLevel: Double? = nil, inverted: Bool? = nil, restrictToFillLevel: Bool? = nil, roundDigits: Int32? = nil, showFillLevel: Bool? = nil, onAdjustBounds: ((Double) -> Void)? = nil, onChangeValue: ((Gtk.ScrollType, Double) -> Bool)? = nil, onMoveSlider: ((Gtk.ScrollType) -> Void)? = nil, onValueChanged: (() -> Void)? = nil) {
|
||
make = { _ in Gtk.Scale(orientation: orientation, min: min, max: max, step: step) }
|
||
configure.append { w, ctx in
|
||
if let digits { w.setDigits(digits: digits) }
|
||
if let drawValue { w.setDrawValue(drawValue: drawValue) }
|
||
if let hasOrigin { w.setHasOrigin(hasOrigin: hasOrigin) }
|
||
if let valuePos { w.setValuePos(pos: valuePos) }
|
||
if let fillLevel { w.setFillLevel(fillLevel: fillLevel) }
|
||
if let inverted { w.setInverted(setting: inverted) }
|
||
if let restrictToFillLevel { w.setRestrictToFillLevel(restrictToFillLevel: restrictToFillLevel) }
|
||
if let roundDigits { w.setRoundDigits(roundDigits: roundDigits) }
|
||
if let showFillLevel { w.setShowFillLevel(showFillLevel: showFillLevel) }
|
||
if let onAdjustBounds { ctx.registry.add(w.connectAdjustBounds { _, a0 in onAdjustBounds(a0) }) }
|
||
if let onChangeValue { ctx.registry.add(w.connectChangeValue { _, a0, a1 in onChangeValue(a0, a1) }) }
|
||
if let onMoveSlider { ctx.registry.add(w.connectMoveSlider { _, a0 in onMoveSlider(a0) }) }
|
||
if let onValueChanged { ctx.registry.add(w.connectValueChanged { _ in onValueChanged() }) }
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
extension Scale: WidgetView {
|
||
public typealias Target = Gtk.Scale
|
||
|
||
@_spi(Portico) public func appending(
|
||
_ step: @escaping (Gtk.Scale, MountContext) -> Void
|
||
) -> Self {
|
||
var c = self
|
||
c.configure.append(step)
|
||
return c
|
||
}
|
||
}
|
||
|
||
@_spi(Portico) extension Scale: 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.Scale
|
||
/// Modifiers for `Gtk.Scale`, available on every Portico view whose
|
||
/// backing widget is `Gtk.Scale` or one of its subclasses.
|
||
extension WidgetView where Target: Gtk.Scale {
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Scale.setDigits(digits:)
|
||
/// Sets the number of decimal places that are displayed in the value.
|
||
///
|
||
/// Also causes the value of the adjustment to be rounded to this number
|
||
/// of digits, so the retrieved value matches the displayed one, if
|
||
/// [property`Gtk`.Scale:draw-value] is `true` when the value changes. If
|
||
/// you want to enforce rounding the value when [property`Gtk`.Scale:draw-value]
|
||
/// is `false`, you can set [property`Gtk`.Range:round-digits] instead.
|
||
///
|
||
/// Note that rounding to a small number of digits can interfere with
|
||
/// the smooth autoscrolling that is built into `GtkScale`. As an alternative,
|
||
/// you can use [method`Gtk`.Scale.set_format_value_func] to format the displayed
|
||
/// value yourself.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter digits: The number of decimal places that are displayed in the value.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func digits(_ digits: Int32) -> Self {
|
||
appending { w, _ in
|
||
w.setDigits(digits: digits)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Scale.setDigits(digits:), GObject.Object.connectNotify(detail:_:), Gtk.Scale.getDigits()
|
||
/// Sets the number of decimal places that are displayed in the value.
|
||
///
|
||
/// Also causes the value of the adjustment to be rounded to this number
|
||
/// of digits, so the retrieved value matches the displayed one, if
|
||
/// [property`Gtk`.Scale:draw-value] is `true` when the value changes. If
|
||
/// you want to enforce rounding the value when [property`Gtk`.Scale:draw-value]
|
||
/// is `false`, you can set [property`Gtk`.Range:round-digits] instead.
|
||
///
|
||
/// Note that rounding to a small number of digits can interfere with
|
||
/// the smooth autoscrolling that is built into `GtkScale`. As an alternative,
|
||
/// you can use [method`Gtk`.Scale.set_format_value_func] to format the displayed
|
||
/// value yourself.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// When `Int32` 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 digits(_ digits: Portico.Binding<Int32>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, digits, registry: ctx.registry, notifyDetail: "digits",
|
||
read: { [w] in w.getDigits() },
|
||
write: { [w] v in w.setDigits(digits: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Scale.setDigits(digits:)
|
||
/// Sets the number of decimal places that are displayed in the value.
|
||
///
|
||
/// Also causes the value of the adjustment to be rounded to this number
|
||
/// of digits, so the retrieved value matches the displayed one, if
|
||
/// [property`Gtk`.Scale:draw-value] is `true` when the value changes. If
|
||
/// you want to enforce rounding the value when [property`Gtk`.Scale:draw-value]
|
||
/// is `false`, you can set [property`Gtk`.Range:round-digits] instead.
|
||
///
|
||
/// Note that rounding to a small number of digits can interfere with
|
||
/// the smooth autoscrolling that is built into `GtkScale`. As an alternative,
|
||
/// you can use [method`Gtk`.Scale.set_format_value_func] to format the displayed
|
||
/// value yourself.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Scale.setDigits(digits:)`.
|
||
///
|
||
/// - Parameter digits: The number of decimal places that are displayed in the value.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func digits(_ digits: @escaping () -> Int32) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setDigits(digits: digits()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Scale.setDrawValue(drawValue:)
|
||
/// Specifies whether the current value is displayed as a string next
|
||
/// to the slider.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter drawValue: Whether the current value is displayed as a string next to the slider.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func drawValue(_ drawValue: Bool) -> Self {
|
||
appending { w, _ in
|
||
w.setDrawValue(drawValue: drawValue)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Scale.setDrawValue(drawValue:), GObject.Object.connectNotify(detail:_:), Gtk.Scale.getDrawValue()
|
||
/// Specifies whether the current value is displayed as a string next
|
||
/// to the slider.
|
||
///
|
||
/// 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 drawValue(_ drawValue: Portico.Binding<Bool>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, drawValue, registry: ctx.registry, notifyDetail: "draw-value",
|
||
read: { [w] in w.getDrawValue() },
|
||
write: { [w] v in w.setDrawValue(drawValue: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Scale.setDrawValue(drawValue:)
|
||
/// Specifies whether the current value is displayed as a string next
|
||
/// to the slider.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Scale.setDrawValue(drawValue:)`.
|
||
///
|
||
/// - Parameter drawValue: Whether the current value is displayed as a string next to the slider.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func drawValue(_ drawValue: @escaping () -> Bool) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setDrawValue(drawValue: drawValue()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Scale.setHasOrigin(hasOrigin:)
|
||
/// Sets whether the scale has an origin.
|
||
///
|
||
/// If [property`Gtk`.Scale:has-origin] is set to `true` (the default),
|
||
/// the scale will highlight the part of the trough between the origin
|
||
/// (bottom or left side) and the current value.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter hasOrigin: Whether the scale has an origin.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func hasOrigin(_ hasOrigin: Bool) -> Self {
|
||
appending { w, _ in
|
||
w.setHasOrigin(hasOrigin: hasOrigin)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Scale.setHasOrigin(hasOrigin:), GObject.Object.connectNotify(detail:_:), Gtk.Scale.getHasOrigin()
|
||
/// Sets whether the scale has an origin.
|
||
///
|
||
/// If [property`Gtk`.Scale:has-origin] is set to `true` (the default),
|
||
/// the scale will highlight the part of the trough between the origin
|
||
/// (bottom or left side) and the current value.
|
||
///
|
||
/// 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 hasOrigin(_ hasOrigin: Portico.Binding<Bool>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, hasOrigin, registry: ctx.registry, notifyDetail: "has-origin",
|
||
read: { [w] in w.getHasOrigin() },
|
||
write: { [w] v in w.setHasOrigin(hasOrigin: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Scale.setHasOrigin(hasOrigin:)
|
||
/// Sets whether the scale has an origin.
|
||
///
|
||
/// If [property`Gtk`.Scale:has-origin] is set to `true` (the default),
|
||
/// the scale will highlight the part of the trough between the origin
|
||
/// (bottom or left side) and the current value.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Scale.setHasOrigin(hasOrigin:)`.
|
||
///
|
||
/// - Parameter hasOrigin: Whether the scale has an origin.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func hasOrigin(_ hasOrigin: @escaping () -> Bool) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setHasOrigin(hasOrigin: hasOrigin()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Scale.setValuePos(pos:)
|
||
/// Sets the position in which the current value is displayed.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter valuePos: The position in which the current value is displayed.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func valuePos(_ valuePos: Gtk.PositionType) -> Self {
|
||
appending { w, _ in
|
||
w.setValuePos(pos: valuePos)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Scale.setValuePos(pos:), GObject.Object.connectNotify(detail:_:), Gtk.Scale.getValuePos()
|
||
/// Sets the position in which the current value is displayed.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// When `Gtk.PositionType` 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 valuePos(_ valuePos: Portico.Binding<Gtk.PositionType>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, valuePos, registry: ctx.registry, notifyDetail: "value-pos",
|
||
read: { [w] in w.getValuePos() },
|
||
write: { [w] v in w.setValuePos(pos: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Scale.setValuePos(pos:)
|
||
/// Sets the position in which the current value is displayed.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Scale.setValuePos(pos:)`.
|
||
///
|
||
/// - Parameter valuePos: The position in which the current value is displayed.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func valuePos(_ valuePos: @escaping () -> Gtk.PositionType) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setValuePos(pos: valuePos()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
}
|