Class SliderWidget

java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.SliderWidget

public class SliderWidget extends Widget
Represents a slider widget that allows the user to select a value by dragging a thumb along a bar. The widget can be customized in terms of appearance and behavior.
  • Constructor Details

    • SliderWidget

      public SliderWidget(int x, int y, int width, Consumer<Integer> onSlideAction)
      Constructs a new SliderWidget with the specified position, width, and slide action callback.
      Parameters:
      x - the x-coordinate of the widget's position
      y - the y-coordinate of the widget's position
      width - the width of the widget
      onSlideAction - a callback function to be executed when the slider value changes
  • Method Details

    • setOnSlideAction

      public final void setOnSlideAction(Consumer<Integer> onSlideAction)
      Sets the callback function to be executed when the slider value changes.
      Parameters:
      onSlideAction - a callback function to be executed when the slider value changes
    • getFontName

      public final String getFontName()
      Returns the name of the font used for text rendering.
      Returns:
      the font name
    • setFontName

      public final void setFontName(String fontName)
      Sets the name of the font used for text rendering.
      Parameters:
      fontName - the font name
    • getMaxValue

      public final int getMaxValue()
      Returns the maximum value of the slider.
      Returns:
      the maximum value
    • setMaxValue

      public final void setMaxValue(int maxValue)
      Sets the maximum value of the slider.
      Parameters:
      maxValue - the maximum value
    • getMinValue

      public final int getMinValue()
      Returns the minimum value of the slider.
      Returns:
      the minimum value
    • setMinValue

      public final void setMinValue(int minValue)
      Sets the minimum value of the slider.
      Parameters:
      minValue - the minimum value
    • getValue

      public final int getValue()
      Gets the current value of the widget.
      Returns:
      the current value
    • setValue

      public final void setValue(int value)
      Sets the value of the widget.
      Parameters:
      value - the new value to be set
    • getFontSize

      public final int getFontSize()
      Gets the font size used in the widget.
      Returns:
      the font size
    • setFontSize

      public final void setFontSize(int fontSize)
      Sets the font size for the widget.
      Parameters:
      fontSize - the new font size
    • getBarHeight

      public final int getBarHeight()
      Gets the height of the bar in the widget.
      Returns:
      the bar height
    • setBarHeight

      public final void setBarHeight(int barHeight)
      Sets the height of the bar in the widget.
      Parameters:
      barHeight - the new bar height
    • getTextOffset

      public final int getTextOffset()
      Gets the text offset used in rendering the widget.
      Returns:
      the text offset
    • setTextOffset

      public final void setTextOffset(int textOffset)
      Sets the text offset for the widget.
      Parameters:
      textOffset - the new text offset
    • getBorderRadius

      public final int getBorderRadius()
      Gets the border radius of the widget.
      Returns:
      the border radius
    • setBorderRadius

      public final void setBorderRadius(int borderRadius)
      Sets the border radius for the widget.
      Parameters:
      borderRadius - the new border radius
    • getBarFillOffset

      public final int getBarFillOffset()
      Gets the offset for the bar fill in the widget.
      Returns:
      the bar fill offset
    • setBarFillOffset

      public final void setBarFillOffset(int barFillOffset)
      Sets the offset for the bar fill in the widget.
      Parameters:
      barFillOffset - the new bar fill offset
    • getThumbWidth

      public final int getThumbWidth()
      Gets the width of the thumb in the widget.
      Returns:
      the thumb width
    • setThumbWidth

      public final void setThumbWidth(int thumbWidth)
      Sets the width of the thumb in the widget.
      Parameters:
      thumbWidth - the new thumb width
    • getAccentColor

      public final NanoColor getAccentColor()
      Gets the accent color used in the widget.
      Returns:
      the accent color
    • setAccentColor

      public final void setAccentColor(NanoColor accentColor)
      Sets the accent color for the widget.
      Parameters:
      accentColor - the new accent color
    • getBarColor

      public final NanoColor getBarColor()
      Gets the bar color used in the widget.
      Returns:
      the bar color
    • setBarColor

      public final void setBarColor(NanoColor barColor)
      Sets the bar color for the widget.
      Parameters:
      barColor - the new bar color
    • isEnable

      public final boolean isEnable()
      Checks if the widget is enabled.
      Returns:
      true if the widget is enabled, false otherwise
    • setEnable

      public final void setEnable(boolean enable)
      Sets the enabled state of the widget.
      Parameters:
      enable - true to enable the widget, false to disable it
    • onLeftMouseDown

      public void onLeftMouseDown(int x, int y)
      Called when the left mouse button is pressed down over the Widget.
      Overrides:
      onLeftMouseDown in class Widget
      Parameters:
      x - relative x-coordinate of the mouse position
      y - relative y-coordinate of the mouse position
    • update

      public void update()
      Updates the Widget
      Overrides:
      update in class Widget
    • render

      public void render()
      Renders the Widget
      Specified by:
      render in class Widget