Slider: Add tick position property and tick offset theme item

Allow ticks to be placed at the top, bottom, or center with custom offset.
This commit is contained in:
LuoZhihao
2025-06-09 12:36:08 +08:00
parent 9e02194297
commit 257c6ebe3c
6 changed files with 97 additions and 4 deletions

View File

@ -23,6 +23,9 @@
<member name="ticks_on_borders" type="bool" setter="set_ticks_on_borders" getter="get_ticks_on_borders" default="false">
If [code]true[/code], the slider will display ticks for minimum and maximum values.
</member>
<member name="ticks_position" type="int" setter="set_ticks_position" getter="get_ticks_position" enum="Slider.TickPosition" default="0">
Sets the position of the ticks. See [enum TickPosition] for details.
</member>
</members>
<signals>
<signal name="drag_ended">
@ -37,6 +40,20 @@
</description>
</signal>
</signals>
<constants>
<constant name="TICK_POSITION_BOTTOM_RIGHT" value="0" enum="TickPosition">
Places the ticks at the bottom of the [HSlider], or right of the [VSlider].
</constant>
<constant name="TICK_POSITION_TOP_LEFT" value="1" enum="TickPosition">
Places the ticks at the top of the [HSlider], or left of the [VSlider].
</constant>
<constant name="TICK_POSITION_BOTH" value="2" enum="TickPosition">
Places the ticks at the both sides of the slider.
</constant>
<constant name="TICK_POSITION_CENTER" value="3" enum="TickPosition">
Places the ticks at the center of the slider.
</constant>
</constants>
<theme_items>
<theme_item name="center_grabber" data_type="constant" type="int" default="0">
Boolean constant. If [code]1[/code], the grabber texture size will be ignored and it will fit within slider's bounds based only on its center position.
@ -44,6 +61,9 @@
<theme_item name="grabber_offset" data_type="constant" type="int" default="0">
Vertical or horizontal offset of the grabber.
</theme_item>
<theme_item name="tick_offset" data_type="constant" type="int" default="0">
Vertical or horizontal offset of the ticks. The offset is reversed for top or left ticks.
</theme_item>
<theme_item name="grabber" data_type="icon" type="Texture2D">
The texture for the grabber (the draggable element).
</theme_item>