[PD-cvs] pd/src g_all_guis.c,1.1.1.4.2.4.2.27,1.1.1.4.2.4.2.28 g_all_guis.h,1.1.1.4.2.2.2.22,1.1.1.4.2.2.2.23 u_object.tk,1.1.2.39,1.1.2.40

Mathieu Bouchard matju at users.sourceforge.net
Sat May 8 21:44:04 CEST 2004


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1673

Modified Files:
      Tag: impd_0_37
	g_all_guis.c g_all_guis.h u_object.tk 
Log Message:
adding method-lookup on the Tk side; abstracting out x->x_draw


Index: g_all_guis.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_all_guis.h,v
retrieving revision 1.1.1.4.2.2.2.22
retrieving revision 1.1.1.4.2.2.2.23
diff -C2 -d -r1.1.1.4.2.2.2.22 -r1.1.1.4.2.2.2.23
*** g_all_guis.h	4 May 2004 07:15:49 -0000	1.1.1.4.2.2.2.22
--- g_all_guis.h	8 May 2004 19:44:01 -0000	1.1.1.4.2.2.2.23
***************
*** 132,146 ****
  EXTERN void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui);
  EXTERN t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv);
- //EXTERN void iemgui_all_col2save(t_iemgui *iemgui, int *bflcol);
- 
- /* methods common to iemgui classes */
- EXTERN void iemgui_send      (t_iemgui *x, t_symbol *s);
- EXTERN void iemgui_receive   (t_iemgui *x, t_symbol *s);
- EXTERN void iemgui_label     (t_iemgui *x, t_symbol *s);
- EXTERN void iemgui_label_pos (t_iemgui *x, t_float lx, t_float ly);
- EXTERN void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av);
- EXTERN void iemgui_delta     (t_iemgui *x, t_symbol *s, int ac, t_atom *av);
- EXTERN void iemgui_pos       (t_iemgui *x, t_symbol *s, int ac, t_atom *av);
- EXTERN void iemgui_color     (t_iemgui *x, t_symbol *s, int ac, t_atom *av);
  EXTERN void iemgui_size      (t_iemgui *x);
  
--- 132,135 ----
***************
*** 163,169 ****
  EXTERN int pd_scanargs(int argc, t_atom *argv, char *format, ...);
  EXTERN void pd_upload(t_gobj *self, t_canvas *can);
! EXTERN void sys_mgui(t_iemgui *self, const char *qlass, const char *sel, const char *fmt, ...);
  EXTERN t_iemgui *iemgui_new(t_class *qlass);
! EXTERN void iemgui_draw(t_iemgui *x, t_glist *glist, int mode, const char *s);
  EXTERN void iemgui_propertiesfn(t_gobj *x, t_glist *owner);
  EXTERN const char *iemgui_get_font(t_iemgui *self);
--- 152,158 ----
  EXTERN int pd_scanargs(int argc, t_atom *argv, char *format, ...);
  EXTERN void pd_upload(t_gobj *self, t_canvas *can);
! EXTERN void sys_mgui(t_iemgui *self, const char *sel, const char *fmt, ...);
  EXTERN t_iemgui *iemgui_new(t_class *qlass);
! EXTERN void iemgui_draw(t_iemgui *x, t_glist *glist, int mode);
  EXTERN void iemgui_propertiesfn(t_gobj *x, t_glist *owner);
  EXTERN const char *iemgui_get_font(t_iemgui *self);
***************
*** 171,172 ****
--- 160,163 ----
  EXTERN t_symbol *sym_empty;
  EXTERN int convert_color2(int x);
+ EXTERN void iemgui_dodraw(t_iemgui *x);
+ EXTERN void iemgui_init(t_iemgui *x, t_floatarg f);

Index: u_object.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/u_object.tk,v
retrieving revision 1.1.2.39
retrieving revision 1.1.2.40
diff -C2 -d -r1.1.2.39 -r1.1.2.40
*** u_object.tk	7 May 2004 07:15:38 -0000	1.1.2.39
--- u_object.tk	8 May 2004 19:44:01 -0000	1.1.2.40
***************
*** 69,81 ****
  set fields(vdl)    $fields(hradio)
  
