Scale
open class Scale : Range, ScaleProtocol
A GtkScale
is a slider control used to select a numeric value.
To use it, you’ll probably want to investigate the methods on its base
class, [classGtkRange
], in addition to the methods for GtkScale
itself.
To set the value of a scale, you would normally use [methodGtk.Range.set_value
].
To detect changes to the value, you would normally use the
[signalGtk.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 [methodGtk.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.
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 [methodGtk.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 [methodGtk.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 [propertyGtk.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 GTK_ACCESSIBLE_ROLE_SLIDER
role.
The Scale
type acts as a reference-counted owner of an underlying GtkScale
instance.
It provides the methods that can operate on this data type through ScaleProtocol
conformance.
Use Scale
as a strong reference or owner of a GtkScale
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
Scale
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkScale>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkScale>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkScale>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkScale>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkScale
. i.e., ownership is transferred to theScale
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkScale>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
ScaleProtocol
Will retainGtkScale
.Declaration
Swift
@inlinable public init<T>(scale other: T) where T : ScaleProtocol
Parameters
other
an instance of a related type that implements
ScaleProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new
GtkScale
.Declaration
Swift
@inlinable public init<AdjustmentT>(orientation: GtkOrientation, adjustment: AdjustmentT?) where AdjustmentT : AdjustmentProtocol
-
Creates a new scale widget with a range from
min
tomax
.The returns scale will have the given orientation and will let the user input a number between
min
andmax
(includingmin
andmax
) with the incrementstep
.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 [methodGtk.Scale.set_digits
] to correct it.Declaration
Swift
@inlinable public init(range orientation: GtkOrientation, min: CDouble, max: CDouble, step: CDouble)
-
Creates a new scale widget with a range from
min
tomax
.The returns scale will have the given orientation and will let the user input a number between
min
andmax
(includingmin
andmax
) with the incrementstep
.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 [methodGtk.Scale.set_digits
] to correct it.Declaration
Swift
@inlinable public static func newWith(range orientation: GtkOrientation, min: CDouble, max: CDouble, step: CDouble) -> Widget!