Package com.avrix.ui.widgets
Class SliderWidget
java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.SliderWidget
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.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSliderWidget
(int x, int y, int width, Consumer<Integer> onSlideAction) Constructs a new SliderWidget with the specified position, width, and slide action callback. -
Method Summary
Modifier and TypeMethodDescriptionfinal NanoColor
Gets the accent color used in the widget.final NanoColor
Gets the bar color used in the widget.final int
Gets the offset for the bar fill in the widget.final int
Gets the height of the bar in the widget.final int
Gets the border radius of the widget.final String
Returns the name of the font used for text rendering.final int
Gets the font size used in the widget.final int
Returns the maximum value of the slider.final int
Returns the minimum value of the slider.final int
Gets the text offset used in rendering the widget.final int
Gets the width of the thumb in the widget.final int
getValue()
Gets the current value of the widget.final boolean
isEnable()
Checks if the widget is enabled.void
onLeftMouseDown
(int x, int y) Called when the left mouse button is pressed down over theWidget
.void
render()
Renders theWidget
final void
setAccentColor
(NanoColor accentColor) Sets the accent color for the widget.final void
setBarColor
(NanoColor barColor) Sets the bar color for the widget.final void
setBarFillOffset
(int barFillOffset) Sets the offset for the bar fill in the widget.final void
setBarHeight
(int barHeight) Sets the height of the bar in the widget.final void
setBorderRadius
(int borderRadius) Sets the border radius for the widget.final void
setEnable
(boolean enable) Sets the enabled state of the widget.final void
setFontName
(String fontName) Sets the name of the font used for text rendering.final void
setFontSize
(int fontSize) Sets the font size for the widget.final void
setMaxValue
(int maxValue) Sets the maximum value of the slider.final void
setMinValue
(int minValue) Sets the minimum value of the slider.final void
setOnSlideAction
(Consumer<Integer> onSlideAction) Sets the callback function to be executed when the slider value changes.final void
setTextOffset
(int textOffset) Sets the text offset for the widget.final void
setThumbWidth
(int thumbWidth) Sets the width of the thumb in the widget.final void
setValue
(int value) Sets the value of the widget.void
update()
Updates theWidget
Methods inherited from class com.avrix.ui.widgets.Widget
addChild, addToScreen, bringToTop, drawArc, drawArc, drawCircle, drawEllipse, drawImage, drawLine, drawRect, drawRectOutline, drawRoundedRect, drawRoundedRectOutline, drawText, getAbsoluteParent, getChildren, getHeight, getMaxScrollX, getMaxScrollY, getParent, getScrollSpeed, getScrollX, getScrollY, getWidth, getX, getXA, getY, getYA, intersectScissor, isAlwaysOnTop, isHovered, isPointOver, isScrollable, isScrollLock, isVisible, isVisibleWithinParent, isVisibleWithinWindow, onInitialize, onKeyPress, onKeyRelease, onKeyRepeat, onLeftMouseDownOutside, onLeftMouseUp, onLeftMouseUpOutside, onMouseEnter, onMouseExit, onMouseMove, onMouseMoveOutside, onMouseWheel, onRightMouseDown, onRightMouseDownOutside, onRightMouseUp, onRightMouseUpOutside, postRender, preRender, removeChild, removeFromScreen, renderChildren, setAlwaysOnTop, setHeight, setMaxScrollX, setMaxScrollY, setScrollable, setScrollLock, setScrollSpeed, setScrollX, setScrollY, setVisible, setWidth, setX, setXA, setY, setYA
-
Constructor Details
-
SliderWidget
Constructs a new SliderWidget with the specified position, width, and slide action callback.- Parameters:
x
- the x-coordinate of the widget's positiony
- the y-coordinate of the widget's positionwidth
- the width of the widgetonSlideAction
- a callback function to be executed when the slider value changes
-
-
Method Details
-
setOnSlideAction
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
Returns the name of the font used for text rendering.- Returns:
- the font name
-
setFontName
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
Gets the accent color used in the widget.- Returns:
- the accent color
-
setAccentColor
Sets the accent color for the widget.- Parameters:
accentColor
- the new accent color
-
getBarColor
Gets the bar color used in the widget.- Returns:
- the bar color
-
setBarColor
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 theWidget
.- Overrides:
onLeftMouseDown
in classWidget
- Parameters:
x
- relative x-coordinate of the mouse positiony
- relative y-coordinate of the mouse position
-
update
public void update()Updates theWidget
-
render
public void render()Renders theWidget
-