[PD-cvs] pd/src desire.c,1.1.2.217.2.46,1.1.2.217.2.47

Mathieu Bouchard matju at users.sourceforge.net
Fri Dec 8 11:03:37 CET 2006


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

Modified Files:
      Tag: desiredata
	desire.c 
Log Message:
0.40: drawnumber_key


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.46
retrieving revision 1.1.2.217.2.47
diff -C2 -d -r1.1.2.217.2.46 -r1.1.2.217.2.47
*** desire.c	8 Dec 2006 09:46:39 -0000	1.1.2.217.2.46
--- desire.c	8 Dec 2006 10:03:32 -0000	1.1.2.217.2.47
***************
*** 4192,4196 ****
  }
  
- #if 0
  /* bash the first of (argv) with a pointer to a scalar, and send on
     to template as a notification message */
--- 4192,4195 ----
***************
*** 4199,4208 ****
      t_gpointer gp;
      gpointer_init(&gp);
!     gpointer_setcanvas(&gp, owner, x);
      SETPOINTER(argv, &gp);
      template_notify(t, s, argc, argv);
      gpointer_unset(&gp);
  }
- #endif
  
  /* call this when reading a patch from a file to declare what templates
--- 4198,4206 ----
      t_gpointer gp;
      gpointer_init(&gp);
!     gpointer_setcanvas(&gp, owner, sc);
      SETPOINTER(argv, &gp);
      template_notify(t, s, argc, argv);
      gpointer_unset(&gp);
  }
  
  /* call this when reading a patch from a file to declare what templates
***************
*** 4561,4567 ****
  }
  
! /* this seems dumb */
! //static int rangecolor(int n) {return min((n/2)<<6,255);}
!   static int rangecolor(int n) {return n*9/255;}
  
  static void numbertocolor(int n, char *s) {
--- 4559,4563 ----
  }
  
! static int rangecolor(int n) {return n*9/255;}
  
  static void numbertocolor(int n, char *s) {
***************
*** 5147,5151 ****
--- 5143,5153 ----
    t_word *wp;
    t_template *t;
+   t_gpointer gpointer;
+   int symbol;
+   int firstkey;
  } dn;
+  
+      /* LATER protect against the template changing or the scalar disappearing
+      probably by attaching a gpointer here ... */
  
  /* LATER protect against the template changing or the scalar disappearing
***************
*** 5163,5166 ****
--- 5165,5211 ----
  #endif
  
+ static void drawnumber_key(void *z, t_floatarg fkey) {
+     t_drawnumber *x = (t_drawnumber *)z;
+     t_slot *f = &x->value;
+     int key = (int)fkey;
+     char sbuf[MAXPDSTRING];
+     t_atom at;
+     if (!gpointer_check(&dn.gpointer, 0)) {
+         post("drawnumber_motion: scalar disappeared");
+         return;
+     }
+     if (key == 0) return;
+     if (dn.symbol) {
+         /* key entry for a symbol field */
+         if (dn.firstkey) sbuf[0] = 0;
+         else strncpy(sbuf, template_getsymbol(dn.t,
+             f->u.varsym, dn.wp, 1)->s_name, MAXPDSTRING);
+         sbuf[MAXPDSTRING-1] = 0;
+         if (key == '\b') {
+             if (*sbuf) sbuf[strlen(sbuf)-1] = 0;
+         } else {
+             sbuf[strlen(sbuf)+1] = 0;
+             sbuf[strlen(sbuf)] = key;
+         }
+     } else {
+         /* key entry for a numeric field.  This is just a stopgap. */
+         float newf;
+         if (dn.firstkey) sbuf[0] = 0;
+         else sprintf(sbuf, "%g", template_getfloat(dn.t, f->u.varsym, dn.wp, 1));
+         dn.firstkey = (key == '\n');
+         if (key == '\b') {
+             if (*sbuf) sbuf[strlen(sbuf)-1] = 0;
+         } else {
+             sbuf[strlen(sbuf)+1] = 0;
+             sbuf[strlen(sbuf)] = key;
+         }
+         if (sscanf(sbuf, "%g", &newf) < 1) newf = 0;
+         template_setfloat(dn.t, f->u.varsym, dn.wp, newf, 1);
+         if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at);
+         if (dn.scalar) scalar_redraw(dn.scalar, dn.canvas);
+         if (dn.array)  array_redraw(dn.array, dn.canvas);
+     }
+ }
+ 
  static int drawnumber_click(t_gobj *z, t_canvas *canvas, t_word *data, t_template *t, t_scalar *sc, t_array *ap, float basex, float basey, int xpix, int ypix, int shift, int alt, int dbl, int doit) {
      t_drawnumber *x = (t_drawnumber *)z;





More information about the Pd-cvs mailing list