ScaleRef
public struct ScaleRef : ScaleProtocol, GWeakCapturing
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, GtkRange
, in addition to the methods for GtkScale itself.
To set the value of a scale, you would normally use gtk_range_set_value()
.
To detect changes to the value, you would normally use the
GtkRange::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 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.
CSS nodes
(plain Language Example):
scale[.fine-tune][.marks-before][.marks-after]
├── marks.top
│ ├── mark
│ ┊ ├── [label]
│ ┊ ╰── indicator
┊ ┊
│ ╰── mark
├── [value]
├── contents
│ ╰── trough
│ ├── slider
│ ├── [highlight]
│ ╰── [fill]
╰── marks.bottom
├── mark
┊ ├── indicator
┊ ╰── [label]
╰── mark
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 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 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 contents 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 GtkScale:draw-value
), there is
subnode with name value.
The ScaleRef
type acts as a lightweight Swift reference to an underlying GtkScale
instance.
It exposes methods that can operate on this data type through ScaleProtocol
conformance.
Use ScaleRef
only as an unowned
reference to an existing GtkScale
instance.
-
Untyped pointer to the underlying `GtkScale` instance.
For type-safe access, use the generated, typed pointer
scale_ptr
property instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GtkScale>)
-
Designated initialiser from a constant pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GtkScale>)
-
Conditional initialiser from an optional pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GtkScale>?)
-
Conditional initialiser from an optional, non-mutable pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GtkScale>?)
-
Conditional initialiser from an optional
gpointer
Declaration
Swift
@inlinable init!(gpointer g: gpointer?)
-
Conditional initialiser from an optional, non-mutable
gconstpointer
Declaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?)
-
Reference intialiser for a related type that implements
ScaleProtocol
Declaration
Swift
@inlinable init<T>(_ other: T) where T : ScaleProtocol
-
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>
Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> ScaleRef where T : ScaleProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>)
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable init(mutating 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 init(raw: UnsafeMutableRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ScaleProtocol
.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
-
Creates a new
GtkScale
.Declaration
Swift
@inlinable init<AdjustmentT>(orientation: GtkOrientation, adjustment: AdjustmentT?) where AdjustmentT : AdjustmentProtocol
-
Creates a new scale widget with the given orientation that lets 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, usegtk_scale_set_digits()
to correct it.Declaration
Swift
@inlinable init(range orientation: GtkOrientation, min: Double, max: Double, step: Double)
-
Creates a new scale widget with the given orientation that lets 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, usegtk_scale_set_digits()
to correct it.Declaration
Swift
@inlinable static func newWith(range orientation: GtkOrientation, min: Double, max: Double, step: Double) -> WidgetRef!