Add background image to library
Create page style using background image
Create a draw style for slider background
Create a draw style for slider
Create a style for key press
Create a style for key release
Create a style for text
Create variable for Slide Status
Create variables for calcualtions (VH1,VH2) and Value
Define a page named "pageName" with style "pageStyle"
Create a box for slider box background
Create a box for slider
Create a box for slider end
Create down key for slider that sets Slide status to 1
Create release key for slider that sets slide status to 0
Create text entity to display Value variable
Create page loop that runs forever
Check status of SLideV if it equals 1 run SlideB1 function
Create SlideB1 function
Load TOUCHX value into VH1
Check VH1 doesnt go below left of box
Check VH1 doesnt go over right of box
Take 40 off the VH1 value to calibrate value so 0 is origin of slide bar
Add 38 to the calibrated VH1 value into VH2
position the slider end to the VH2 value
Divide the VH1 number by 4 to give a value betwwen 0-100 into Value
Load the Value into text entity
Draw the slider with the length of VH1
Refresh page
After loading show the page named "pageName"
|
LIB(background,"SDHC/bground.png");
STYLE(pageStyle, Page) { image = background; }
STYLE(dSt,Draw) {type=B;col=red;back=white;width=2;curRel=TL;}
STYLE(dSt2,Draw) {type=B;col=red;back=\\80ff0000;width=2;curRel=TL; maxX=410;maxY=30;}
STYLE(keyStD, key) {type=touch;action=D;delay=0;curRel=TL;}
STYLE(keyStU, key) {type=touch;action=U;delay=0;curRel=TL;}
STYLE(textStyle,Text) {font=Ascii32;col=Red;}
VAR(SlideV,0,U8); VAR(VH1,0,U16);
VAR(VH2,0,U16); VAR(Value,0,U8);
PAGE(pageName, pageStyle)
{
DRAW(id1,400,30,dSt,40,130);
DRAW(id2,0,30,dSt2,40,130);
DRAW(id3,4,40,dSt2,40,125);
KEY(keyD,[LOAD(SlideV,1);],400,40,keyStD,40,125);
KEY(keyU,[LOAD(SlideV,0);],480,272,keyStU,0,0);
TEXT(ValueText,Value,textStyle,240,190);
LOOP(Loop1,FOREVER)
{
IF(SlideV=1?SlideB1);
}
}
FUNC(SlideB1)
{
LOAD(VH1,TOUCHX);
IF(VH1<40?[LOAD(VH1,40);]);
IF(VH1>440?[LOAD(VH1,440);]);
CALC(VH1,VH1,40,"-");
CALC(VH2,VH1,38,"+");
POSN(VH2,125,id3);
CALC(Value,VH1,4,"/");
TEXT(ValueText,Value);
DRAW(id2,VH1,30);;
}
SHOW(pageName);
|