gi-gtk-4.0.6: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.Scale

Description

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 rangeSetValue. To detect changes to the value, you would normally use the Range::valueChanged 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 scaleAddMark 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 scaleSetHasOrigin), 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 rangeSetShowFillLevel), 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 Scale:drawValue), 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 AccessibleRoleSlider role.

Synopsis

Exported types

newtype Scale Source #

Memory-managed wrapper type.

Constructors

Scale (ManagedPtr Scale) 

Instances

Instances details
Eq Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

Methods

(==) :: Scale -> Scale -> Bool #

(/=) :: Scale -> Scale -> Bool #

GObject Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

ManagedPtrNewtype Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

Methods

toManagedPtr :: Scale -> ManagedPtr Scale

TypedObject Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

Methods

glibType :: IO GType

HasParentTypes Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

IsGValue (Maybe Scale) Source #

Convert Scale to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Scale

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Scale -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Scale)

type ParentTypes Scale Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

type ParentTypes Scale = '[Range, Widget, Object, Accessible, Buildable, ConstraintTarget, Orientable]

class (GObject o, IsDescendantOf Scale o) => IsScale o Source #

Type class for types which can be safely cast to Scale, for instance with toScale.

Instances

Instances details
(GObject o, IsDescendantOf Scale o) => IsScale o Source # 
Instance details

Defined in GI.Gtk.Objects.Scale

toScale :: (MonadIO m, IsScale o) => o -> m Scale Source #

Cast to Scale, for types for which this is known to be safe. For general casts, use castTo.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMark, addMnemonicLabel, addTickCallback, allocate, bindProperty, bindPropertyFull, childFocus, clearMarks, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateProperty, updateRelation, updateState, watchClosure.

Getters

getAccessibleRole, getAdjustment, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getData, getDigits, getDirection, getDisplay, getDrawValue, getFillLevel, getFirstChild, getFlippable, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasOrigin, getHasTooltip, getHeight, getHexpand, getHexpandSet, getInverted, getLastChild, getLayout, getLayoutManager, getLayoutOffsets, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOrientation, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRangeRect, getRealized, getReceivesDefault, getRequestMode, getRestrictToFillLevel, getRoot, getRoundDigits, getScaleFactor, getSensitive, getSettings, getShowFillLevel, getSize, getSizeRequest, getSliderRange, getSliderSizeFixed, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getValue, getValuePos, getVexpand, getVexpandSet, getVisible, getWidth.

Setters

setAdjustment, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDigits, setDirection, setDrawValue, setFillLevel, setFlippable, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setFormatValueFunc, setHalign, setHasOrigin, setHasTooltip, setHexpand, setHexpandSet, setIncrements, setInverted, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOrientation, setOverflow, setParent, setProperty, setRange, setReceivesDefault, setRestrictToFillLevel, setRoundDigits, setSensitive, setShowFillLevel, setSizeRequest, setSliderSizeFixed, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setValue, setValuePos, setVexpand, setVexpandSet, setVisible.

addMark

scaleAddMark Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> Double

value: the value at which the mark is placed, must be between the lower and upper limits of the scales’ adjustment

-> PositionType

position: where to draw the mark. For a horizontal scale, PositionTypeTop and PositionTypeLeft are drawn above the scale, anything else below. For a vertical scale, PositionTypeLeft and PositionTypeTop are drawn to the left of the scale, anything else to the right.

-> Maybe Text

markup: Text to be shown at the mark, using Pango markup

-> m () 

Adds a mark at value.

A mark is indicated visually by drawing a tick mark next to the scale, and GTK makes it easy for the user to position the scale exactly at the marks value.

If markup is not Nothing, text is shown next to the tick mark.

To remove marks from a scale, use scaleClearMarks.

clearMarks

scaleClearMarks Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m () 

Removes any marks that have been added.

getDigits

scaleGetDigits Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m Int32

Returns: the number of decimal places that are displayed

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

getDrawValue

scaleGetDrawValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m Bool

Returns: whether the current value is displayed as a string

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

getHasOrigin

scaleGetHasOrigin Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m Bool

Returns: True if the scale has an origin.

Returns whether the scale has an origin.

getLayout

scaleGetLayout Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: A GtkScale

-> m (Maybe Layout)

Returns: the Layout for this scale, or Nothing if the [propertygtkScale:draw-value] property is False.

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

