Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
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, Range
, 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
::value-changed
signal.
Note that using the same upper and lower bounds for the Scale
(through
the Range
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
plain code
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 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 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 Scale
:draw-value
), there is
subnode with name value.
- newtype Scale = Scale (ManagedPtr Scale)
- class GObject o => IsScale o
- toScale :: IsScale o => o -> IO Scale
- noScale :: Maybe Scale
- data ScaleAddMarkMethodInfo
- scaleAddMark :: (HasCallStack, MonadIO m, IsScale a) => a -> Double -> PositionType -> Maybe Text -> m ()
- data ScaleClearMarksMethodInfo
- scaleClearMarks :: (HasCallStack, MonadIO m, IsScale a) => a -> m ()
- data ScaleGetDigitsMethodInfo
- scaleGetDigits :: (HasCallStack, MonadIO m, IsScale a) => a -> m Int32
- data ScaleGetDrawValueMethodInfo
- scaleGetDrawValue :: (HasCallStack, MonadIO m, IsScale a) => a -> m Bool
- data ScaleGetHasOriginMethodInfo
- scaleGetHasOrigin :: (HasCallStack, MonadIO m, IsScale a) => a -> m Bool
- data ScaleGetLayoutMethodInfo
- scaleGetLayout :: (HasCallStack, MonadIO m, IsScale a) => a -> m (Maybe Layout)
- data ScaleGetLayoutOffsetsMethodInfo
- scaleGetLayoutOffsets :: (HasCallStack, MonadIO m, IsScale a) => a -> m (Int32, Int32)
- data ScaleGetValuePosMethodInfo
- scaleGetValuePos :: (HasCallStack, MonadIO m, IsScale a) => a -> m PositionType
- scaleNew :: (HasCallStack, MonadIO m, IsAdjustment a) => Orientation -> Maybe a -> m Scale
- scaleNewWithRange :: (HasCallStack, MonadIO m) => Orientation -> Double -> Double -> Double -> m Scale
- data ScaleSetDigitsMethodInfo
- scaleSetDigits :: (HasCallStack, MonadIO m, IsScale a) => a -> Int32 -> m ()
- data ScaleSetDrawValueMethodInfo
- scaleSetDrawValue :: (HasCallStack, MonadIO m, IsScale a) => a -> Bool -> m ()
- data ScaleSetHasOriginMethodInfo
- scaleSetHasOrigin :: (HasCallStack, MonadIO m, IsScale a) => a -> Bool -> m ()
- data ScaleSetValuePosMethodInfo
- scaleSetValuePos :: (HasCallStack, MonadIO m, IsScale a) => a -> PositionType -> m ()
- data ScaleDigitsPropertyInfo
- constructScaleDigits :: IsScale o => Int32 -> IO (GValueConstruct o)
- getScaleDigits :: (MonadIO m, IsScale o) => o -> m Int32
- scaleDigits :: AttrLabelProxy "digits"
- setScaleDigits :: (MonadIO m, IsScale o) => o -> Int32 -> m ()
- data ScaleDrawValuePropertyInfo
- constructScaleDrawValue :: IsScale o => Bool -> IO (GValueConstruct o)
- getScaleDrawValue :: (MonadIO m, IsScale o) => o -> m Bool
- scaleDrawValue :: AttrLabelProxy "drawValue"
- setScaleDrawValue :: (MonadIO m, IsScale o) => o -> Bool -> m ()
- data ScaleHasOriginPropertyInfo
- constructScaleHasOrigin :: IsScale o => Bool -> IO (GValueConstruct o)
- getScaleHasOrigin :: (MonadIO m, IsScale o) => o -> m Bool
- scaleHasOrigin :: AttrLabelProxy "hasOrigin"
- setScaleHasOrigin :: (MonadIO m, IsScale o) => o -> Bool -> m ()
- data ScaleValuePosPropertyInfo
- constructScaleValuePos :: IsScale o => PositionType -> IO (GValueConstruct o)
- getScaleValuePos :: (MonadIO m, IsScale o) => o -> m PositionType
- scaleValuePos :: AttrLabelProxy "valuePos"
- setScaleValuePos :: (MonadIO m, IsScale o) => o -> PositionType -> m ()
- type C_ScaleFormatValueCallback = Ptr () -> CDouble -> Ptr () -> IO CString
- type ScaleFormatValueCallback = Double -> IO Text
- data ScaleFormatValueSignalInfo
- afterScaleFormatValue :: (GObject a, MonadIO m) => a -> ScaleFormatValueCallback -> m SignalHandlerId
- genClosure_ScaleFormatValue :: ScaleFormatValueCallback -> IO Closure
- mk_ScaleFormatValueCallback :: C_ScaleFormatValueCallback -> IO (FunPtr C_ScaleFormatValueCallback)
- noScaleFormatValueCallback :: Maybe ScaleFormatValueCallback
- onScaleFormatValue :: (GObject a, MonadIO m) => a -> ScaleFormatValueCallback -> m SignalHandlerId
- wrap_ScaleFormatValueCallback :: ScaleFormatValueCallback -> Ptr () -> CDouble -> Ptr () -> IO CString
Exported types
GObject Scale Source # | |
IsImplementorIface Scale Source # | |
IsObject Scale Source # | |
IsWidget Scale Source # | |
IsScale Scale Source # | |
IsRange Scale Source # | |
IsOrientable Scale Source # | |
IsBuildable Scale Source # | |
((~) * info (ResolveScaleMethod t Scale), MethodInfo * info Scale p) => IsLabel t (Scale -> p) Source # | |
((~) * info (ResolveScaleMethod t Scale), MethodInfo * info Scale p) => IsLabelProxy t (Scale -> p) Source # | |
HasAttributeList * Scale Source # | |
type AttributeList Scale Source # | |
type SignalList Scale Source # | |
Methods
addMark
data ScaleAddMarkMethodInfo Source #
((~) * signature (Double -> PositionType -> Maybe Text -> m ()), MonadIO m, IsScale a) => MethodInfo * ScaleAddMarkMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Double |
|
-> PositionType |
|
-> Maybe Text |
|
-> 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
.
Since: 2.16
clearMarks
data ScaleClearMarksMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsScale a) => MethodInfo * ScaleClearMarksMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m () |
Removes any marks that have been added with scaleAddMark
.
Since: 2.16
getDigits
data ScaleGetDigitsMethodInfo Source #
((~) * signature (m Int32), MonadIO m, IsScale a) => MethodInfo * ScaleGetDigitsMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m Int32 | Returns: the number of decimal places |
Gets the number of decimal places to which the value is rounded on change.
This number is also used by the default Scale
::format-value
handler.
getDrawValue
data ScaleGetDrawValueMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsScale a) => MethodInfo * ScaleGetDrawValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> 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
data ScaleGetHasOriginMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsScale a) => MethodInfo * ScaleGetHasOriginMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the scale has an origin.
Since: 3.4
getLayout
data ScaleGetLayoutMethodInfo Source #
((~) * signature (m (Maybe Layout)), MonadIO m, IsScale a) => MethodInfo * ScaleGetLayoutMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m (Maybe Layout) | Returns: the |
Gets the Layout
used to display the scale. The returned
object is owned by the scale so does not need to be freed by
the caller.
Since: 2.4
getLayoutOffsets
data ScaleGetLayoutOffsetsMethodInfo Source #
((~) * signature (m (Int32, Int32)), MonadIO m, IsScale a) => MethodInfo * ScaleGetLayoutOffsetsMethodInfo a signature Source # | |
getValuePos
data ScaleGetValuePosMethodInfo Source #
((~) * signature (m PositionType), MonadIO m, IsScale a) => MethodInfo * ScaleGetValuePosMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> m PositionType | Returns: the position in which the current value is displayed |
Gets the position in which the current value is displayed.
new
:: (HasCallStack, MonadIO m, IsAdjustment a) | |
=> Orientation |
|
-> Maybe a |
|
-> m Scale | Returns: a new |
Creates a new Scale
.
Since: 3.0
newWithRange
:: (HasCallStack, MonadIO m) | |
=> Orientation |
|
-> Double |
|
-> Double |
|
-> Double |
|
-> m Scale | Returns: a new |
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.
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.
Since: 3.0
setDigits
data ScaleSetDigitsMethodInfo Source #
((~) * signature (Int32 -> m ()), MonadIO m, IsScale a) => MethodInfo * ScaleSetDigitsMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Int32 |
|
-> m () |
Sets the number of decimal places to which the value is rounded when it is
changed. This also sets the number of digits shown in the displayed value
when using the default handler for the Scale
::format-value
signal.
Note that rounding to a small number of digits can interfere with
the smooth autoscrolling that is built into Scale
. As an alternative,
you can use the Scale
::format-value
signal to format the displayed
value yourself.
setDrawValue
data ScaleSetDrawValueMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsScale a) => MethodInfo * ScaleSetDrawValueMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Bool |
|
-> m () |
Specifies whether the current value is displayed as a string next to the slider.
setHasOrigin
data ScaleSetHasOriginMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsScale a) => MethodInfo * ScaleSetHasOriginMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> Bool |
|
-> m () |
If hasOrigin
is set to True
(the default),
the scale will highlight the part of the scale
between the origin (bottom or left side) of the scale
and the current value.
Since: 3.4
setValuePos
data ScaleSetValuePosMethodInfo Source #
((~) * signature (PositionType -> m ()), MonadIO m, IsScale a) => MethodInfo * ScaleSetValuePosMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsScale a) | |
=> a |
|
-> PositionType |
|
-> m () |
Sets the position in which the current value is displayed.
Properties
digits
data ScaleDigitsPropertyInfo Source #
constructScaleDigits :: IsScale o => Int32 -> IO (GValueConstruct o) Source #
scaleDigits :: AttrLabelProxy "digits" Source #
drawValue
data ScaleDrawValuePropertyInfo Source #
constructScaleDrawValue :: IsScale o => Bool -> IO (GValueConstruct o) Source #
scaleDrawValue :: AttrLabelProxy "drawValue" Source #
hasOrigin
data ScaleHasOriginPropertyInfo Source #
constructScaleHasOrigin :: IsScale o => Bool -> IO (GValueConstruct o) Source #
scaleHasOrigin :: AttrLabelProxy "hasOrigin" Source #
valuePos
data ScaleValuePosPropertyInfo Source #
constructScaleValuePos :: IsScale o => PositionType -> IO (GValueConstruct o) Source #
getScaleValuePos :: (MonadIO m, IsScale o) => o -> m PositionType Source #
scaleValuePos :: AttrLabelProxy "valuePos" Source #
setScaleValuePos :: (MonadIO m, IsScale o) => o -> PositionType -> m () Source #
Signals
formatValue
afterScaleFormatValue :: (GObject a, MonadIO m) => a -> ScaleFormatValueCallback -> m SignalHandlerId Source #
mk_ScaleFormatValueCallback :: C_ScaleFormatValueCallback -> IO (FunPtr C_ScaleFormatValueCallback) Source #
onScaleFormatValue :: (GObject a, MonadIO m) => a -> ScaleFormatValueCallback -> m SignalHandlerId Source #
wrap_ScaleFormatValueCallback :: ScaleFormatValueCallback -> Ptr () -> CDouble -> Ptr () -> IO CString Source #