UI.Slider
From GiderosMobile
Available since: Gideros 2023.1
Class: UI
Description
Creates Slider widgets. The widget can be a Slider, or an ArcSlider. Sliders give value from 0 to 1.
UI.Slider.new(direction,svgpath,resolution,dual,offset)
UI.ArcSlider.new(astart,aend,resolution,dual,offset)
Parameters
direction: (bool) is the Slider widget vertical default = true
svgpath: (string) the Slider widget svg path
resolution: (number) the Slider widget step increment
dual: (bool) has the Slider widget two knobs default = false
offset: (number) the Slider widget knob offset
astart: (number) the Slider widget start angle value
aend: (number) the Slider widget end angle value
Examples
A Slider
local gui = UI.Slider.new(false, nil, 0.25, true)
gui:setDimensions(256, 32)
--gui:setVertical(false)
gui:setColor(0xaa0000)
gui:setPosition(50, 50)
--gui:setResolution(0.25)
gui:setCenter(0.25)
gui:setKnobPosition(0.25)
stage:addChild(gui)
An ArcSlider
local gui = UI.ArcSlider.new(5, 60, 0.1, true, 0.1)
gui:setDimensions(128, 128)
--gui:setVertical(false)
gui:setColor(0xaa0000)
gui:setPosition(50, 50)
--gui:setResolution(0.25)
--gui:setCenter(0.25)
--gui:setKnobPosition(0.25)
stage:addChild(gui)
onWidgetChange
--Sliders give value from 0 to 1
local sliderA=UI.Slider.new()
sliderA:setDimensions(200,50)
sliderA:setPosition(250,50)
sliderA.name="Slider A"
local sliderB=UI.Slider.new()
sliderB:setDimensions(200,50)
sliderB:setPosition(250,150)
--This slider center is in the middle of the range
sliderB:setCenter(.5)
--Initial value is .6
sliderB:setKnobPosition(.6)
--Discrete steps of .1
sliderB:setResolution(.1)
sliderB.name="Slider B"
stage:addChild(sliderA)
stage:addChild(sliderB)
--Here we put the WidgetAction listener on stage.
--It will be propagated from each button up to stage through the sprite tree
--First parameter of event listeners are always the source widget of the event
function stage:onWidgetChange(w,v)
print(w.name.." value is "..v)
end