diff --git a/Internal/UI/Input.lua b/Internal/UI/Input.lua index 4948679..d698a5e 100644 --- a/Internal/UI/Input.lua +++ b/Internal/UI/Input.lua @@ -870,7 +870,7 @@ local function UpdateDrag(Instance, Step) end end -local function DrawSlider(Instance) +local function DrawSlider(Instance, DrawSliderAsHandle) if Instance ~= nil and Instance.NumbersOnly then local Value = tonumber(Instance.Text) if Value ~= nil then @@ -881,7 +881,12 @@ local function DrawSlider(Instance) local MinX, MinY = Cursor.GetPosition() local MaxX, MaxY = MinX + Instance.W - SliderSize, MinY + Instance.H local X = (MaxX - MinX) * Ratio + MinX - DrawCommands.Rectangle('fill', X, MinY + 1.0, SliderSize, Instance.H - 2.0, Style.InputSliderColor) + if DrawSliderAsHandle then + DrawCommands.Rectangle('fill', X, MinY + 1.0, SliderSize, Instance.H - 2.0, Style.InputSliderColor) + else + local Padding = 2 + DrawCommands.Rectangle('fill', MinX+Padding, MinY+Padding, Padding + (Instance.W - Padding * 3) * Ratio, Instance.H - (Padding * 2), Style.InputSliderColor) + end end end end @@ -1360,7 +1365,7 @@ function Input.Begin(Id, Options) if Options.UseSlider then if not IsEditing then - DrawSlider(Instance) + DrawSlider(Instance, Options.DrawSliderAsHandle) end end diff --git a/SlabTest.lua b/SlabTest.lua index 700a668..fec3569 100644 --- a/SlabTest.lua +++ b/SlabTest.lua @@ -410,6 +410,7 @@ local DrawInput_Basic_Numbers_Clamped_Max = 1.0 local DrawInput_Basic_Numbers_Clamped_Step = 0.01 local DrawInput_Basic_Numbers_NoDrag = 50 local DrawInput_Basic_Numbers_Slider = 50 +local DrawInput_Basic_Numbers_Slider_Handle = 50 local DrawInput_Basic_Numbers_Slider_Min = 0 local DrawInput_Basic_Numbers_Slider_Max = 100 local DrawInput_MultiLine = @@ -567,6 +568,12 @@ local function DrawInput() DrawInput_Basic_Numbers_Slider = Slab.GetInputNumber() end + Slab.NewLine() + Slab.Text("Sliders can also be drawn with a handle") + if Slab.InputNumberSlider('DrawInput_Basic_Numbers_Slider_Handle', DrawInput_Basic_Numbers_Slider_Handle, DrawInput_Basic_Numbers_Slider_Min, DrawInput_Basic_Numbers_Slider_Max, {DrawSliderAsHandle = true}) then + DrawInput_Basic_Numbers_Slider_Handle = Slab.GetInputNumber() + end + Slab.NewLine() Slab.Separator()