Scale

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.Range.setValue. 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.Scale.addMark 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]
├── 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.Scale.setHasOrigin), 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.Range.setShowFillLevel), 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.

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this(gtk.types.Orientation orientation, gtk.adjustment.Adjustment adjustment)

Creates a new #GtkScale.

Members

Functions

addMark
void addMark(double value, gtk.types.PositionType position, string markup)

Adds a mark at value.

clearMarks
void clearMarks()

Removes any marks that have been added with gtk.scale.Scale.addMark.

connectFormatValue
gulong connectFormatValue(T callback, Flag!"After" after)

Connect to FormatValue signal.

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
pango.layout.Layout getLayout()

Gets the #PangoLayout used to display the scale. The returned object is owned by the scale so does not need to be freed by the caller.

getLayoutOffsets
void getLayoutOffsets(int x, int y)

Obtains the coordinates where the scale will draw the #PangoLayout representing the text in the scale. Remember when using the #PangoLayout function you need to convert to and from pixels using PANGO_PIXELS() or #PANGO_SCALE.

getValuePos
gtk.types.PositionType getValuePos()

Gets the position in which the current value is displayed.

self
Scale self()

Returns this, for use in with statements.

setDigits
void setDigits(int 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 #GtkScale:draw-value is true when the value changes. If you want to enforce rounding the value when #GtkScale:draw-value is false, you can set #GtkRange:round-digits instead.

setDrawValue
void setDrawValue(bool drawValue)

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

setHasOrigin
void setHasOrigin(bool hasOrigin)

If #GtkScale: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.

setValuePos
void setValuePos(gtk.types.PositionType pos)

Sets the position in which the current value is displayed.

Properties

_gType
GType _gType [@property getter]
digits
int digits [@property getter]
digits
int digits [@property setter]
drawValue
bool drawValue [@property getter]
drawValue
bool drawValue [@property setter]
hasOrigin
bool hasOrigin [@property getter]
hasOrigin
bool hasOrigin [@property setter]
valuePos
gtk.types.PositionType valuePos [@property getter]
valuePos
gtk.types.PositionType valuePos [@property setter]

Static functions

_getGType
GType _getGType()
builder
ScaleGidBuilder builder()

Get builder for gtk.scale.Scale

newWithRange
gtk.scale.Scale newWithRange(gtk.types.Orientation orientation, double min, double max, double step)

Creates a new scale widget with the given orientation that lets 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.

Inherited Members

From Range

_getGType
GType _getGType()
_gType
GType _gType [@property getter]
self
Range self()

Returns this, for use in with statements.

builder
RangeGidBuilder builder()

Get builder for gtk.range.Range

adjustment
gtk.adjustment.Adjustment adjustment [@property getter]
adjustment
gtk.adjustment.Adjustment adjustment [@property setter]
fillLevel
double fillLevel [@property getter]

Get fillLevel property.

fillLevel
double fillLevel [@property setter]

Set fillLevel property.

inverted
bool inverted [@property getter]
inverted
bool inverted [@property setter]
lowerStepperSensitivity
gtk.types.SensitivityType lowerStepperSensitivity [@property getter]
lowerStepperSensitivity
gtk.types.SensitivityType lowerStepperSensitivity [@property setter]
restrictToFillLevel
bool restrictToFillLevel [@property getter]

Get restrictToFillLevel property.

restrictToFillLevel
bool restrictToFillLevel [@property setter]

Set restrictToFillLevel property.

roundDigits
int roundDigits [@property getter]

Get roundDigits property.

roundDigits
int roundDigits [@property setter]

Set roundDigits property.

showFillLevel
bool showFillLevel [@property getter]

Get showFillLevel property.

showFillLevel
bool showFillLevel [@property setter]

Set showFillLevel property.

upperStepperSensitivity
gtk.types.SensitivityType upperStepperSensitivity [@property getter]
upperStepperSensitivity
gtk.types.SensitivityType upperStepperSensitivity [@property setter]
getAdjustment
gtk.adjustment.Adjustment getAdjustment()

Get the #GtkAdjustment which is the “model” object for #GtkRange. See gtk.range.Range.setAdjustment for details. The return value does not have a reference added, so should not be unreferenced.

getFillLevel
double getFillLevel()

Gets the current position of the fill level indicator.

getFlippable
bool getFlippable()

Gets the value set by gtk.range.Range.setFlippable.

getInverted
bool getInverted()

Gets the value set by gtk.range.Range.setInverted.

getLowerStepperSensitivity
gtk.types.SensitivityType getLowerStepperSensitivity()

Gets the sensitivity policy for the stepper that points to the 'lower' end of the GtkRange’s adjustment.

getMinSliderSize
int getMinSliderSize()

This function is useful mainly for #GtkRange subclasses.

getRangeRect
void getRangeRect(gdk.rectangle.Rectangle rangeRect)

This function returns the area that contains the range’s trough and its steppers, in widget->window coordinates.

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. See #GtkRange::change-value.

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.

getUpperStepperSensitivity
gtk.types.SensitivityType getUpperStepperSensitivity()

Gets the sensitivity policy for the stepper that points to the 'upper' end of the GtkRange’s adjustment.

getValue
double getValue()

Gets the current value of the range.

setAdjustment
void setAdjustment(gtk.adjustment.Adjustment adjustment)

Sets the adjustment to be used as the “model” object for this range widget. The adjustment indicates the current range value, the minimum and maximum range values, the step/page increments used for keybindings and scrolling, and the page size. The page size is normally 0 for #GtkScale and nonzero for #GtkScrollbar, and indicates the size of the visible area of the widget being scrolled. The page size affects the size of the scrollbar slider.

setFillLevel
void setFillLevel(double fillLevel)

Set the new position of the fill level indicator.

setFlippable
void setFlippable(bool flippable)

If a range is flippable, it will switch its direction if it is horizontal and its direction is gtk.types.TextDirection.Rtl.

setIncrements
void setIncrements(double step, double page)

Sets the step and page sizes for the range. The step size is used when the user clicks the #GtkScrollbar arrows or moves #GtkScale via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.

setInverted
void setInverted(bool setting)

Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.

setLowerStepperSensitivity
void setLowerStepperSensitivity(gtk.types.SensitivityType sensitivity)

Sets the sensitivity policy for the stepper that points to the 'lower' end of the GtkRange’s adjustment.

setMinSliderSize
void setMinSliderSize(int minSize)

Sets the minimum size of the range’s slider.

setRange
void setRange(double min, double max)

Sets the allowable values in the #GtkRange, and clamps the range value to be between min and max. (If the range has a non-zero page size, it is clamped between min and max - page-size.)

setRestrictToFillLevel
void setRestrictToFillLevel(bool restrictToFillLevel)

Sets whether the slider is restricted to the fill level. See gtk.range.Range.setFillLevel for a general description of the fill level concept.

setRoundDigits
void setRoundDigits(int roundDigits)

Sets the number of digits to round the value to when it changes. See #GtkRange::change-value.

setShowFillLevel
void setShowFillLevel(bool showFillLevel)

Sets whether a graphical fill level is show on the trough. See gtk.range.Range.setFillLevel for a general description of the fill level concept.

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.

setUpperStepperSensitivity
void setUpperStepperSensitivity(gtk.types.SensitivityType sensitivity)

Sets the sensitivity policy for the stepper that points to the 'upper' end of the GtkRange’s adjustment.

setValue
void setValue(double value)

Sets the current value of the range; if the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the #GtkRange::value-changed signal if the value changes.

connectAdjustBounds
gulong connectAdjustBounds(T callback, Flag!"After" after)

Connect to AdjustBounds signal.

connectChangeValue
gulong connectChangeValue(T callback, Flag!"After" after)

Connect to ChangeValue signal.

connectMoveSlider
gulong connectMoveSlider(T callback, Flag!"After" after)

Connect to MoveSlider signal.

connectValueChanged
gulong connectValueChanged(T callback, Flag!"After" after)

Connect to ValueChanged signal.