Class: Gtk::Scale

Inherits:
Range
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Methods inherited from Range

#adjustment, #adjustment=, #fill_level, #fill_level=, #flippable, #flippable=, #get_range_rect, #get_slider_range, #inverted, #inverted=, #inverted?, #restrict_to_fill_level, #restrict_to_fill_level=, #restrict_to_fill_level?, #round_digits, #round_digits=, #set_increments, #set_range, #show_fill_level, #show_fill_level=, #show_fill_level?, #slider_size_fixed, #slider_size_fixed=, #value, #value=

Methods inherited from Widget

#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_events, #add_events_raw, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #drag_dest_set, #drag_dest_set_raw, #drag_source_set, #drag_source_set_raw, #error_bell, #events, #events_raw, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, have_template?, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_action_group_raw, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #render_icon_pixbuf, #render_icon_pixbuf_raw, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_allocation, set_connect_func, set_connect_func_raw, #set_events, #set_events_raw, #set_size_request, #set_size_request_raw, #set_state_flags, #set_template, #set_template_raw, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #style_context_raw, #style_get_property, #style_get_property_raw, #template=, template_children, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #translate_coordinates_raw, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=

Constructor Details

#initialize(orientation, min, max, step) ⇒ Gtk::Widget

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 [methodGtk.Scale.set_digits] to correct it.

Parameters:

  • orientation (Gtk::Orientation)

    the scale’s orientation.

  • min (Float)

    minimum value

  • max (Float)

    maximum value

  • step (Float)

    step increment (tick size) used with keyboard shortcuts

Instance Method Details

#add_mark(value, position, markup) ⇒ nil

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 nil, text is shown next to the tick mark.

To remove marks from a scale, use [methodGtk.Scale.clear_marks].

Parameters:

  • value (Float)

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

  • position (Gtk::PositionType)

    where to draw the mark. For a horizontal scale, %GTK_POS_TOP and %GTK_POS_LEFT are drawn above the scale, anything else below. For a vertical scale, %GTK_POS_LEFT and %GTK_POS_TOP are drawn to the left of the scale, anything else to the right.

  • markup (String)

    Text to be shown at the mark, using Pango markup

Returns:

  • (nil)

#clear_marksnil

Removes any marks that have been added.

Returns:

  • (nil)

#digitsInteger

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

Returns:

  • (Integer)

    digits

#digits=(digits) ⇒ Integer

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

Parameters:

  • digits (Integer)

Returns:

  • (Integer)

    digits

  • (Integer)

    digits

#draw_valueBoolean

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

Returns:

  • (Boolean)

    whether the current value is displayed as a string

#draw_value=(draw_value) ⇒ Boolean

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

Parameters:

  • draw_value (Boolean)

Returns:

  • (Boolean)

    draw-value

  • (Boolean)

    draw-value

#draw_value?Boolean

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

Returns:

  • (Boolean)

    draw-value

#get_layout_offsets(x, y) ⇒ nil

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 [propertyGtk.Scale:draw-value] property is false, the return values are undefined.

Parameters:

  • x (Integer)

    location to store X offset of layout

  • y (Integer)

    location to store Y offset of layout

Returns:

  • (nil)

#has_originBoolean

Returns whether the scale has an origin.

Returns:

  • (Boolean)

    true if the scale has an origin.

#has_origin=(has_origin) ⇒ Boolean

Whether the scale has an origin.

Parameters:

  • has_origin (Boolean)

Returns:

  • (Boolean)

    has-origin

  • (Boolean)

    has-origin

#has_origin?Boolean

Whether the scale has an origin.

Returns:

  • (Boolean)

    has-origin

#layoutPango::Layout

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.

Returns:

  • (Pango::Layout)

    the [classPango.Layout] for this scale, or nil if the [propertyGtk.Scale:draw-value] property is false.

#set_format_value_func(func, user_data, destroy_notify) ⇒ nil

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 [propertyGtk.Scale:digits] property.

Parameters:

  • func (Gtk::ScaleFormatValueFunc)

    function that formats the value

  • user_data (GObject)

    user data to pass to func

  • destroy_notify (GLib::DestroyNotify)

    destroy function for user_data

Returns:

  • (nil)

#value_posGtk::PositionType

The position in which the current value is displayed.

Returns:

#value_pos=(value_pos) ⇒ Gtk::PositionType

The position in which the current value is displayed.

Parameters:

Returns: