SlideBar
Author: VesQ
        Added: 19. huhtikuuta 2012 kello 16.56
        Edited: 19. huhtikuuta 2012 kello 16.56
        Category: Käyttöliittymä
    
Description
Yksinkertainen liu'utettava sivupalkki.
    Code
Select all1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  | // ESIMERKKI
Repeat
    arvo = SlideBar( 20, 20, 200, arvo )
   
    arvo2 = SlideBarVertical( 30, 20, 200, arvo2 )
    Text 50, 50, " Arvo: "+arvo
    Text 50, 70, "Arvo2: "+arvo2
   
    DrawScreen
Forever
Function SlideBar(x, y, korkeus, arvo, _max=100)
    If MouseDown(1)
        If MouseX() >= x-5 And MouseX() <= x+15 And MouseY() >= y And MouseY() <= y+korkeus+15 Then
            arvo = Min(Max((MouseY()-y-5)*_max/korkeus, 0), _max)
        EndIf
    EndIf
    Line x, y+5, x, y+korkeus+5
    Box x-5, y + korkeus*arvo/_max, 11, 10, ON
   
    Return arvo
EndFunction
Function SlideBarVertical( x, y, leveys, arvo, _max=100 )
    If MouseDown(1)
        If MouseY() >= y-5 And MouseY() <= y+15 And MouseX() >= x And MouseX() <= x+leveys+15 Then
            arvo = Min(Max((MouseX()-x-5)*_max/leveys, 0), _max)
        EndIf
    EndIf
    Line x+5, y, x+leveys+5, y
    Box x + leveys*arvo/_max, y-5, 11, 10, ON
    Return arvo
EndFunction
 | 
Comments
No comments. You can be first!
Leave a comment
            You must be logged in to comment.