! set classinfo(obj)     {Object}
! set classinfo(tgl)     {Toggle}
! set classinfo(bng)     {Bang}
! set classinfo(nbx)     {Numberbox}
! set classinfo(hsl)     {Slider}
! set classinfo(hradio)  {Radiobutton}
! set classinfo(vu)      {Vumeter}
! set classinfo(cnv)     {Canvas}
! set classinfo(dropper) {Dropper}
  set classinfo(vsl)     $classinfo(hsl)
  set classinfo(vradio)  $classinfo(hradio)
--- 69,81 ----
  set fields(vdl)    $fields(hradio)
  
! set classinfo(obj)     {Object      object}
! set classinfo(tgl)     {Toggle      toggle}
! set classinfo(bng)     {Bang        bang}
! set classinfo(nbx)     {Numberbox   numbox}
! set classinfo(hsl)     {Slider      slider}
! set classinfo(hradio)  {Radiobutton radio}
! set classinfo(vu)      {Vumeter     vu}
! set classinfo(cnv)     {Canvas      cnv}
! set classinfo(dropper) {Dropper     dropper}
  set classinfo(vsl)     $classinfo(hsl)
  set classinfo(vradio)  $classinfo(hradio)
***************
*** 83,86 ****
--- 83,92 ----
  set classinfo(vdl)     $classinfo(hradio)
  
+ proc call {sel self args} {
+ 	global _ classinfo
+ 	set class [lindex $classinfo($_($self:class)) 1]
+ 	eval [linsert $args 0 ${class}_$sel $self]
+ }
+ 
  proc update_object {x d} {
  	global _
***************
*** 483,487 ****
  	if {!$grabbed} {return}
  	foreach {ox oy} $_($self:mouse) {}
! 	set _($self:val) [expr $_($self:val)+$_($self:rate)*($y-$oy)]
  	numbox_draw $self $canvas
  	set _($self:mouse) [list $x $y]
--- 489,493 ----
  	if {!$grabbed} {return}
  	foreach {ox oy} $_($self:mouse) {}
! 	set _($self:val) [expr $_($self:val)-$_($self:rate)*($y-$oy)]
  	numbox_draw $self $canvas
  	set _($self:mouse) [list $x $y]
***************
*** 527,531 ****
          canvas_ungrab $canvas
      } else {
! 	puts "numbox_keyevent $key"
      }
  }
--- 533,537 ----
          canvas_ungrab $canvas
      } else {
! 	puts "numbox_key $key"
      }
  }
***************
*** 613,616 ****
--- 619,623 ----
  	}
  	label_draw $self $canvas
+ 	radio_set $self $canvas $_($self:on)
  	set _($self:clickevent) radio_click
  }
***************
*** 863,874 ****
  	}
  	label_draw $self $canvas
! 	toggle_set $self $canvas $_($self:on)
! 	
! 	set _($self:clickevent) toggle_click
! }
! 
! proc toggle_set {self canvas v} {
! 	global _
! 	if {$v} {
  		set fill [parse_color $_($self:fcol)]
  	} {
--- 870,874 ----
  	}
  	label_draw $self $canvas
! 	if {$_($self:on)} {
  		set fill [parse_color $_($self:fcol)]
  	} {
***************
*** 877,880 ****
--- 877,882 ----
  	$canvas itemconfigure ${self}X1 -fill $fill
  	$canvas itemconfigure ${self}X2 -fill $fill
+ 	
+ 	set _($self:clickevent) toggle_click
  }
  
***************
*** 963,989 ****
  }
  
! proc vu_set {self canvas i} {
! 	global _
  	foreach {x1 y1} [object_xy $self $canvas] {}
  	set xs $_($self:w)
  	set ys $_($self:h)
  	set led_size [vu_led_size $self]
  	set y [expr $y1 + ($led_size+1)*(41-$i) - ($led_size+1)/2]
  	set x3 [expr $x1+$xs/4]
  	set x4 [expr $x1+$xs-$xs/4]
  	$canvas coords ${self}MASK $x3 $y1 $x4 $y
- }
  
