
#compact
$ filename "t.exe"
'uses rtl32
'uses rtl64
uses ../GDIWindow/window



Window "Slider Controls",400,300,2

sys sxMouse,syMouse

class Slider
  '
  sys px,py,sx,sy     'position and sensing-size
  sys lx1,lx2,ly1,ly2 'limits of movement
  sys spx,spy
  '
  method pos() as sys
  if MouseButton=1 then
    if xMouse>=lx1-sx and xMouse<=lx2+sx then
    if yMouse>=ly1-sy and yMouse<=ly2+sy then
      px=spx+xMouse-sxMouse : py=spy+yMouse-syMouse
      if px<lx1 then px=lx1
      if px>lx2 then px=lx2
      if py<ly1 then py=ly1
      if py>ly2 then py=ly2
    end if
    end if
  elseif MouseButton=0 then
    spx=px
    spy=py
  end if
  end method
  '
  method show() as sys
  Line lx1,ly1,lx2,ly2,4,200,200,200
  Oval px-sx, py-sy, sx*2, sy*2, 255,0,200
  end method
  '
  method fvalue() as single
  if lx1<lx2 then return (px-lx1)/(lx2-lx1)
  if ly1<ly2 then return (py-ly1)/(ly2-ly1)
  end method
  '
  method bvalue() as sys
  if lx1<lx2 then return 255*(px-lx1)/(lx2-lx1)
  if ly1<ly2 then return 255*(py-ly1)/(ly2-ly1)
  end method
  '
end class

'HORIZONTAL SLIDERS

Slider c1<=(100,100,10,15,50,150,100,100)
Slider c2<=(100,150,10,15,50,150,150,150)
Slider c3<=(100,200,10,15,50,150,200,200)

'VERTICAL SLIDERS

Slider c4<=(200,150,15,10,200,200,100,200)
Slider c5<=(250,150,15,10,250,250,100,200)
Slider c6<=(300,150,15,10,300,300,100,200)

sys a

While AscKey=0 and WinExit=0
ClsColor c1.bvalue,c2.bvalue,c3.bvalue
if mouseButton=0 then
  sxMouse=xMouse
  syMouse=yMouse
end if
c1.pos : c1.show
c2.pos : c2.show
c3.pos : c3.show
c4.pos : c4.show
c5.pos : c5.show
c6.pos : c6.show
FlipBuffer
WaitFPS 60
Wend
