//Menu file TU480A.MNU for showing touch position /////////// //Setup// ////////// SETUP(system ){touchsamples = 25; touchdebounce = 5; touchaccuracy = 50;} //set up the system for a better touch interface ////////// //Files// ///////// LIB(img1,"SDHC/cageele.bmp"); //Load cageele image LIB(img2,"SDHC/drdre.bmp"); //Load drdre image LIB(img3,"SDHC/gbara.bmp"); //Load gbara image LIB(img4,"SDHC/gbbks.bmp"); //Load gbbks image LIB(img5,"SDHC/goulding.bmp"); //Load goulding image LIB(img6,"SDHC/jessie.bmp"); //Load jessie image LIB(img7,"SDHC/jlopez.bmp"); //Load jlopez image LIB(img8,"SDHC/katyb.bmp"); //Load katyb image LIB(img9,"SDHC/kingleon.bmp"); //Load kingleon image LIB(img10,"SDHC/nicole.bmp"); //Load nicole image LIB(img11,"SDHC/pink.bmp"); //Load pink image LIB(img12,"SDHC/rihanna.bmp"); //Load rihanna image LIB(img13,"SDHC/usum.bmp"); //Load usum image LIB(img14,"SDHC/blackeye.bmp"); //Load blackeye image LIB(fntasc16,"SDHC/asc_16b.fnt"); //Load asc 16 font /////////// //Styles// /////////// STYLE(sTimg, Image) {curRel = CC;} //create a style for the images STYLE(pagestyle, Page) {back = lightblue;} //create a style for the main page STYLE(sTkeyU, key) {type=touch; action=U; delay=0;} //create a style with an UP touch(released) event STYLE(sTkeyD, key) {type=touch; action=D; delay=0;} //create a style with a DOWN touch(pressed) event STYLE(stText, text) {font=fntasc16;col=black;curRel=RC;} //create a style for the alignment text STYLE(HText, text) {font=fntasc16;col=black;curRel=RC;} //create a style for title text STYLE(sCircler,DRAW) {type=C; col=Red; width=1; back=Red; maxX=20; maxY=20; rotate=0; curRel=CC;} //create a style for the alignment indicator circle STYLE(sCircleb,DRAW) {type=C; col=black; width=1; back=Black; maxX=10; maxY=10; rotate=0; curRel=CC;} //create a style for the alignment indicator circle /////////////// //Variables// /////////////// VAR(keyD,0,U8); //create an unsigned 8 bit variable to hold which image should be moved VAR(timg>"",PTR); //create a pointer variable to display the image selected VAR(tku>"",PTR); //create a pointer variable to select the correct touch event VAR(tkd>"",PTR); //create a pointer variable to select the correct touch style VAR(align,0,U8); //create an unsigned 8 bit variable to determine alignment status VAR(ty,0,U16); //create an unsigned 16 bit variable to hold the image's Y coordinate /////////////// //Functions// /////////////// FUNC(keyfnc) //display images on the bottom left corner which can be dragged { LOAD(timg>"imgA",keyD); //use the image pointer to load the image LOAD(tku>"keyU",keyD); //use the touch up pointer to load the keyD=0, dont move the image LOAD(tkd>"keyD",keyD); //use the touch down pointer to load appropriate keyD value, move the image IF(align=0?[LOAD(ty,TOUCHY);]:[LOAD(ty,200);]); //if alignment is free then load the last known Y coordinate to ty otherwise load 200 POSN(TOUCHX,ty,timg); //place the position of the image to (TOUCHX,ty(new)) POSN(TOUCHX,ty,tku); //place the position of the touch up event to (TOUCHX,ty(new)) POSN(TOUCHX,ty,tkd);; //place the position of the touch down event to (TOUCHX,ty(new)) } FUNC(switchalign) //indicate alignment status { IF(align=1?[SHOW(abcircle);HIDE(bbcircle);]:[SHOW(bbcircle);HIDE(abcircle);]);; //show appropriate alignment indicators } ////////// //Page// ///////// PAGE(MainPage, pagestyle) //set up the contents of the Main page { POSN(58,24); TEXT(atxt,"ALIGN",stText); //set the position and create the static words "ALIGN" POSN(42,24); KEY(alignkey,[LOAD(align,1);RUN(switchalign);],80,40,TOUCH); //set the position and create the align touch area POSN(70,25); DRAW(acircle, 16, 16, sCircler); DRAW(abcircle, 8, 8, sCircleb); //set the position and create the align indicator POSN(58,74); TEXT(btxt,"FREE",stText); //set the position and create the static words "FREE" POSN(42,74); KEY(freekey,[LOAD(align,0);RUN(switchalign);],80,40,TOUCH); //set the position and create the free alignment touch area POSN(70,75); DRAW(bcircle, 16, 16, sCircler); DRAW(bbcircle, 8, 8, sCircleb); //set the position and create the free alignment indicator POSN(310,15); TEXT(Ttxt,"Drag & Drop Demo",HText); //set the position and create the static words "Drag & Drop Demo" //set the position of the images, when touch area is pressed and when released load the associated number to KeyD POSN(40,200); IMG(imgA1,img1,sTimg); //create the image for cageele KEY(keyD1,[LOAD(keyD,1);],75,75,sTkeyD); //set keyD=1, cageele.bmp KEY(keyU1,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA2,img2,sTimg); //create the image for drdre KEY(keyD2,[LOAD(keyD,2);],75,75,sTkeyD); //set keyD=2, drdre.bmp KEY(keyU2,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA3,img3,sTimg); //create the image for gbara KEY(keyD3,[LOAD(keyD,3);],75,75,sTkeyD); //set keyD=3 KEY(keyU3,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA4,img4,sTimg); //create the image for gbbks KEY(keyD4,[LOAD(keyD,4);],75,75,sTkeyD); //set keyD=4 KEY(keyU4,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA5,img5,sTimg); //create the image for goulding KEY(keyD5,[LOAD(keyD,5);],75,75,sTkeyD); //set keyD=5 KEY(keyU5,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA6,img6,sTimg); //create the image for jessie KEY(keyD6,[LOAD(keyD,6);],75,75,sTkeyD); //set keyD=6 KEY(keyU6,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA7,img7,sTimg); //create the image for jlopez KEY(keyD7,[LOAD(keyD,7);],75,75,sTkeyD); //set keyD=7 KEY(keyU7,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA8,img8,sTimg); //create the image for katyb KEY(keyD8,[LOAD(keyD,8);],75,75,sTkeyD); //set keyD=8 KEY(keyU8,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA9,img9,sTimg); //create the image for kingleon KEY(keyD9,[LOAD(keyD,9);],75,75,sTkeyD); //set keyD=9 KEY(keyU9,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA10,img10,sTimg); //create the image for nicole KEY(keyD10,[LOAD(keyD,10);],75,75,sTkeyD); //set keyD=10 KEY(keyU10,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA11,img11,sTimg); //create the image for pink KEY(keyD11,[LOAD(keyD,11);],75,75,sTkeyD); //set keyD=11 KEY(keyU11,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA12,img12,sTimg); //create the image for rihanna KEY(keyD12,[LOAD(keyD,12);],75,75,sTkeyD); //set keyD=12 KEY(keyU12,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA13,img13,sTimg); //create the image for usum KEY(keyD13,[LOAD(keyD,13);],75,75,sTkeyD); //set keyD=13 KEY(keyU13,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 IMG(imgA14,img14,sTimg); //create the image for blackeye KEY(keyD14,[LOAD(keyD,14);],75,75,sTkeyD); //set keyD=14 KEY(keyU14,[LOAD(keyD,0);],75,75,sTkeyU); //set keyD=0 LOOP(keymove,forever) //enable the images to be dragged across the screen { IF(keyD<>0?keyfnc); //if the image has been touched then move it to the new x,y coordinates } } HIDE(abcircle); //set the default to free alignment SHOW(MainPage); //show the main page