- proc vu_peak {self canvas i} {
- 	global _ vu_col
- 	foreach {x1 y1} [object_xy $self $canvas] {}
- 	set xs $_($self:w)
- 	set ys $_($self:h)
- 	set led_size [vu_led_size $self]
  	$canvas delete ${self}PEAK
! 	set c [lindex $vu_col $i]
! 	#puts "i=$i c=$c"
! 	if {!$i} {return}
! 	set y1 [expr $y1 + ($led_size+1)*(41-$i) - ($led_size+1)/2]
  	$canvas create rectangle $x1 $y1 [expr $x1+$xs] [expr $y1+$led_size] \
  		-fill [parse_color $c] -tags ${self}PEAK -width 0
--- 965,984 ----
  }
  
! proc vu_set {self canvas i j} {
! 	global _ vu_col
  	foreach {x1 y1} [object_xy $self $canvas] {}
  	set xs $_($self:w)
  	set ys $_($self:h)
  	set led_size [vu_led_size $self]
+ 
  	set y [expr $y1 + ($led_size+1)*(41-$i) - ($led_size+1)/2]
  	set x3 [expr $x1+$xs/4]
  	set x4 [expr $x1+$xs-$xs/4]
  	$canvas coords ${self}MASK $x3 $y1 $x4 $y
  
  	$canvas delete ${self}PEAK
! 	set c [lindex $vu_col $j]
! 	if {!$j} {return}
! 	set y1 [expr $y1 + ($led_size+1)*(41-$j) - ($led_size+1)/2]
  	$canvas create rectangle $x1 $y1 [expr $x1+$xs] [expr $y1+$led_size] \
  		-fill [parse_color $c] -tags ${self}PEAK -width 0

Index: g_all_guis.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_all_guis.c,v
retrieving revision 1.1.1.4.2.4.2.27
retrieving revision 1.1.1.4.2.4.2.28
diff -C2 -d -r1.1.1.4.2.4.2.27 -r1.1.1.4.2.4.2.28
*** g_all_guis.c	4 May 2004 07:26:55 -0000	1.1.1.4.2.4.2.27
--- g_all_guis.c	8 May 2004 19:44:01 -0000	1.1.1.4.2.4.2.28
***************
*** 30,33 ****
--- 30,35 ----
  t_symbol *sym_empty;
  
+ EXTERN void iemgui_dodraw(t_iemgui *x) {x->x_draw(x,x->x_glist, 0);}
+ 
  /*------------------ global varaibles -------------------------*/
  
***************
*** 75,85 ****
  }
  
! void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui)
  {
!     iemgui->x_put_in2out = 1;
!     if(iemgui->x_snd_able && iemgui->x_rcv_able)
!     {
! 	iemgui->x_put_in2out = strcmp(iemgui->x_snd->s_name, iemgui->x_rcv->s_name);
!     }
  }
  
--- 77,84 ----
  }
  
! void iemgui_verify_snd_ne_rcv(t_iemgui *x)
  {
!     x->x_put_in2out = 1;
!     if(x->x_snd_able && x->x_rcv_able) x->x_put_in2out = x->x_snd != x->x_rcv;
  }
  
***************
*** 146,150 ****
  }
  
! void iemgui_send(t_iemgui *x, t_symbol *s)
  {
      t_symbol *snd = iemgui_raute2dollar(s);
--- 145,149 ----
  }
  
! static void iemgui_send(t_iemgui *x, t_symbol *s)
  {
      t_symbol *snd = iemgui_raute2dollar(s);
***************
*** 154,161 ****
      x->x_snd_able = strcmp(s->s_name, "empty");
      iemgui_verify_snd_ne_rcv(x);
!     x->x_draw(x,x->x_glist, 0);
  }
  
! void iemgui_receive(t_iemgui *x, t_symbol *s)
  {
      t_symbol *rcv = iemgui_raute2dollar(s);
--- 153,160 ----
      x->x_snd_able = strcmp(s->s_name, "empty");
      iemgui_verify_snd_ne_rcv(x);
!     iemgui_dodraw(x);
  }
  
