1 /* 2 widgets.h: 3 4 Copyright (C) 2002 Gabriel Maldonado 5 6 This file is part of Csound. 7 8 The Csound Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 Csound is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with Csound; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 02110-1301 USA 22 */ 23 24 #ifndef CSOUND_WIDGETS_H 25 #define CSOUND_WIDGETS_H 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 typedef struct { 32 OPDS h; 33 MYFLT *kout, *ihandle; 34 STRINGDAT *name; 35 MYFLT *imin, *imax, *iexp; 36 MYFLT *itype, *idisp, *iwidth, *iheight, *ix, *iy; 37 MYFLT min, base, *table; 38 long tablen; 39 } FLSLIDER; 40 41 #define MAXSLIDERBANK 128 42 43 typedef struct { 44 void *widget_addr; //gab 45 MYFLT min, max, *out; 46 MYFLT base, *table; 47 long tablen; 48 int exp; 49 } SLDBK_ELEMENT; 50 51 // --------------------------------------------------------------------- 52 53 typedef struct { 54 OPDS h; 55 MYFLT *names; 56 MYFLT *inumsliders, *ioutable, *iwidth, *iheight; 57 MYFLT *ix, *iy, *itypetable, *iexptable, *ioutablestart_ndx; 58 MYFLT *iminmaxtable; 59 SLDBK_ELEMENT slider_data[MAXSLIDERBANK]; 60 long elements; 61 } FLSLIDERBANK; 62 63 typedef struct { 64 OPDS h; 65 MYFLT *names; 66 MYFLT *inumsliders, *ioutable, *iconfigtable, *iwidth, 67 *iheight, *ix, *iy, *ioutablestart_ndx; 68 SLDBK_ELEMENT slider_data[MAXSLIDERBANK]; 69 long elements; 70 } FLSLIDERBANK2; //gab 71 72 // typedef struct { 73 // OPDS h; 74 // MYFLT *kout, *args[PMAX+1]; 75 // } FLKEYB; 76 77 typedef struct { 78 OPDS h; 79 MYFLT *kvalue, *ihandle; 80 } FLBUTTONCALL; 81 82 typedef struct { 83 OPDS h; 84 MYFLT *koutx, *kouty, *ihandle1, *ihandle2; 85 STRINGDAT *name; 86 MYFLT *iminx, *imaxx, *iminy, *imaxy; 87 MYFLT *iexpx, *iexpy, *idispx, *idispy, *iwidth, *iheight, *ix, *iy; 88 MYFLT basex, basey, *tablex, *tabley; 89 long tablenx, tableny; 90 } FLJOYSTICK; 91 92 typedef struct { 93 OPDS h; 94 MYFLT *kout, *ihandle; 95 STRINGDAT *name; 96 MYFLT *imin, *imax, *istep, *iexp; 97 MYFLT *itype, *idisp, *iwidth, *iheight, *ix, *iy; 98 MYFLT min, base, *table; 99 long tablen; 100 } FLROLLER; 101 102 typedef struct { 103 OPDS h; 104 MYFLT *kout, *ihandle; 105 STRINGDAT *name; 106 MYFLT *imin, *imax, *iexp, *itype; 107 MYFLT *idisp, *iwidth, *ix, *iy, *icursorsize; 108 MYFLT min, base, *table; 109 long tablen; 110 } FLKNOB; 111 112 typedef struct { 113 OPDS h; 114 MYFLT *kout, *ihandle; 115 STRINGDAT *name; 116 MYFLT *imin, *imax, *istep, *itype; 117 MYFLT *iwidth, *iheight, *ix, *iy; 118 } FLTEXT; 119 120 // --------------------------------------------------------------------- 121 122 typedef struct { 123 OPDS h; 124 MYFLT *red1, *green1, *blue1, *red2, *green2, *blue2; 125 } FLWIDGCOL; 126 127 typedef struct { 128 OPDS h; 129 MYFLT *red, *green, *blue; 130 } FLWIDGCOL2; 131 132 typedef struct { 133 OPDS h; 134 MYFLT *size, *font, *align, *red, *green, *blue; 135 } FLWIDGLABEL; 136 137 // --------------------------------------------------------------------- 138 139 typedef struct { 140 OPDS h; 141 MYFLT *ivalue, *ihandle; 142 } FL_SET_WIDGET_VALUE_I; 143 144 typedef struct { 145 OPDS h; 146 MYFLT *ktrig, *kvalue, *ihandle; 147 int handle; 148 int widgetType; 149 MYFLT log_base; 150 } FL_SET_WIDGET_VALUE; 151 152 typedef struct { 153 OPDS h; 154 MYFLT *red, *green, *blue, *ihandle; 155 } FL_SET_COLOR; 156 157 typedef struct { 158 OPDS h; 159 MYFLT *ivalue, *ihandle; 160 } FL_SET_TEXTSIZE; 161 162 typedef struct { 163 OPDS h; 164 MYFLT *itype, *ihandle; 165 } FL_SET_FONT; 166 167 typedef struct { 168 OPDS h; 169 STRINGDAT *itext; 170 MYFLT *ihandle; 171 } FL_SET_TEXT; 172 173 typedef struct { 174 OPDS h; 175 MYFLT *ndx; 176 MYFLT *ihandle; 177 } FL_SET_TEXTi; 178 179 typedef struct { 180 OPDS h; 181 MYFLT *itype, *ihandle; 182 } FL_TALIGN; 183 184 typedef struct { 185 OPDS h; 186 MYFLT *iwidth, *iheight, *ihandle; 187 } FL_SET_SIZE; 188 189 typedef struct { 190 OPDS h; 191 MYFLT *ix, *iy, *ihandle; 192 } FL_SET_POSITION; 193 194 typedef struct { 195 OPDS h; 196 MYFLT *ihandle; 197 } FL_WIDHIDE; 198 199 typedef struct { 200 OPDS h; 201 MYFLT *ihandle; 202 } FL_WIDSHOW; 203 204 typedef struct { 205 OPDS h; 206 MYFLT *itype, *ihandle; 207 } FL_SETBOX; 208 209 typedef struct { 210 OPDS h; 211 MYFLT *ihandle; 212 STRINGDAT *itext; 213 MYFLT *itype, *ifont, *isize; 214 MYFLT *iwidth, *iheight, *ix, *iy; 215 } FL_BOX; 216 217 // --------------------------------------------------------------------- 218 219 typedef struct { 220 OPDS h; 221 MYFLT *ihandle; 222 STRINGDAT *name; 223 MYFLT *iwidth, *iheight, *ix, *iy; 224 } FLVALUE; 225 226 typedef struct { 227 OPDS h; 228 } FLRUN; 229 230 typedef struct { 231 OPDS h; 232 STRINGDAT *name; 233 MYFLT *iwidth, *iheight, *ix, *iy, *border, *ikbdsense, *iclose; 234 } FLPANEL; 235 236 typedef struct { 237 OPDS h; 238 MYFLT *inum_snap, *inum_val, *index, *ifn, *group; 239 } FLSETSNAP; 240 241 typedef struct { 242 OPDS h; 243 MYFLT *inum_el, *index, *group; 244 } FLGETSNAP; 245 246 typedef struct { 247 OPDS h; 248 STRINGDAT *filename; 249 MYFLT *group; 250 } FLSAVESNAPS; 251 252 typedef struct { 253 OPDS h; 254 STRINGDAT *filename; 255 MYFLT *group; 256 } FLLOADSNAPS; 257 258 typedef struct { 259 OPDS h; 260 } FLPANELEND; 261 262 typedef struct { 263 OPDS h; 264 MYFLT *iwidth, *iheight, *ix, *iy; 265 } FLSCROLL; 266 267 typedef struct { 268 OPDS h; 269 } FLSCROLLEND; 270 271 typedef struct { 272 OPDS h; 273 MYFLT *iwidth, *iheight, *ix, *iy; 274 } FLTABS; 275 276 typedef struct { 277 OPDS h; 278 } FLTABSEND; 279 280 typedef struct { 281 OPDS h; 282 STRINGDAT *name; 283 MYFLT *iwidth, *iheight, *ix, *iy, *border; 284 } FLGROUP; 285 286 typedef struct { 287 OPDS h; 288 } FLGROUPEND; 289 290 typedef struct { 291 OPDS h; 292 MYFLT *iwidth, *iheight, *ix, *iy, *itype, *ispace, *iborder; 293 } FLPACK; 294 295 typedef struct { 296 OPDS h; 297 } FLPACKEND; 298 299 typedef struct { 300 OPDS h; 301 MYFLT *kout, *ihandle; 302 STRINGDAT *name; 303 MYFLT *ion, *ioff, *itype; 304 MYFLT *iwidth, *iheight, *ix, *iy, *args[PMAX]; 305 } FLBUTTON; 306 307 typedef struct { 308 OPDS h; 309 MYFLT *kout, *ihandle; /* outs */ 310 MYFLT *itype, *inumx, *inumy, *iwidth, *iheight, *ix, *iy, *args[PMAX]; 311 } FLBUTTONBANK; 312 313 typedef struct { 314 OPDS h; 315 MYFLT *kout, *ihandle; 316 STRINGDAT *name; 317 MYFLT *imin, *imax, *istep1, *istep2, *itype; 318 MYFLT *iwidth, *iheight, *ix, *iy, *args[PMAX]; 319 } FLCOUNTER; 320 321 typedef struct { 322 OPDS h; 323 MYFLT *ptime, *val, *idisp; 324 MYFLT initime, ctime; 325 long cysofar; 326 } FLPRINTK; 327 328 typedef struct { 329 OPDS h; 330 MYFLT *val, *idisp; 331 MYFLT oldvalue; 332 /* int pspace; */ 333 } FLPRINTK2; 334 335 typedef struct { 336 OPDS h; 337 MYFLT *ihandle; 338 STRINGDAT *name; 339 MYFLT *iwidth, *iheight, *ix, *iy; 340 } FLCLOSEBUTTON; 341 342 typedef struct { 343 OPDS h; 344 MYFLT *ihandle; 345 STRINGDAT *command; 346 MYFLT *iwidth, *iheight, *ix, *iy; 347 char *commandString; 348 CSOUND *csound; 349 } FLEXECBUTTON; 350 351 #ifdef __cplusplus 352 } 353 #endif 354 355 #if defined(CSOUND_WIDGETS_CPP) 356 357 /* ---- IV - Aug 23 2002 ---- included file: Fl_Ball.H */ 358 359 class Fl_Ball : public Fl_Valuator { 360 private: 361 CSOUND *csound; 362 int ix, iy, drag; 363 int spinning; 364 365 int ballstacks, ballslices; 366 float ballsize; 367 368 float curquat[4]; 369 float lastquat[4]; 370 float mat[4][4]; 371 372 char soft_; 373 uchar mouseobj; 374 375 static PUBLIC void repeat_callback(void *); 376 PUBLIC void increment_cb(); 377 PUBLIC void vertex_by_matrix(float &x, float &y, float &z); 378 379 PUBLIC void transform_ball_vertex(float &x, float &y, float &z); 380 PUBLIC void rotate(float &x, float &y, float &z, 381 float rotx=0.0f, float roty=0.0f, float rotz=0.0f); 382 PUBLIC void draw_solid_ball(float radius, int slices, int stacks); 383 PUBLIC void draw_wire_ball(float radius, int slices, int stacks); 384 public: 385 PUBLIC void draw(); 386 PUBLIC void handle_drag(double v=0.0); 387 PUBLIC void handle_release(); 388 PUBLIC int handle(int); 389 PUBLIC Fl_Ball(CSOUND *cs, int x, int y, int w, int h, const char *l = 0); 390 soft(char x)391 void soft(char x) {soft_ = x;} soft()392 char soft() const {return soft_;} 393 ballscale()394 float ballscale() const {return ballsize;} ballscale(float s)395 void ballscale(float s) { ballsize=s;} 396 397 void rotateball(float rotx=0.0f, float roty=0.0f, float rotz=0.0f); 398 void getrot(float &rotx, float &roty, float &rotz); 399 stacks(int s)400 void stacks(int s) { ballstacks=s; } stacks()401 int stacks() const { return ballstacks; } 402 slices(int s)403 void slices(int s) { ballslices=s; } slices()404 int slices() const { return ballslices; } 405 406 ~Fl_Ball(); 407 }; 408 409 /* ---- IV - Aug 23 2002 ---- included file: Fl_Knob.H */ 410 411 /* generated by Fast Light User Interface Designer (fluid) version 2.00 */ 412 413 class Fl_Knob : public Fl_Valuator { 414 public: 415 enum Fl_Knobtype { 416 DOTLIN=0, 417 DOTLOG_1, 418 DOTLOG_2, 419 DOTLOG_3, 420 LINELIN, 421 LINELOG_1, 422 LINELOG_2, 423 LINELOG_3 424 }; 425 private: 426 CSOUND *csound; 427 int _type; 428 float _percent; 429 int _scaleticks; 430 short a1, a2; 431 public: 432 Fl_Knob(CSOUND *cs, int xx, int yy, int ww, int hh, const char *l=0); 433 ~Fl_Knob(); 434 private: 435 void draw(); 436 int handle(int event); 437 public: 438 void type(int ty); 439 private: 440 void shadow(const int offs, const uchar r, uchar g, uchar b); 441 void draw_scale(const int ox, const int oy, const int side); 442 void draw_cursor(const int ox, const int oy, const int side); 443 public: 444 void cursor(const int pc); 445 void scaleticks(const int tck); 446 }; 447 448 /* ---- IV - Aug 23 2002 ---- included file: Fl_Spin.H */ 449 450 class Fl_Spin : public Fl_Valuator { 451 private: 452 CSOUND * csound; 453 int ix, iy, drag, indrag; 454 int delta, deltadir; 455 char soft_; 456 uchar mouseobj; 457 static PUBLIC void repeat_callback(void *); 458 PUBLIC void increment_cb(); 459 460 public: 461 PUBLIC void draw(); 462 PUBLIC int handle(int); 463 PUBLIC Fl_Spin(CSOUND *cs, int x, int y, int w, int h, const char *l = 0); 464 soft(char x)465 void soft(char x) {soft_ = x;} soft()466 char soft() const {return soft_;} 467 468 ~Fl_Spin(); 469 }; 470 471 /* ---- IV - Aug 23 2002 ---- included file: Fl_Value_Input_Spin.H */ 472 473 class Fl_Value_Input_Spin : public Fl_Valuator { 474 private: 475 CSOUND * csound; 476 int ix, iy, drag; 477 int delta, deltadir; 478 char soft_; 479 uchar mouseobj; 480 int butsize; 481 static PUBLIC void input_cb(Fl_Widget*, void*); 482 // cause damage() due to value() changing 483 virtual PUBLIC void value_damage(); 484 static PUBLIC void repeat_callback(void *); 485 PUBLIC void increment_cb(); 486 487 public: 488 Fl_Input input; 489 PUBLIC void draw(); 490 PUBLIC int handle(int); 491 PUBLIC void resize(int, int, int, int); 492 PUBLIC Fl_Value_Input_Spin(CSOUND *csound, int x, int y, int w, int h, 493 const char *l = 0); 494 soft(char x)495 void soft(char x) {soft_ = x;} soft()496 char soft() const {return soft_;} 497 textfont()498 Fl_Font textfont() const {return input.textfont();} textfont(uchar s)499 void textfont(uchar s) { input.textfont(s);} textsize()500 uchar textsize() const {return input.textsize();} textsize(uchar s)501 void textsize(uchar s) {input.textsize(s);} textcolor()502 Fl_Color textcolor() const {return input.textcolor();} textcolor(uchar n)503 void textcolor(uchar n) {input.textcolor(n);} cursor_color()504 Fl_Color cursor_color() const {return input.cursor_color();} cursor_color(uchar n)505 void cursor_color(uchar n) {input.cursor_color(n);} buttonssize()506 int buttonssize() const {return butsize;} buttonssize(int s)507 void buttonssize(int s) { butsize=s;} 508 ~Fl_Value_Input_Spin(); 509 }; 510 511 /* ---- IV - Aug 23 2002 ---- included file: Fl_Value_Slider_Input.H */ 512 513 class Fl_Value_Slider_Input : public Fl_Value_Slider { 514 private: 515 CSOUND *csound; 516 char soft_; 517 int txtboxsize; 518 519 static PUBLIC void input_cb(Fl_Widget*, void*); 520 // cause damage() due to value() changing 521 virtual PUBLIC void value_damage(); 522 523 public: 524 Fl_Input input; 525 PUBLIC void draw(); 526 PUBLIC int handle(int); 527 PUBLIC void resize(int, int, int, int); 528 PUBLIC Fl_Value_Slider_Input(CSOUND * cs, int x, int y, int w, int h, 529 const char *l = 0); 530 soft(char x)531 void soft(char x) {soft_ = x;} soft()532 char soft() const {return soft_;} 533 textfont()534 Fl_Font textfont() const {return input.textfont();} textfont(uchar s)535 void textfont(uchar s) { input.textfont(s);} textsize()536 uchar textsize() const {return input.textsize();} textsize(uchar s)537 void textsize(uchar s) {input.textsize(s);} textcolor()538 Fl_Color textcolor() const {return input.textcolor();} textcolor(uchar n)539 void textcolor(uchar n) {input.textcolor(n);} cursor_color()540 Fl_Color cursor_color() const {return input.cursor_color();} cursor_color(uchar n)541 void cursor_color(uchar n) {input.cursor_color(n);} textboxsize(int s)542 void textboxsize(int s) { txtboxsize=s;} textboxsize()543 int textboxsize() const {return txtboxsize;} 544 }; 545 546 547 // New widgets for Csound5.06 by Gabriel Maldonado 548 // Ported by Andres Cabrera. This section below comes 549 // from the file newwidgets.h 550 551 typedef struct { 552 OPDS h; 553 MYFLT *ihandle; 554 } FLSLDBNK_GETHANDLE; //gab 555 556 typedef struct { 557 OPDS h; 558 MYFLT *ihandle, *ifn, *startInd, *startSlid, *numSlid; 559 //int oldx, oly; 560 } FLSLDBNK_SET; //gab 561 562 typedef struct { 563 OPDS h; 564 MYFLT *kflag, *ihandle, *ifn, *startInd, *startSlid, *numSlid; 565 MYFLT oldValues[MAXSLIDERBANK]; 566 int numslid, startind, startslid; 567 FLSLIDERBANK2 *q; 568 MYFLT *table, *outable; 569 //int oldx, oly; 570 } FLSLDBNK2_SETK; 571 572 typedef struct { 573 OPDS h; 574 MYFLT *kflag, *ihandle, *ifn, *startInd, *startSlid, *numSlid; 575 MYFLT oldValues[MAXSLIDERBANK]; 576 int numslid, startind, startslid; 577 FLSLIDERBANK *q; 578 MYFLT *table, *outable; 579 //int oldx, oly; 580 } FLSLDBNK_SETK; 581 582 typedef struct { 583 OPDS h; 584 MYFLT *koutx, *kouty, *kinside; //outs 585 MYFLT *ioutx_min, *ioutx_max, *iouty_min, *iouty_max, 586 *iwindx_min, *iwindx_max, *iwindy_min, *iwindy_max, 587 *iexpx, *iexpy, *ioutx, *iouty; //ins 588 MYFLT oldx, oldy, *tablex, *tabley; 589 int expx, expy; 590 long tablenx, tableny; 591 double rangex, rangey, basex, basey; 592 //int pspace; 593 } FLXYIN; //gab 594 595 typedef struct { 596 OPDS h; 597 // MYFLT *ktrig, *kvalue, *ihandle; 598 MYFLT *chan, *cc, *ihandle; 599 int ccVal, oldCCval; 600 MYFLT log_base, min, max, range; 601 void *WidgAddress, *opcode, *addrSetVal; 602 int exp, widg_type; 603 } FL_MIDI_WIDGET_VALUE; 604 605 606 typedef struct { 607 OPDS h; 608 MYFLT *kascii,*ifn;//, *ifnMap; 609 MYFLT *table;//, *tableMap; 610 int flag; 611 } FLKEYIN; 612 613 typedef struct { 614 OPDS h; 615 MYFLT *group; 616 } FLSETSNAPGROUP; 617 618 typedef struct { 619 OPDS h; 620 MYFLT *x,*y, *b1, *b2, *b3, *flagRaw; 621 MYFLT height,width; 622 } FLMOUSE; 623 624 typedef struct { 625 OPDS h; 626 MYFLT *ihandle, *numlinesX, *numlinesY, *iwidth, *iheight, *ix, *iy,*image; 627 int width, height; 628 } FL_HVSBOX; 629 630 typedef struct { 631 OPDS h; 632 MYFLT *kx, *ky, *ihandle; 633 void *WidgAddress, *opcode; 634 MYFLT old_x, old_y; 635 } FL_SET_HVS_VALUE; 636 637 typedef struct { 638 OPDS h; 639 MYFLT max[MAXCHNLS]; 640 unsigned long widg_address[MAXCHNLS]; 641 int dummycycles, dummycyc; 642 } FLTKMETER; 643 644 #endif /* CSOUND_WIDGETS_CPP */ 645 #endif /* CSOUND_WIDGETS_H */ 646