Scale

A GtkScale is a slider control used to select a numeric value.

An example GtkScale

To use it, you’ll probably want to investigate the methods on its base class, [class@GtkRange], 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.

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 %GTK_ACCESSIBLE_ROLE_SLIDER role.

Constructors

this
this(GtkScale* gtkScale, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(GtkOrientation orientation, Adjustment adjustment)

Creates a new GtkScale.

this
this(GtkOrientation orientation, double min, double max, double step)

Creates a new scale widget with a range from @min to @max.

Members

Functions

addMark
void addMark(double value, GtkPositionType position, string markup)

Adds a mark at @value.

clearMarks
void clearMarks()

Removes any marks that have been added.

getDigits
int getDigits()

Gets the number of decimal places that are displayed in the value.

getDrawValue
bool getDrawValue()

Returns whether the current value is displayed as a string next to the slider.

getHasOrigin
bool getHasOrigin()

Returns whether the scale has an origin.

getLayout
PgLayout getLayout()

Gets the PangoLayout used to display the scale.

getLayoutOffsets
void getLayoutOffsets(int x, int y)

Obtains the coordinates where the scale will draw the PangoLayout representing the text in the scale.

getScaleStruct
GtkScale* getScaleStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getValuePos
GtkPositionType getValuePos()

Gets the position in which the current value is displayed.

setDigits
void setDigits(int digits)

Sets the number of decimal places that are displayed in the value.

setDrawValue
void setDrawValue(bool drawValue)

Specifies whether the current value is displayed as a string next to the slider.

setFormatValueFunc
void setFormatValueFunc(GtkScaleFormatValueFunc func, void* userData, GDestroyNotify destroyNotify)

@func allows you to change how the scale value is displayed.

setHasOrigin
void setHasOrigin(bool hasOrigin)

Sets whether the scale has an origin.

setValuePos
void setValuePos(GtkPositionType pos)

Sets the position in which the current value is displayed.

Static functions

getType
GType getType()

Variables

gtkScale
GtkScale* gtkScale;

the main Gtk struct

Inherited Members

From Range

gtkRange
GtkRange* gtkRange;

the main Gtk struct

getRangeStruct
GtkRange* getRangeStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

__anonymous
mixin OrientableT!(GtkRange)
Undocumented in source.
getType
GType getType()
getAdjustment
Adjustment getAdjustment()

Get the adjustment which is the “model” object for GtkRange.

getFillLevel
double getFillLevel()

Gets the current position of the fill level indicator.

getFlippable
bool getFlippable()

Gets whether the GtkRange respects text direction.

getInverted
bool getInverted()

Gets whether the range is inverted.

getRangeRect
void getRangeRect(GdkRectangle rangeRect)

This function returns the area that contains the range’s trough, in coordinates relative to @range's origin.

getRestrictToFillLevel
bool getRestrictToFillLevel()

Gets whether the range is restricted to the fill level.

getRoundDigits
int getRoundDigits()

Gets the number of digits to round the value to when it changes.

getShowFillLevel
bool getShowFillLevel()

Gets whether the range displays the fill level graphically.

getSliderRange
void getSliderRange(int sliderStart, int sliderEnd)

This function returns sliders range along the long dimension, in widget->window coordinates.

getSliderSizeFixed
bool getSliderSizeFixed()

This function is useful mainly for GtkRange subclasses.

getValue
double getValue()

Gets the current value of the range.

setAdjustment
void setAdjustment(Adjustment adjustment)

Sets the adjustment to be used as the “model” object for the GtkRange

setFillLevel
void setFillLevel(double fillLevel)

Set the new position of the fill level indicator.

setFlippable
void setFlippable(bool flippable)

Sets whether the GtkRange respects text direction.

setIncrements
void setIncrements(double step, double page)

Sets the step and page sizes for the range.

setInverted
void setInverted(bool setting)

Sets whether to invert the range.

setRange
void setRange(double min, double max)

Sets the allowable values in the GtkRange.

setRestrictToFillLevel
void setRestrictToFillLevel(bool restrictToFillLevel)

Sets whether the slider is restricted to the fill level.

setRoundDigits
void setRoundDigits(int roundDigits)

Sets the number of digits to round the value to when it changes.

setShowFillLevel
void setShowFillLevel(bool showFillLevel)

Sets whether a graphical fill level is show on the trough.

setSliderSizeFixed
void setSliderSizeFixed(bool sizeFixed)

Sets whether the range’s slider has a fixed size, or a size that depends on its adjustment’s page size.

setValue
void setValue(double value)

Sets the current value of the range.

addOnAdjustBounds
gulong addOnAdjustBounds(void delegate(double, Range) dlg, ConnectFlags connectFlags)

Emitted before clamping a value, to give the application a chance to adjust the bounds.

addOnChangeValue
gulong addOnChangeValue(bool delegate(GtkScrollType, double, Range) dlg, ConnectFlags connectFlags)

Emitted when a scroll action is performed on a range.

addOnMoveSlider
gulong addOnMoveSlider(void delegate(GtkScrollType, Range) dlg, ConnectFlags connectFlags)

Virtual function that moves the slider.

addOnValueChanged
gulong addOnValueChanged(void delegate(Range) dlg, ConnectFlags connectFlags)

Emitted when the range value changes.

Meta