Struct gtk4::Scale [−][src]
pub struct Scale(_);
Expand description
A Scale
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 Scale
itself.
To set the value of a scale, you would normally use RangeExt::set_value()
.
To detect changes to the value, you would normally use the
signal::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
Scale
supports a custom <marks>
element, which can contain multiple
<mark> elements. The “value” and “position” attributes have the same
meaning as ScaleExt::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
Scale
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 ScaleExt::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 RangeExt::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::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
Scale
uses the AccessibleRole::Slider
role.
Implements
ScaleExt
, RangeExt
, WidgetExt
, glib::ObjectExt
, AccessibleExt
, BuildableExt
, ConstraintTargetExt
, OrientableExt
, ScaleExtManual
, WidgetExtManual
, AccessibleExtManual
Implementations
Creates a new Scale
.
orientation
the scale’s orientation.
adjustment
the Adjustment
which sets
the range of the scale, or None
to create a new adjustment.
Returns
a new Scale
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 ScaleExt::set_digits()
to correct it.
orientation
the scale’s orientation.
min
minimum value
max
maximum value
step
step increment (tick size) used with keyboard shortcuts
Returns
a new Scale
Creates a new builder-pattern struct instance to construct Scale
objects.
This method returns an instance of ScaleBuilder
which can be used to create Scale
objects.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Scale
impl UnwindSafe for Scale
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Same as emit
but takes Value
for the arguments.
Emit signal by its name.
Same as emit_by_name
but takes Value
for the arguments.
Emit signal with details by signal id.
Same as emit_with_details
but takes Value
for the arguments.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.