scaleGetLayoutOffsets Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m (Int32, Int32) 

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.

If the [propertygtkScale:draw-value] property is False, the return values are undefined.

getValuePos

scaleGetValuePos Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> m PositionType

Returns: the position in which the current value is displayed

Gets the position in which the current value is displayed.

new

scaleNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsAdjustment a) 
=> Orientation

orientation: the scale’s orientation.

-> Maybe a

adjustment: the Adjustment which sets the range of the scale, or Nothing to create a new adjustment.

-> m Scale

Returns: a new GtkScale

Creates a new GtkScale.

newWithRange

scaleNewWithRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Orientation

orientation: the scale’s orientation.

-> Double

min: minimum value

-> Double

max: maximum value

-> Double

step: step increment (tick size) used with keyboard shortcuts

-> m Scale

Returns: a new GtkScale

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 scaleSetDigits to correct it.

setDigits

scaleSetDigits Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> Int32

digits: the number of decimal places to display, e.g. use 1 to display 1.0, 2 to display 1.00, etc

-> m () 

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 [propertygtkScale:draw-value] is True when the value changes. If you want to enforce rounding the value when [propertygtkScale:draw-value] is False, you can set [propertygtkRange: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 scaleSetFormatValueFunc to format the displayed value yourself.

setDrawValue

scaleSetDrawValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> Bool

drawValue: True to draw the value

-> m () 

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

setFormatValueFunc

scaleSetFormatValueFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> Maybe ScaleFormatValueFunc

func: function that formats the value

-> m () 

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

The given function will return an allocated string representing value. That string will then be used to display the scale's value.

If NULL is passed as func, the value will be displayed on its own, rounded according to the value of the [propertygtkScale:digits] property.

setHasOrigin

scaleSetHasOrigin Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> Bool

hasOrigin: True if the scale has an origin

-> m () 

Sets whether the scale has an origin.

If [propertygtkScale: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

scaleSetValuePos Source #

Arguments

:: (HasCallStack, MonadIO m, IsScale a) 
=> a

scale: a GtkScale

-> PositionType

pos: the position in which the current value is displayed

-> m () 

Sets the position in which the current value is displayed.

Properties

digits

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

constructScaleDigits :: (IsScale o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “digits” property. This is rarely needed directly, but it is used by new.

getScaleDigits :: (MonadIO m, IsScale o) => o -> m Int32 Source #

Get the value of the “digits” property. When overloading is enabled, this is equivalent to

get scale #digits

setScaleDigits :: (MonadIO m, IsScale o) => o -> Int32 -> m () Source #

Set the value of the “digits” property. When overloading is enabled, this is equivalent to

set scale [ #digits := value ]

drawValue

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

constructScaleDrawValue :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “draw-value” property. This is rarely needed directly, but it is used by new.

getScaleDrawValue :: (MonadIO m, IsScale o) => o -> m Bool Source #

Get the value of the “draw-value” property. When overloading is enabled, this is equivalent to

get scale #drawValue

setScaleDrawValue :: (MonadIO m, IsScale o) => o -> Bool -> m () Source #

Set the value of the “draw-value” property. When overloading is enabled, this is equivalent to

set scale [ #drawValue := value ]

hasOrigin

Whether the scale has an origin.

constructScaleHasOrigin :: (IsScale o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “has-origin” property. This is rarely needed directly, but it is used by new.

getScaleHasOrigin :: (MonadIO m, IsScale o) => o -> m Bool Source #

Get the value of the “has-origin” property. When overloading is enabled, this is equivalent to

get scale #hasOrigin

setScaleHasOrigin :: (MonadIO m, IsScale o) => o -> Bool -> m () Source #

Set the value of the “has-origin” property. When overloading is enabled, this is equivalent to

set scale [ #hasOrigin := value ]

valuePos

The position in which the current value is displayed.

constructScaleValuePos :: (IsScale o, MonadIO m) => PositionType -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “value-pos” property. This is rarely needed directly, but it is used by new.

getScaleValuePos :: (MonadIO m, IsScale o) => o -> m PositionType Source #

Get the value of the “value-pos” property. When overloading is enabled, this is equivalent to

get scale #valuePos

setScaleValuePos :: (MonadIO m, IsScale o) => o -> PositionType -> m () Source #

Set the value of the “value-pos” property. When overloading is enabled, this is equivalent to

set scale [ #valuePos := value ]