Class ScaleButton

All Implemented Interfaces:
Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable, Proxy
Direct Known Subclasses:
VolumeButton

@Generated("org.javagi.JavaGI") public class ScaleButton extends Widget implements Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable

Provides a button which pops up a scale widget.

This kind of widget is commonly used for volume controls in multimedia applications, and GTK provides a VolumeButton subclass that is tailored for this use case.

Shortcuts and Gestures

The following signals have default keybindings:

  • Gtk.ScaleButton::popup

CSS nodes

scalebutton.scale
╰── button.toggle
    ╰── <icon>

GtkScaleButton has a single CSS node with name scalebutton and .scale style class, and contains a button node with a .toggle style class.

  • Constructor Details

    • ScaleButton

      public ScaleButton(MemorySegment address)
      Create a ScaleButton instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ScaleButton

      public ScaleButton(double min, double max, double step, @Nullable String @Nullable [] icons)

      Creates a GtkScaleButton.

      The new scale button has a range between min and max, with a stepping of step.

      Parameters:
      min - the minimum value of the scale (usually 0)
      max - the maximum value of the scale (usually 100)
      step - the stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2)
      icons - a null-terminated array of icon names, or null if you want to set the list later with gtk_scale_button_set_icons()
    • ScaleButton

      public ScaleButton()
      Create a new ScaleButton.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ScaleButton class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ScaleButton asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getActive

      public boolean getActive()

      Queries a GtkScaleButton and returns its current state.

      Returns true if the scale button is pressed in and false if it is raised.

      Returns:
      whether the button is pressed
      Since:
      4.10
    • getAdjustment

      public Adjustment getAdjustment()

      Gets the GtkAdjustment associated with the GtkScaleButton’s scale.

      See Range.getAdjustment() for details.

      Returns:
      the adjustment associated with the scale
    • getHasFrame

      public boolean getHasFrame()
      Returns whether the button has a frame.
      Returns:
      true if the button has a frame
      Since:
      4.14
    • getMinusButton

      public Button getMinusButton()
      Retrieves the minus button of the GtkScaleButton.
      Returns:
      the minus button of the GtkScaleButton
    • getPlusButton

      public Button getPlusButton()
      Retrieves the plus button of the GtkScaleButton.
      Returns:
      the plus button of the GtkScaleButton
    • getPopup

      public Widget getPopup()
      Retrieves the popup of the GtkScaleButton.
      Returns:
      the popup of the GtkScaleButton
    • getValue

      public double getValue()
      Gets the current value of the scale button.
      Returns:
      current value of the scale button
    • setAdjustment

      public void setAdjustment(Adjustment adjustment)

      Sets the GtkAdjustment to be used as a model for the GtkScaleButton’s scale.

      See Range.setAdjustment(Adjustment) for details.

      Parameters:
      adjustment - a GtkAdjustment
    • setHasFrame

      public void setHasFrame(boolean hasFrame)
      Sets the style of the button.
      Parameters:
      hasFrame - whether the button should have a visible frame
      Since:
      4.14
    • setIcons

      public void setIcons(@Nullable String @Nullable [] icons)
      Sets the icons to be used by the scale button.
      Parameters:
      icons - a null-terminated array of icon names
    • setValue

      public void setValue(double value)

      Sets the current value of the scale.

      If the value is outside the minimum or maximum range values, it will be clamped to fit inside them.

      The scale button emits the Gtk.ScaleButton::value-changed signal if the value changes.

      Parameters:
      value - new value of the scale button
    • valueChanged

      protected void valueChanged(double value)
    • onPopdown

      Emitted to dismiss the popup.

      This is a keybinding signal.

      The default binding for this signal is Escape.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitPopdown

      public void emitPopdown()
      Emits the "popdown" signal. See onPopdown(ScaleButton.PopdownCallback).
    • onPopup

      Emitted to popup the scale widget.

      This is a keybinding signal.

      The default bindings for this signal are Space, Enter and Return.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitPopup

      public void emitPopup()
      Emits the "popup" signal. See onPopup(ScaleButton.PopupCallback).
    • onValueChanged

      Emitted when the value field has changed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitValueChanged

      public void emitValueChanged(double value)
      Emits the "value-changed" signal. See onValueChanged(ScaleButton.ValueChangedCallback).
    • builder

      public static ScaleButton.Builder<? extends ScaleButton.Builder> builder()
      A ScaleButton.Builder object constructs a ScaleButton with the specified properties. Use the various set...() methods to set properties, and finish construction with ScaleButton.Builder.build().
      Returns:
      the builder object