Trait gtk4::prelude::ScaleExt

source ·
pub trait ScaleExt: 'static {
Show 17 methods // Required 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_format_value_func<P: Fn(&Scale, f64) -> String + 'static>( &self, func: P ); fn set_has_origin(&self, has_origin: bool); fn set_value_pos(&self, pos: PositionType); 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

Trait containing all Scale methods.

Implementors

Scale

Required Methods§

source

fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>)

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

source

fn clear_marks(&self)

Removes any marks that have been added.

source

fn digits(&self) -> i32

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

Returns

the number of decimal places that are displayed

source

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

source

fn has_origin(&self) -> bool

Returns whether the scale has an origin.

Returns

true if the scale has an origin.

source

fn layout(&self) -> Option<Layout>

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 [draw-value][struct@crate::GtkScale#draw-value] property is false.

source

fn layout_offsets(&self) -> (i32, i32)

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 [draw-value][struct@crate::GtkScale#draw-value] property is false, the return values are undefined.

Returns
x

location to store X offset of layout

y

location to store Y offset of layout

source

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

source

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 [draw-value][struct@crate::GtkScale#draw-value] is true when the value changes. If you want to enforce rounding the value when [draw-value][struct@crate::GtkScale#draw-value] is false, you can set [round-digits][struct@crate::GtkRange#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 set_format_value_func() 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

source

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

source

fn set_format_value_func<P: Fn(&Scale, f64) -> String + 'static>(&self, func: P)

@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 [digits][struct@crate::GtkScale#digits] property.

func

function that formats the value

destroy_notify

destroy function for @user_data

source

fn set_has_origin(&self, has_origin: bool)

Sets whether the scale has an origin.

If [has-origin][struct@crate::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.

has_origin

true if the scale has an origin

source

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

source

fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_draw_value_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_has_origin_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_value_pos_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Implementors§

source§

impl<O: IsA<Scale>> ScaleExt for O