/* * Page Layout Demo * * David Barberi */ #include #include #include #include #include #include #include #include "colors.h" #include "/ip/vr/stream/powerglove.h" int correct_x, correct_y; int text_box_x1 = 10, text_box_x2 = 210, text_box_y1 = 750, text_box_y2 = 950, photo_box_x1 = 10, photo_box_x2 = 210, photo_box_y1 = 450, photo_box_y2 = 650; int in_text_box, in_photo_box; /***********************************************************/ main() { initilize2d(); while(!getbutton(ESCKEY)) { c3i(dark_grey); clear(); get_input(); /* either Glove or Mouse */ think(); /* decide what to do */ draw_menu(); draw_pointer(); swapbuffers(); } curson(); } /***********************************************************/ think() { if(in_text_box) { c3i(red); ezfont(500.0, 500.0, 30.0, "In text box"); } if(in_photo_box) { c3i(red); ezfont(500.0, 500.0, 30.0, "In photo box"); } } /***********************************************************/ initilize2d() { prefposition( 9, 1269, 9, 994); winopen(""); wintitle(" VR Page Layout Demo "); doublebuffer(); RGBmode(); gconfig(); cursoff(); file_id = init_glove(); } /***********************************************************/ get_input() { /* get_mouse();*/ get_glove(); } /********/ get_glove() { query_glove(file_id, &pglove); correct_x = ( ( pglove.x +127) * 5.1); correct_y = ( ( pglove.y +127) * 4); } /***********************************************************/ draw_pointer() { c3i(red); circfi( correct_x, correct_y, 10); c3i(blue); } /***********************************************************/ draw_menu() { in_text_box = draw_click_box( text_box_x1, text_box_y1, text_box_x2, text_box_y2, "TEXT"); in_photo_box = draw_click_box( photo_box_x1, photo_box_y1, photo_box_x2, photo_box_y2, "PHOTO"); } /***********************************************************/ draw_click_box(x1, y1, x2, y2, name) Icoord x1, y1, x2, y2; char name[]; { int in_box; if( (correct_x > x1) && (correct_x < x2) && (correct_y > y1) && (correct_y < y2) ) { c3i(yellow); in_box = 1; } else { c3i(dark_blue); in_box = 0; } rectfi(x1,y1,x2,y2); c3i(light_grey); rectfi( (x1+9), (y1+9), (x2-9), (y2-9) ); c3i(black); linewidth(6); ezfont( (float)(x1+25), (float)(y1+90), 30.0, name); return( in_box ); } /************************************************************/ get_mouse() { correct_x = getvaluator(MOUSEX); correct_y = getvaluator(MOUSEY); }