pub trait ScaleExt: 'static {
Show 17 methods
fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>);
fn clear_marks(&self);
fn digits(&self) -> i32;
fn draws_value(&self) -> bool;
fn has_origin(&self) -> bool;
fn layout(&self) -> Option<Layout>;
fn layout_offsets(&self) -> (i32, i32);
fn value_pos(&self) -> PositionType;
fn set_digits(&self, digits: i32);
fn set_draw_value(&self, draw_value: bool);
fn set_has_origin(&self, has_origin: bool);
fn set_value_pos(&self, pos: PositionType);
fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_digits_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_draw_value_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_has_origin_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_value_pos_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods
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 None
, text is shown next to the tick mark.
To remove marks from a scale, use clear_marks()
.
value
the value at which the mark is placed, must be between the lower and upper limits of the scales’ adjustment
position
where to draw the mark. For a horizontal scale, PositionType::Top
and PositionType::Left
are drawn above the scale, anything else below.
For a vertical scale, PositionType::Left
and PositionType::Top
are drawn to
the left of the scale, anything else to the right.
markup
Text to be shown at the mark, using [Pango markup][PangoMarkupFormat], or None
fn clear_marks(&self)
fn clear_marks(&self)
Removes any marks that have been added with add_mark()
.
Gets the number of decimal places that are displayed in the value.
Returns
the number of decimal places that are displayed
fn draws_value(&self) -> bool
fn draws_value(&self) -> bool
Returns whether the current value is displayed as a string next to the slider.
Returns
whether the current value is displayed as a string
fn has_origin(&self) -> bool
fn has_origin(&self) -> bool
Gets the pango::Layout
used to display the scale. The returned
object is owned by the scale so does not need to be freed by
the caller.
Returns
the pango::Layout
for this scale,
or None
if the property::Scale::draw-value
property is false
.
Obtains the coordinates where the scale will draw the
pango::Layout
representing the text in the scale. Remember
when using the pango::Layout
function you need to convert to
and from pixels using PANGO_PIXELS() or PANGO_SCALE
.
If the property::Scale::draw-value
property is false
, the return
values are undefined.
Returns
x
location to store X offset of layout, or None
y
location to store Y offset of layout, or None
fn value_pos(&self) -> PositionType
fn value_pos(&self) -> PositionType
Gets the position in which the current value is displayed.
Returns
the position in which the current value is displayed
fn set_digits(&self, digits: i32)
fn set_digits(&self, digits: i32)
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 property::Scale::draw-value
is
true
when the value changes. If you want to enforce rounding the value when
property::Scale::draw-value
is false
, you can set property::Range::round-digits
instead.
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 signal::Scale::format-value
signal to format the displayed
value yourself.
digits
the number of decimal places to display, e.g. use 1 to display 1.0, 2 to display 1.00, etc
fn set_draw_value(&self, draw_value: bool)
fn set_draw_value(&self, draw_value: bool)
Specifies whether the current value is displayed as a string next to the slider.
draw_value
true
to draw the value
fn set_has_origin(&self, has_origin: bool)
fn set_has_origin(&self, has_origin: bool)
If property::Scale::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.
has_origin
true
if the scale has an origin
fn set_value_pos(&self, pos: PositionType)
fn set_value_pos(&self, pos: PositionType)
Sets the position in which the current value is displayed.
pos
the position in which the current value is displayed
fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(
&self,
f: F
) -> SignalHandlerId
Signal which allows you to change how the scale value is displayed.
Connect a signal handler which returns an allocated string representing
value
. That string will then be used to display the scale’s value.
If no user-provided handlers are installed, the value will be displayed on
its own, rounded according to the value of the property::Scale::digits
property.
Here’s an example signal handler which displays a value 1.0 as with “–>1.0<–”.
⚠️ The following code is in C ⚠️
static gchar*
format_value_callback (GtkScale *scale,
gdouble value)
{
return g_strdup_printf ("-->\%0.*g<--",
gtk_scale_get_digits (scale), value);
}
value
the value to format
Returns
allocated string representing value