! static void iemgui_receive(t_iemgui *x, t_symbol *s)
  {
      t_symbol *rcv = iemgui_raute2dollar(s);
***************
*** 175,211 ****
      x->x_rcv_able = rcvable;
      iemgui_verify_snd_ne_rcv(x);
!     if(glist_isvisible(x->x_glist)) x->x_draw(x,x->x_glist, 0);
  }
  
! void iemgui_label(t_iemgui *x, t_symbol *s)
! {
!     t_symbol *lab = iemgui_raute2dollar(s);
!     x->x_lab_unexpanded = lab;
      x->x_lab = lab = canvas_realizedollar(x->x_glist, lab);
!     if(glist_isvisible(x->x_glist)) x->x_draw(x,x->x_glist, 0);
  }
  
! void iemgui_label_pos(t_iemgui *x, t_float ldx, t_float ldy) {
      x->x_ldx = (int)ldx;
      x->x_ldy = (int)ldy;
!     if(glist_isvisible(x->x_glist)) x->x_draw(x,x->x_glist, 0);
  }
  
! void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
! {
!     int f = MAX(4,(int)atom_getintarg(1, ac, av));
!     x->x_fontsize = f;
      x->x_font_style = atom_getintarg(0, ac, av);
!     if(glist_isvisible(x->x_glist)) x->x_draw(x,x->x_glist, 0);
  }
  
  void iemgui_size(t_iemgui *x) {
      if(glist_isvisible(x->x_glist)) {
! 	x->x_draw(x,x->x_glist, 0);
  	canvas_fixlinesfor(glist_getcanvas(x->x_glist), (t_text*)x);
      }
  }
  
! void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      x->x_obj.te_xpix += (int)atom_getintarg(0, ac, av);
--- 174,206 ----
      x->x_rcv_able = rcvable;
      iemgui_verify_snd_ne_rcv(x);
!     if(glist_isvisible(x->x_glist)) iemgui_dodraw(x);
  }
  
! static void iemgui_label(t_iemgui *x, t_symbol *s) {
!     t_symbol *lab = x->x_lab_unexpanded = iemgui_raute2dollar(s);
      x->x_lab = lab = canvas_realizedollar(x->x_glist, lab);
!     if(glist_isvisible(x->x_glist)) iemgui_dodraw(x);
  }
  
! static void iemgui_label_pos(t_iemgui *x, t_float ldx, t_float ldy) {
      x->x_ldx = (int)ldx;
      x->x_ldy = (int)ldy;
!     if(glist_isvisible(x->x_glist)) iemgui_dodraw(x);
  }
  
! static void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av) {
!     x->x_fontsize = MAX(4,(int)atom_getintarg(1, ac, av));
      x->x_font_style = atom_getintarg(0, ac, av);
!     if(glist_isvisible(x->x_glist)) iemgui_dodraw(x);
  }
  
  void iemgui_size(t_iemgui *x) {
      if(glist_isvisible(x->x_glist)) {
! 	iemgui_dodraw(x);
  	canvas_fixlinesfor(glist_getcanvas(x->x_glist), (t_text*)x);
      }
  }
  
! static void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      x->x_obj.te_xpix += (int)atom_getintarg(0, ac, av);
***************
*** 214,218 ****
  }
  
! void iemgui_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      x->x_obj.te_xpix = (int)atom_getintarg(0, ac, av);
--- 209,213 ----
  }
  
! static void iemgui_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      x->x_obj.te_xpix = (int)atom_getintarg(0, ac, av);
***************
*** 224,228 ****
  {return i>=0 ? iemgui_color_hex[i%IEM_GUI_MAX_COLOR] : (~i)&0xffffff;}
  
