A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 559 lines 19 kB view raw
1/* Copyright (c) 1997-1999 Miller Puckette. 2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL 3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ 4 5/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ 6/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ 7 8 9#ifdef ROCKBOX 10#include "plugin.h" 11#include "../../pdbox.h" 12#include "m_pd.h" 13#include "g_canvas.h" 14#include "g_all_guis.h" 15#else /* ROCKBOX */ 16#include <stdlib.h> 17#include <string.h> 18#include <stdio.h> 19#include <ctype.h> 20#include "m_pd.h" 21#include "g_canvas.h" 22#include "t_tk.h" 23#include "g_all_guis.h" 24#include <math.h> 25 26#ifdef MSW 27#include <io.h> 28#else 29#include <unistd.h> 30#endif 31#endif /* ROCKBOX */ 32 33/* --------------- tgl gui-toggle ------------------------- */ 34 35t_widgetbehavior toggle_widgetbehavior; 36static t_class *toggle_class; 37 38/* widget helper functions */ 39 40void toggle_draw_update(t_toggle *x, t_glist *glist) 41{ 42#ifdef ROCKBOX 43 (void) x; 44 (void) glist; 45#else /* ROCKBOX */ 46 if(glist_isvisible(glist)) 47 { 48 t_canvas *canvas=glist_getcanvas(glist); 49 50 sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x, 51 (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); 52 sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, 53 (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); 54 } 55#endif /* ROCKBOX */ 56} 57 58void toggle_draw_new(t_toggle *x, t_glist *glist) 59{ 60#ifdef ROCKBOX 61 (void) x; 62 (void) glist; 63#else /* ROCKBOX */ 64 t_canvas *canvas=glist_getcanvas(glist); 65 int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); 66 67 if(x->x_gui.x_w >= 30) 68 w = 2; 69 if(x->x_gui.x_w >= 60) 70 w = 3; 71 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n", 72 canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h, 73 x->x_gui.x_bcol, x); 74 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX1\n", 75 canvas, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w, w, 76 (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x); 77 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX2\n", 78 canvas, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w, w, 79 (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x); 80 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \ 81 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n", 82 canvas, xx+x->x_gui.x_ldx, 83 yy+x->x_gui.x_ldy, 84 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", 85 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); 86 if(!x->x_gui.x_fsf.x_snd_able) 87 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", 88 canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, 0); 89 if(!x->x_gui.x_fsf.x_rcv_able) 90 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", 91 canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0); 92#endif /* ROCKBOX */ 93} 94 95void toggle_draw_move(t_toggle *x, t_glist *glist) 96{ 97#ifdef ROCKBOX 98 (void) x; 99 (void) glist; 100#else /* ROCKBOX */ 101 t_canvas *canvas=glist_getcanvas(glist); 102 int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); 103 104 if(x->x_gui.x_w >= 30) 105 w = 2; 106 107 if(x->x_gui.x_w >= 60) 108 w = 3; 109 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n", 110 canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h); 111 sys_vgui(".x%x.c itemconfigure %xX1 -width %d\n", canvas, x, w); 112 sys_vgui(".x%x.c coords %xX1 %d %d %d %d\n", 113 canvas, x, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w); 114 sys_vgui(".x%x.c itemconfigure %xX2 -width %d\n", canvas, x, w); 115 sys_vgui(".x%x.c coords %xX2 %d %d %d %d\n", 116 canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w); 117 sys_vgui(".x%x.c coords %xLABEL %d %d\n", 118 canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy); 119 if(!x->x_gui.x_fsf.x_snd_able) 120 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n", 121 canvas, x, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); 122 if(!x->x_gui.x_fsf.x_rcv_able) 123 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", 124 canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1); 125#endif /* ROCKBOX */ 126} 127 128void toggle_draw_erase(t_toggle* x, t_glist* glist) 129{ 130#ifdef ROCKBOX 131 (void) x; 132 (void) glist; 133#else /* ROCKBOX */ 134 t_canvas *canvas=glist_getcanvas(glist); 135 136 sys_vgui(".x%x.c delete %xBASE\n", canvas, x); 137 sys_vgui(".x%x.c delete %xX1\n", canvas, x); 138 sys_vgui(".x%x.c delete %xX2\n", canvas, x); 139 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x); 140 if(!x->x_gui.x_fsf.x_snd_able) 141 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); 142 if(!x->x_gui.x_fsf.x_rcv_able) 143 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); 144#endif /* ROCKBOX */ 145} 146 147void toggle_draw_config(t_toggle* x, t_glist* glist) 148{ 149#ifdef ROCKBOX 150 (void) x; 151 (void) glist; 152#else /* ROCKBOX */ 153 t_canvas *canvas=glist_getcanvas(glist); 154 155 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", 156 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, 157 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, 158 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); 159 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, 160 x->x_gui.x_bcol); 161 sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x, 162 x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); 163 sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, 164 x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); 165#endif /* ROCKBOX */ 166} 167 168void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) 169{ 170#ifdef ROCKBOX 171 (void) x; 172 (void) glist; 173 (void) old_snd_rcv_flags; 174#else /* ROCKBOX */ 175 int xpos=text_xpix(&x->x_gui.x_obj, glist); 176 int ypos=text_ypix(&x->x_gui.x_obj, glist); 177 t_canvas *canvas=glist_getcanvas(glist); 178 179 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) 180 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", 181 canvas, xpos, 182 ypos + x->x_gui.x_h-1, xpos + IOWIDTH, 183 ypos + x->x_gui.x_h, x, 0); 184 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) 185 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); 186 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) 187 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", 188 canvas, xpos, ypos, 189 xpos + IOWIDTH, ypos+1, x, 0); 190 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) 191 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); 192#endif /* ROCKBOX */ 193} 194 195void toggle_draw_select(t_toggle* x, t_glist* glist) 196{ 197#ifdef ROCKBOX 198 (void) x; 199 (void) glist; 200#else /* ROCKBOX */ 201 t_canvas *canvas=glist_getcanvas(glist); 202 203 if(x->x_gui.x_fsf.x_selected) 204 { 205 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); 206 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); 207 } 208 else 209 { 210 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); 211 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); 212 } 213#endif /* ROCKBOX */ 214} 215 216void toggle_draw(t_toggle *x, t_glist *glist, int mode) 217{ 218 if(mode == IEM_GUI_DRAW_MODE_UPDATE) 219 toggle_draw_update(x, glist); 220 else if(mode == IEM_GUI_DRAW_MODE_MOVE) 221 toggle_draw_move(x, glist); 222 else if(mode == IEM_GUI_DRAW_MODE_NEW) 223 toggle_draw_new(x, glist); 224 else if(mode == IEM_GUI_DRAW_MODE_SELECT) 225 toggle_draw_select(x, glist); 226 else if(mode == IEM_GUI_DRAW_MODE_ERASE) 227 toggle_draw_erase(x, glist); 228 else if(mode == IEM_GUI_DRAW_MODE_CONFIG) 229 toggle_draw_config(x, glist); 230 else if(mode >= IEM_GUI_DRAW_MODE_IO) 231 toggle_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); 232} 233 234/* ------------------------ tgl widgetbehaviour----------------------------- */ 235 236static void toggle_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) 237{ 238 t_toggle *x = (t_toggle *)z; 239 240 *xp1 = text_xpix(&x->x_gui.x_obj, glist); 241 *yp1 = text_ypix(&x->x_gui.x_obj, glist); 242 *xp2 = *xp1 + x->x_gui.x_w; 243 *yp2 = *yp1 + x->x_gui.x_h; 244} 245 246static void toggle_save(t_gobj *z, t_binbuf *b) 247{ 248 t_toggle *x = (t_toggle *)z; 249 int bflcol[3]; 250 t_symbol *srl[3]; 251 252 iemgui_save(&x->x_gui, srl, bflcol); 253 binbuf_addv(b, "ssiisiisssiiiiiiiff", gensym("#X"),gensym("obj"), 254 (t_int)x->x_gui.x_obj.te_xpix, 255 (t_int)x->x_gui.x_obj.te_ypix, 256 gensym("tgl"), x->x_gui.x_w, 257 iem_symargstoint(&x->x_gui.x_isa), 258 srl[0], srl[1], srl[2], 259 x->x_gui.x_ldx, x->x_gui.x_ldy, 260 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, 261 bflcol[0], bflcol[1], bflcol[2], x->x_on, x->x_nonzero); 262 binbuf_addv(b, ";"); 263} 264 265static void toggle_properties(t_gobj *z, t_glist *owner) 266{ 267#ifdef ROCKBOX 268 (void) z; 269 (void) owner; 270#else /* ROCKBOX */ 271 t_toggle *x = (t_toggle *)z; 272 char buf[800]; 273 t_symbol *srl[3]; 274 275 iemgui_properties(&x->x_gui, srl); 276 sprintf(buf, "pdtk_iemgui_dialog %%s TOGGLE \ 277 ----------dimensions(pix):----------- %d %d size: 0 0 empty \ 278 -----------non-zero-value:----------- %g value: 0.0 empty %g \ 279 -1 lin log %d %d empty %d \ 280 %s %s \ 281 %s %d %d \ 282 %d %d \ 283 %d %d %d\n", 284 x->x_gui.x_w, IEM_GUI_MINSIZE, 285 x->x_nonzero, 1.0,/*non_zero-schedule*/ 286 x->x_gui.x_isa.x_loadinit, -1, -1,/*no multi*/ 287 srl[0]->s_name, srl[1]->s_name, 288 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, 289 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, 290 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); 291 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); 292#endif 293} 294 295static void toggle_bang(t_toggle *x) 296{ 297 x->x_on = (x->x_on==0.0)?x->x_nonzero:0.0; 298 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); 299 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); 300 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) 301 pd_float(x->x_gui.x_snd->s_thing, x->x_on); 302} 303 304static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv) 305{ 306 t_symbol *srl[3]; 307 int a = (int)atom_getintarg(0, argc, argv); 308 float nonzero = (float)atom_getfloatarg(2, argc, argv); 309 int sr_flags; 310 311#ifdef ROCKBOX 312 (void) s; 313#endif 314 315 if(nonzero == 0.0) 316 nonzero = 1.0; 317 x->x_nonzero = nonzero; 318 if(x->x_on != 0.0) 319 x->x_on = x->x_nonzero; 320 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); 321 x->x_gui.x_w = iemgui_clip_size(a); 322 x->x_gui.x_h = x->x_gui.x_w; 323 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); 324 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); 325 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); 326 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); 327} 328 329static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) 330#ifdef ROCKBOX 331{ 332 (void) xpos; 333 (void) ypos; 334 (void) shift; 335 (void) alt; 336 (void) ctrl; 337 338 toggle_bang(x); 339} 340#else /* ROCKBOX */ 341{toggle_bang(x);} 342#endif /* ROCKBOX */ 343 344static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) 345{ 346#ifdef ROCKBOX 347 (void) glist; 348 (void) dbl; 349#endif 350 if(doit) 351 toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); 352 return (1); 353} 354 355static void toggle_set(t_toggle *x, t_floatarg f) 356{ 357 x->x_on = f; 358 if(f != 0.0) 359 x->x_nonzero = f; 360 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); 361} 362 363static void toggle_float(t_toggle *x, t_floatarg f) 364{ 365 toggle_set(x, f); 366 if(x->x_gui.x_fsf.x_put_in2out) 367 { 368 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); 369 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) 370 pd_float(x->x_gui.x_snd->s_thing, x->x_on); 371 } 372} 373 374static void toggle_fout(t_toggle *x, t_floatarg f) 375{ 376 toggle_set(x, f); 377 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); 378 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) 379 pd_float(x->x_gui.x_snd->s_thing, x->x_on); 380} 381 382static void toggle_loadbang(t_toggle *x) 383{ 384 if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) 385 toggle_fout(x, (float)x->x_on); 386} 387 388static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av) 389{ 390#ifdef ROCKBOX 391 (void) s; 392#endif 393 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); 394 x->x_gui.x_h = x->x_gui.x_w; 395 iemgui_size((void *)x, &x->x_gui); 396} 397 398static void toggle_delta(t_toggle *x, t_symbol *s, int ac, t_atom *av) 399{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} 400 401static void toggle_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) 402{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} 403 404static void toggle_color(t_toggle *x, t_symbol *s, int ac, t_atom *av) 405{iemgui_color((void *)x, &x->x_gui, s, ac, av);} 406 407static void toggle_send(t_toggle *x, t_symbol *s) 408{iemgui_send(x, &x->x_gui, s);} 409 410static void toggle_receive(t_toggle *x, t_symbol *s) 411{iemgui_receive(x, &x->x_gui, s);} 412 413static void toggle_label(t_toggle *x, t_symbol *s) 414{iemgui_label((void *)x, &x->x_gui, s);} 415 416static void toggle_label_font(t_toggle *x, t_symbol *s, int ac, t_atom *av) 417{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} 418 419static void toggle_label_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) 420{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} 421 422static void toggle_init(t_toggle *x, t_floatarg f) 423{ 424 x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; 425} 426 427static void toggle_nonzero(t_toggle *x, t_floatarg f) 428{ 429 if(f != 0.0) 430 x->x_nonzero = f; 431} 432 433static void *toggle_new(t_symbol *s, int argc, t_atom *argv) 434{ 435 t_toggle *x = (t_toggle *)pd_new(toggle_class); 436 int bflcol[]={-262144, -1, -1}; 437#ifdef ROCKBOX 438 int a=IEM_GUI_DEFAULTSIZE; 439#else 440 int a=IEM_GUI_DEFAULTSIZE, f=0; 441#endif 442 int ldx=0, ldy=-6; 443 int fs=8; 444 float on=0.0, nonzero=1.0; 445#ifndef ROCKBOX 446 char str[144]; 447#endif 448 449#ifdef ROCKBOX 450 (void) s; 451#endif 452 453 iem_inttosymargs(&x->x_gui.x_isa, 0); 454 iem_inttofstyle(&x->x_gui.x_fsf, 0); 455 456 if(((argc == 13)||(argc == 14))&&IS_A_FLOAT(argv,0) 457 &&IS_A_FLOAT(argv,1) 458 &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2)) 459 &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3)) 460 &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)) 461 &&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6) 462 &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9) 463 &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)) 464 { 465 a = (int)atom_getintarg(0, argc, argv); 466 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv)); 467 iemgui_new_getnames(&x->x_gui, 2, argv); 468 ldx = (int)atom_getintarg(5, argc, argv); 469 ldy = (int)atom_getintarg(6, argc, argv); 470 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(7, argc, argv)); 471 fs = (int)atom_getintarg(8, argc, argv); 472 bflcol[0] = (int)atom_getintarg(9, argc, argv); 473 bflcol[1] = (int)atom_getintarg(10, argc, argv); 474 bflcol[2] = (int)atom_getintarg(11, argc, argv); 475 on = (float)atom_getfloatarg(12, argc, argv); 476 } 477 else iemgui_new_getnames(&x->x_gui, 2, 0); 478 if((argc == 14)&&IS_A_FLOAT(argv,13)) 479 nonzero = (float)atom_getfloatarg(13, argc, argv); 480 x->x_gui.x_draw = (t_iemfunptr)toggle_draw; 481 482 x->x_gui.x_fsf.x_snd_able = 1; 483 x->x_gui.x_fsf.x_rcv_able = 1; 484 x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); 485 if (!strcmp(x->x_gui.x_snd->s_name, "empty")) 486 x->x_gui.x_fsf.x_snd_able = 0; 487 if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) 488 x->x_gui.x_fsf.x_rcv_able = 0; 489 if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); 490 else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); 491 else { x->x_gui.x_fsf.x_font_style = 0; 492 strcpy(x->x_gui.x_font, "courier"); } 493 x->x_nonzero = (nonzero!=0.0)?nonzero:1.0; 494 if(x->x_gui.x_isa.x_loadinit) 495 x->x_on = (on!=0.0)?nonzero:0.0; 496 else 497 x->x_on = 0.0; 498 if (x->x_gui.x_fsf.x_rcv_able) 499 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); 500 x->x_gui.x_ldx = ldx; 501 x->x_gui.x_ldy = ldy; 502 503 if(fs < 4) 504 fs = 4; 505 x->x_gui.x_fontsize = fs; 506 x->x_gui.x_w = iemgui_clip_size(a); 507 x->x_gui.x_h = x->x_gui.x_w; 508 iemgui_all_colfromload(&x->x_gui, bflcol); 509 iemgui_verify_snd_ne_rcv(&x->x_gui); 510 outlet_new(&x->x_gui.x_obj, &s_float); 511 return (x); 512} 513 514static void toggle_ff(t_toggle *x) 515{ 516 if(x->x_gui.x_fsf.x_rcv_able) 517 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); 518#ifndef ROCKBOX 519 gfxstub_deleteforkey(x); 520#endif 521} 522 523void g_toggle_setup(void) 524{ 525 toggle_class = class_new(gensym("tgl"), (t_newmethod)toggle_new, 526 (t_method)toggle_ff, sizeof(t_toggle), 0, A_GIMME, 0); 527 class_addcreator((t_newmethod)toggle_new, gensym("toggle"), A_GIMME, 0); 528 class_addbang(toggle_class, toggle_bang); 529 class_addfloat(toggle_class, toggle_float); 530 class_addmethod(toggle_class, (t_method)toggle_click, gensym("click"), 531 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); 532 class_addmethod(toggle_class, (t_method)toggle_dialog, gensym("dialog"), 533 A_GIMME, 0); 534 class_addmethod(toggle_class, (t_method)toggle_loadbang, gensym("loadbang"), 0); 535 class_addmethod(toggle_class, (t_method)toggle_set, gensym("set"), A_FLOAT, 0); 536 class_addmethod(toggle_class, (t_method)toggle_size, gensym("size"), A_GIMME, 0); 537 class_addmethod(toggle_class, (t_method)toggle_delta, gensym("delta"), A_GIMME, 0); 538 class_addmethod(toggle_class, (t_method)toggle_pos, gensym("pos"), A_GIMME, 0); 539 class_addmethod(toggle_class, (t_method)toggle_color, gensym("color"), A_GIMME, 0); 540 class_addmethod(toggle_class, (t_method)toggle_send, gensym("send"), A_DEFSYM, 0); 541 class_addmethod(toggle_class, (t_method)toggle_receive, gensym("receive"), A_DEFSYM, 0); 542 class_addmethod(toggle_class, (t_method)toggle_label, gensym("label"), A_DEFSYM, 0); 543 class_addmethod(toggle_class, (t_method)toggle_label_pos, gensym("label_pos"), A_GIMME, 0); 544 class_addmethod(toggle_class, (t_method)toggle_label_font, gensym("label_font"), A_GIMME, 0); 545 class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0); 546 class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), A_FLOAT, 0); 547 toggle_widgetbehavior.w_getrectfn = toggle_getrect; 548 toggle_widgetbehavior.w_displacefn = iemgui_displace; 549 toggle_widgetbehavior.w_selectfn = iemgui_select; 550 toggle_widgetbehavior.w_activatefn = NULL; 551 toggle_widgetbehavior.w_deletefn = iemgui_delete; 552 toggle_widgetbehavior.w_visfn = iemgui_vis; 553 toggle_widgetbehavior.w_clickfn = toggle_newclick; 554 class_setwidget(toggle_class, &toggle_widgetbehavior); 555 class_sethelpsymbol(toggle_class, gensym("toggle")); 556 class_setsavefn(toggle_class, toggle_save); 557 class_setpropertiesfn(toggle_class, toggle_properties); 558} 559