diff --git a/include/ui.bm b/include/ui.bm index be4ddc7..4240564 100644 --- a/include/ui.bm +++ b/include/ui.bm @@ -56,7 +56,7 @@ function textinput$ (x as integer,y as integer,w as integer,h as integer,__text if cursor<1 then cursor=1 if cursor>len(text)+1 then cursor=len(text)+1 else - done=-1 ' Clicked outside, exit focus + done=-1 end if end if drawtextinput x,y,w,h,text,cursor @@ -162,6 +162,22 @@ function link(x,y,label as string) end if end function +function slider(x as long, y as long, w as long, value as single) + dim tmpval as single + tmpval = value + if _mousex > x and _mousey > y - 5 and _mousex < x + w and _mousey < y + 15 then + drawslider x, y, w, value, 1 + if _mousebutton(1) then + tmpval = ((_mousex - x) / w) * 100 + end if + else + drawslider x, y, w, value, 0 + end if + if tmpval < 0 then tmpval = 0 + if tmpval > 100 then tmpval = 100 + slider = tmpval +end function + function vscrollbar(x as long,y as long,h as long,value as single) dim tmpval as single tmpval=value @@ -278,6 +294,23 @@ sub drawhline(x,y,w) line (x,y+1)-(x+w,y+1),backgroundcolor2 end sub +sub drawslider(x as long, y as long, w as long, value as single, state as integer) + dim handleX as long + handleX = x + (w * (value / 100)) + color backgroundcolor1 + line (x, y + 4)-(x + w, y + 6), , bf + if state = 1 then color highlightcolor else color textcolor + line (x, y + 4)-(x + w, y + 6), , b + if state = 1 then + color highlightcolor + else + color textcolor + end if + line (handleX - 5, y - 2)-(handleX + 5, y + 12), , bf + color backgroundcolor1 + line (handleX - 5, y - 2)-(handleX + 5, y + 12), , b +end sub + sub drawvbar(x as long,y as long,h as long,value as single, state as integer) if state and 2 then color backgroundcolor2