! void iemgui_color(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      int i=0;
--- 219,223 ----
  {return i>=0 ? iemgui_color_hex[i%IEM_GUI_MAX_COLOR] : (~i)&0xffffff;}
  
! static void iemgui_color(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
  {
      int i=0;
***************
*** 230,234 ****
      if(ac > 2) x->x_fcol = iemgui_compatible_col(atom_getintarg(i++, ac, av));
      x->x_lcol = iemgui_compatible_col(atom_getintarg(i++, ac, av));
!     if(glist_isvisible(x->x_glist)) x->x_draw(x,x->x_glist,0);
  }
  
--- 225,229 ----
      if(ac > 2) x->x_fcol = iemgui_compatible_col(atom_getintarg(i++, ac, av));
      x->x_lcol = iemgui_compatible_col(atom_getintarg(i++, ac, av));
!     if(glist_isvisible(x->x_glist)) iemgui_dodraw(x);
  }
  
***************
*** 417,430 ****
  }
  
! void sys_mgui(t_iemgui *self, const char *qlass, const char *sel, const char *fmt, ...) {
  	char buf[4096];
  	int i=0, n=4096;
- 	t_class *c = self->x_obj.te_g.g_pd;
- 	const char *cname = c->c_name->s_name;
  	t_canvas *canvas=glist_getcanvas(self->x_glist);
  	va_list val;
  	va_start(val,fmt);
! 	i+=snprintf(buf+i,n-i,"%s_%s %x .x%x.c",
! 		qlass?qlass:cname, sel, (unsigned)self, (unsigned)canvas);
  	if (i>=n) goto over;
  	while (*fmt) {
--- 412,422 ----
  }
  
! void sys_mgui(t_iemgui *self, const char *sel, const char *fmt, ...) {
  	char buf[4096];
  	int i=0, n=4096;
  	t_canvas *canvas=glist_getcanvas(self->x_glist);
  	va_list val;
  	va_start(val,fmt);
! 	i+=snprintf(buf+i,n-i,"call %s %x .x%x.c", sel, (unsigned)self, (unsigned)canvas);
  	if (i>=n) goto over;
  	while (*fmt) {
***************
*** 470,473 ****
--- 462,466 ----
  	x->x_glist = (t_glist *)canvas_getcurrent();
  	x->x_w = x->x_h = IEM_GUI_DEFAULTSIZE;
+ 	x->x_draw = (t_iemfunptr)iemgui_draw;
  	x->x_ldx=0;
  	x->x_ldy=-6;
***************
*** 484,499 ****
  	x->x_lcol = 0x000000;
  	x->x_snd_able = x->x_rcv_able = 0;
  	return x;
  }
  
! EXTERN void iemgui_draw(t_iemgui *x, t_glist *glist, int mode, const char *s) {
! /*if (!glist_isvisible(glist_getcanvas(glist))) return; <-- doesn't work */
  if (mode==IEM_GUI_DRAW_MODE_ERASE)
! 	sys_mgui(x,s,"erase","");
  else if (mode==IEM_GUI_DRAW_MODE_SELECT)
! 	sys_mgui(x,s,"select","i",x->x_selected);
  else {
  	pd_upload((t_gobj *)x,glist);
! 	sys_mgui(x,s,"draw","");}
  }
  
--- 477,494 ----
  	x->x_lcol = 0x000000;
  	x->x_snd_able = x->x_rcv_able = 0;
+ 	x->x_lin0_log1 = 0;
+ 	x->x_steady = 1;
  	return x;
  }
  
! EXTERN void iemgui_draw(t_iemgui *x, t_glist *glist, int mode) {
! /*if (!glist_isvisible(glist_getcanvas(glist))) return; <-- doesn't work because NEW object isn't visible yet */
  if (mode==IEM_GUI_DRAW_MODE_ERASE)
! 	sys_mgui(x,"erase","");
  else if (mode==IEM_GUI_DRAW_MODE_SELECT)
! 	sys_mgui(x,"select","i",x->x_selected);
  else {
  	pd_upload((t_gobj *)x,glist);
! 	sys_mgui(x,"draw","");}
  }
  
***************
*** 511,512 ****
--- 506,509 ----
      iemgui_verify_snd_ne_rcv(x);
  }
+ 
+ EXTERN void iemgui_init(t_iemgui *x, t_floatarg f) {x->x_loadinit = !!f;}





More information about the Pd-cvs mailing list