Moving MAUI Buttons and What's Up with MAUI Porting?
Hi ChucK friends, I made a ChucK file with MAUI that demonstrates moving a button on the view panel with the mouse. The source code follows: // experiment with mouse moving a button in MAUI // copyright 2008 Les Hall // This software is protected by the GNU General Public License // set up the view panel 400 => int x_max; 400 => int y_max; 1280 => int screen_width; 960 => int screen_height; MAUI_View mouse_view; mouse_view.size (x_max, y_max); mouse_view.position (screen_width/2 - x_max/2, screen_height/2 - y_max/2); mouse_view.name ("Click and drag the square button!"); mouse_view.display (); // create the button 200 => int x_pos; 200 => int y_pos; 60 => int button_size; MAUI_Button mouse_button; mouse_button.toggleType (); mouse_button.size (button_size, button_size); mouse_button.position (x_pos - button_size/2, y_pos - button_size/2); mouse_button.name (""); mouse_view.addElement (mouse_button); // create a dummy button MAUI_Button mouse_button2; mouse_button2.toggleType (); mouse_button2.size (x_max, button_size); mouse_button2.position (0, 0); mouse_button2.name ("Experiment with moving buttons"); mouse_view.addElement (mouse_button2); 0 => int device; Hid hid; HidMsg hidmsg; if (!hid.openMouse (device)) me.exit(); 0 =>int move_mouse; // infinite time loop while (true) { // wait on event hid => now; // loop over messages while (hid.recv (hidmsg)) { if (hidmsg.isButtonDown()) { 1 => move_mouse; } if (hidmsg.isButtonUp ()) { 0 => move_mouse; } if( hidmsg.isMouseMotion() ) { if (move_mouse) { // add the mouse movement to x and y positions hidmsg.deltaX +=> x_pos; hidmsg.deltaY +=> y_pos; // check lower limit on x if (x_pos < 0) { 0 => x_pos; } // check upper limit on x if (x_pos > x_max - button_size) { x_max - button_size => x_pos; } // check lower limit on y if (y_pos < button_size) { button_size => y_pos; } // check upper limit on y if (y_pos > y_max - button_size) { y_max - button_size => y_pos; } // move the button mouse_button.position (x_pos, y_pos); mouse_view.addElement (mouse_button); // delay to let system catch up 0.1::ms => now; } } } } I hope that's not too much source code to put in a post. Is this something intended, or a happy coincidence? Just thought I'd share. Pong anyone? Oh, and by the way, what's up with porting MAUI? I've been writing great fun stuff in MAUI including Guitar Lab and Synth Lab, and I'd like to share these programs with my friends who can't run MAUI. Thanks, Les
On 25/03/2008, Inventor-66@comcast.net
Pong anyone?
Aargh! I was *so* hoping the buttons would come to Linux/Windows before somebody else noticed that could be done. :¬) Oh, well, you beat me to it fair&square, if you want to do this; I was thinking about continually adapting the ball's speed so it's impact with the walls and the bats would always be on a beat (while leaving the angle intact), then use drum samples instead of just beeps. Could be fun for installations or jamming with non-musicians or odes to http://en.wikipedia.org/wiki/Tetsuya_Mizuguchi Cheers, Kas.
participants (2)
-
Inventor-66@comcast.net
-
Kassen