[PD-cvs] pd/src desire.c, 1.1.2.127, 1.1.2.128 desire.h, 1.1.2.7, 1.1.2.8

Mathieu Bouchard matju at users.sourceforge.net
Fri Sep 1 19:56:01 CEST 2006


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

Modified Files:
      Tag: devel_0_39
	desire.c desire.h 
Log Message:
removing t_glistmotionfn and t_glistkeyfn and e_onmotion.


Index: desire.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** desire.h	21 Aug 2006 03:13:05 -0000	1.1.2.7
--- desire.h	1 Sep 2006 17:55:58 -0000	1.1.2.8
***************
*** 73,79 ****
  } t_updateheader;
  
!     /* types to support glists grabbing mouse motion or keys from parent */
  typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
  typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
  
  EXTERN_STRUCT _rtext;
--- 73,81 ----
  } t_updateheader;
  
! /* types to support glists grabbing mouse motion or keys from parent */
! /*
  typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
  typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
+ */
  
  EXTERN_STRUCT _rtext;
***************
*** 101,105 ****
  } t_selection;
  
!     /* this structure is instantiated whenever a glist becomes visible. */
  typedef struct _editor
  {
--- 103,108 ----
  } t_selection;
  
! /* this structure is instantiated whenever a glist becomes visible. */
! /* commented-out fields are not in DesireData */
  typedef struct _editor
  {
***************
*** 107,117 ****
      t_selection *e_updlist;         /* list of objects to update */
      t_rtext *e_rtext;               /* text responder linked list */
! #ifndef DESIRE
!     t_selection *e_selection;       /* head of the selection list */
! #endif
      t_rtext *e_textedfor;           /* the rtext if any that we are editing */
      t_gobj *e_grab;                 /* object being "dragged" */
!     t_glistmotionfn e_motionfn;     /* ... motion callback */
!     t_glistkeyfn e_keyfn;           /* ... keypress callback */
      t_binbuf *e_connectbuf;         /* connections to deleted objects */
      t_binbuf *e_deleted;            /* last stuff we deleted */
--- 110,118 ----
      t_selection *e_updlist;         /* list of objects to update */
      t_rtext *e_rtext;               /* text responder linked list */
! /*  t_selection *e_selection;          head of the selection list */
      t_rtext *e_textedfor;           /* the rtext if any that we are editing */
      t_gobj *e_grab;                 /* object being "dragged" */
! /*  t_glistmotionfn e_motionfn;        ... motion callback */
! /*  t_glistkeyfn e_keyfn;              ... keypress callback */
      t_binbuf *e_connectbuf;         /* connections to deleted objects */
      t_binbuf *e_deleted;            /* last stuff we deleted */
***************
*** 125,129 ****
      int e_selectline_inno;
      t_outconnect *e_selectline_tag;
!     unsigned int e_onmotion: 3;     /* action to take on motion */
      unsigned int e_lastmoved: 1;    /* one if mouse has moved since click */
      unsigned int e_textdirty: 1;    /* one if e_textedfor has changed */
--- 126,130 ----
      int e_selectline_inno;
      t_outconnect *e_selectline_tag;
! /*  unsigned int e_onmotion: 3;        action to take on motion */
      unsigned int e_lastmoved: 1;    /* one if mouse has moved since click */
      unsigned int e_textdirty: 1;    /* one if e_textedfor has changed */
***************
*** 131,141 ****
  } t_editor;
  
- #define MA_NONE    0    /* e_onmotion: do nothing on mouse motion */
- #define MA_MOVE    1    /* drag the selection around */
- #define MA_CONNECT 2    /* make a connection */
- #define MA_REGION  3    /* selection region */
- #define MA_PASSOUT 4    /* send on to e_grab */
- #define MA_DRAGTEXT 5   /* drag in text editor to alter selection */
- 
  /* editor structure for "garrays".  We don't bother to delete and regenerate
  this structure when the "garray" becomes invisible or visible, although we
--- 132,135 ----
***************
*** 403,412 ****
  EXTERN void glist_noselect(t_glist *x);
  EXTERN void glist_selectall(t_glist *x);
  */
  
  EXTERN void glist_delete(t_glist *x, t_gobj *y);
  EXTERN void glist_retext(t_glist *x, t_text *y);
- EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
-     t_glistkeyfn keyfn, int xpos, int ypos);
  EXTERN int glist_isvisible(t_glist *x);
  EXTERN int glist_istoplevel(t_glist *x);
--- 397,406 ----
  EXTERN void glist_noselect(t_glist *x);
  EXTERN void glist_selectall(t_glist *x);
+ EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
+ 	t_glistkeyfn keyfn, int xpos, int ypos);
  */
  
  EXTERN void glist_delete(t_glist *x, t_gobj *y);
  EXTERN void glist_retext(t_glist *x, t_text *y);
  EXTERN int glist_isvisible(t_glist *x);
  EXTERN int glist_istoplevel(t_glist *x);

Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.127
retrieving revision 1.1.2.128
diff -C2 -d -r1.1.2.127 -r1.1.2.128
*** desire.c	1 Sep 2006 15:39:48 -0000	1.1.2.127
--- desire.c	1 Sep 2006 17:55:58 -0000	1.1.2.128
***************
*** 1596,1599 ****
--- 1596,1600 ----
  }
  
+ /*DIE*/
  void canvas_startmotion(t_canvas *x)
  {
***************
*** 1602,1608 ****
      glist_getnextxy(x, &xval, &yval);
      if (xval == 0 && yval == 0) return;
-     x->gl_editor->e_onmotion = MA_MOVE;
      x->gl_editor->e_xwas = xval;
!     x->gl_editor->e_ywas = yval; 
  }
  
--- 1603,1608 ----
      glist_getnextxy(x, &xval, &yval);
      if (xval == 0 && yval == 0) return;
      x->gl_editor->e_xwas = xval;
!     x->gl_editor->e_ywas = yval;
  }
  
***************
*** 2353,2361 ****
      probably by attaching a gpointer here ... */
  
  static void array_motion(void *z, t_floatarg dx, t_floatarg dy) {
      array_motion_xcumulative += dx * array_motion_xperpix;
      array_motion_ycumulative += dy * array_motion_yperpix;
!     if (array_motion_xfield) {
!             /* it's an x, y plot */
          int i;
          for (i = 0; i < array_motion_npoints; i++) {
--- 2353,2361 ----
      probably by attaching a gpointer here ... */
  
+ #if 0
  static void array_motion(void *z, t_floatarg dx, t_floatarg dy) {
      array_motion_xcumulative += dx * array_motion_xperpix;
      array_motion_ycumulative += dy * array_motion_yperpix;
!     if (array_motion_xfield) {// xy plot
          int i;
          for (i = 0; i < array_motion_npoints; i++) {
***************
*** 2384,2389 ****
              }
          }
!     } else if (array_motion_yfield) {
!             /* a y-only plot. */
          int thisx = array_motion_initx + array_motion_xcumulative + 0.5, x2;
          int increment, i, nchange;
--- 2384,2388 ----
              }
          }
!     } else if (array_motion_yfield) {// y plot
          int thisx = array_motion_initx + array_motion_xcumulative + 0.5, x2;
          int increment, i, nchange;
***************
*** 2413,2416 ****
--- 2412,2416 ----
      if (array_motion_array)   array_redraw(array_motion_array,  array_motion_glist);
  }
+ #endif
  
  int scalar_doclick(t_word *data, t_template *template, t_scalar *sc,
***************
*** 2600,2604 ****
                          array_motion_ycumulative = 0;
                      }
!                     glist_grab(glist, 0, array_motion, 0, xpix, ypix);
                  }
                  if (alt) {
--- 2600,2604 ----
                          array_motion_ycumulative = 0;
                      }
!                     /* glist_grab(glist, 0, array_motion, 0, xpix, ypix); */
                  }
                  if (alt) {
***************
*** 3075,3079 ****
  
  void glist_add(t_glist *x, t_gobj *y) {
! /*
      if (!y->g_pd->c_patchable) {
  	printf("glist_add %p %p class=%s (non-t_text)\n",x,y,y->g_pd->c_name->s_name);
--- 3075,3079 ----
  
  void glist_add(t_glist *x, t_gobj *y) {
! #ifdef DEBUG_GLIST_ADD
      if (!y->g_pd->c_patchable) {
  	printf("glist_add %p %p class=%s (non-t_text)\n",x,y,y->g_pd->c_name->s_name);
***************
*** 3089,3093 ****
  	}
      }
! */
  
      gobj_subscribe(y,(t_gobj *)x);
--- 3089,3093 ----
  	}
      }
! #endif
  
      gobj_subscribe(y,(t_gobj *)x);
***************
*** 3201,3268 ****
  }
  
! void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
!     t_glistkeyfn keyfn, int xpos, int ypos)
! {
!     t_glist *x2 = glist_getcanvas(x);
!     if (motionfn)
!         x2->gl_editor->e_onmotion = MA_PASSOUT;
!     else x2->gl_editor->e_onmotion = 0;
!     x2->gl_editor->e_grab = y;
!     x2->gl_editor->e_motionfn = motionfn;
!     x2->gl_editor->e_keyfn = keyfn;
!     x2->gl_editor->e_xwas = xpos;
!     x2->gl_editor->e_ywas = ypos;
! }
! 
! t_canvas *glist_getcanvas(t_glist *x)
! {
!     while (x->gl_owner && !x->gl_havewindow && x->gl_isgraph)
!         x = x->gl_owner;
!     return((t_canvas *)x);
  }
  
! static float gobj_getxforsort(t_gobj *g)
! {
!     if (pd_class(&g->g_pd) == scalar_class)
!     {
          float x1, y1;
          scalar_getbasexy((t_scalar *)g, &x1, &y1);
!         return(x1);
!     }
!     else return (0);
  }
  
! static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2)
! {
      t_gobj *g = 0, *g9 = 0;
      float f1 = 0, f2 = 0;
      if (g1) f1 = gobj_getxforsort(g1);
      if (g2) f2 = gobj_getxforsort(g2);
!     while (1)
!     {
!         if (g1) {
!             if (g2 && f1>f2) goto put2; else goto put1;
!         } else if (g2) goto put2;
!         else break;
!     put1:
!         if (g9)
!             g9->g_next = g1, g9 = g1;
!         else g9 = g = g1;
!         if ((g1 = g1->g_next)) f1 = gobj_getxforsort(g1);
!         g9->g_next = 0;
!         continue;
!     put2:
!         if (g9)
!             g9->g_next = g2, g9 = g2;
!         else g9 = g = g2;
!         if ((g2 = g2->g_next)) f2 = gobj_getxforsort(g2);
!         g9->g_next = 0;
!         continue;
      }
!     return (g);
  }
  
! static t_gobj *glist_dosort(t_glist *x, t_gobj *g, int nitems)
! {
      if (nitems < 2) return g;
      {
--- 3201,3241 ----
  }
  
! t_canvas *glist_getcanvas(t_glist *x) {
!     while (x->gl_owner && !x->gl_havewindow && x->gl_isgraph) x = x->gl_owner;
!     return (t_canvas *)x;
  }
  
! static float gobj_getxforsort(t_gobj *g) {
!     if (pd_class(&g->g_pd) == scalar_class) {
          float x1, y1;
          scalar_getbasexy((t_scalar *)g, &x1, &y1);
!         return x1;
!     } else return 0;
  }
  
! static t_gobj *glist_merge(t_glist *x, t_gobj *g1, t_gobj *g2) {
      t_gobj *g = 0, *g9 = 0;
      float f1 = 0, f2 = 0;
      if (g1) f1 = gobj_getxforsort(g1);
      if (g2) f2 = gobj_getxforsort(g2);
!     while (1) {
! 	if (g1 && !(g2 && f1>f2)) {
! 	        if (g9) {g9->g_next = g1; g9 = g1;} else g9 = g = g1;
! 	        if ((g1 = g1->g_next)) f1 = gobj_getxforsort(g1);
! 	        g9->g_next = 0;
! 	        continue;
! 	}
! 	if (g1 || g2) {
! 	        if (g9) {g9->g_next = g2; g9 = g2;} else g9 = g = g2;
! 	        if ((g2 = g2->g_next)) f2 = gobj_getxforsort(g2);
! 	        g9->g_next = 0;
! 	        continue;
! 	}
!         break;
      }
!     return g;
  }
  
! static t_gobj *glist_dosort(t_glist *x, t_gobj *g, int nitems) {
      if (nitems < 2) return g;
      {
***************
*** 3279,3301 ****
  }
  
! void glist_sort(t_glist *x)
! {
      int nitems = 0, foo = 0;
      float lastx = -1e37;
      t_gobj *g;
!     for (g = x->gl_list; g; g = g->g_next)
!     {
          float x1 = gobj_getxforsort(g);
!         if (x1 < lastx)
!             foo = 1;
          lastx = x1;
          nitems++;
      }
!     if (foo)
!         x->gl_list = glist_dosort(x, x->gl_list, nitems);
  }
  
! void glist_cleanup(t_glist *x)
! {
      freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel)));
      freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel)));
--- 3252,3269 ----
  }
  
! void glist_sort(t_glist *x) {
      int nitems = 0, foo = 0;
      float lastx = -1e37;
      t_gobj *g;
!     for (g = x->gl_list; g; g = g->g_next) {
          float x1 = gobj_getxforsort(g);
!         if (x1 < lastx) foo = 1;
          lastx = x1;
          nitems++;
      }
!     if (foo) x->gl_list = glist_dosort(x, x->gl_list, nitems);
  }
  
! void glist_cleanup(t_glist *x) {
      freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel)));
      freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel)));
***************
*** 3303,3308 ****
  }
  
! void glist_free(t_glist *x)
! {
      glist_cleanup(x);
      freebytes(x, sizeof(*x));
--- 3271,3275 ----
  }
  
! void glist_free(t_glist *x) {
      glist_cleanup(x);
      freebytes(x, sizeof(*x));
***************
*** 3311,3315 ****
  /* --------------- inlets and outlets  ----------- */
  
- 
  t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s, t_symbol* h) {
      t_inlet *ip = inlet_new(&x->gl_obj, who, s, 0);
--- 3278,3281 ----
***************
*** 3362,3367 ****
  }
  
! t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s)
! {
      t_outlet *op = outlet_new(&x->gl_obj, s);
      if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) {
--- 3328,3332 ----
  }
  
! t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) {
      t_outlet *op = outlet_new(&x->gl_obj, s);
      if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) {
***************
*** 3370,3374 ****
      }
      if (!x->gl_loading) canvas_resortoutlets(x);
!     return (op);
  }
  
--- 3335,3339 ----
      }
      if (!x->gl_loading) canvas_resortoutlets(x);
!     return op;
  }
  
***************
*** 6646,6672 ****
      probably by attaching a gpointer here ... */
  
! static void curve_motion(void *z, t_floatarg dx, t_floatarg dy)
! {
      t_curve *x = (t_curve *)z;
      t_fielddesc *f = x->x_vec + curve_motion_field;
      curve_motion_xcumulative += dx;
      curve_motion_ycumulative += dy;
!     if (f->fd_var && (dx != 0))
!     {
          fielddesc_setcoord(f, curve_motion_template, curve_motion_wp,
!             curve_motion_xbase + curve_motion_xcumulative * curve_motion_xper,
!                 1); 
!     }
!     if ((f+1)->fd_var && (dy != 0))
!     {
          fielddesc_setcoord(f+1, curve_motion_template, curve_motion_wp,
!             curve_motion_ybase + curve_motion_ycumulative * curve_motion_yper,
!                 1); 
!     }
!     if (curve_motion_scalar)
!         scalar_redraw(curve_motion_scalar, curve_motion_glist);
!     if (curve_motion_array)
!         array_redraw(curve_motion_array, curve_motion_glist);
  }
  
  static int curve_click(t_gobj *z, t_glist *glist, 
--- 6611,6630 ----
      probably by attaching a gpointer here ... */
  
! #if 0
! static void curve_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_curve *x = (t_curve *)z;
      t_fielddesc *f = x->x_vec + curve_motion_field;
      curve_motion_xcumulative += dx;
      curve_motion_ycumulative += dy;
!     if (f[0].fd_var && dx!=0)
          fielddesc_setcoord(f, curve_motion_template, curve_motion_wp,
!             curve_motion_xbase + curve_motion_xcumulative * curve_motion_xper, 1);
!     if (f[1].fd_var && dy!=0)
          fielddesc_setcoord(f+1, curve_motion_template, curve_motion_wp,
!             curve_motion_ybase + curve_motion_ycumulative * curve_motion_yper, 1);
!     if (curve_motion_scalar) scalar_redraw(curve_motion_scalar, curve_motion_glist);
!     if (curve_motion_array)   array_redraw(curve_motion_array,  curve_motion_glist);
  }
+ #endif
  
  static int curve_click(t_gobj *z, t_glist *glist, 
***************
*** 6680,6702 ****
      int besterror = 0x7fffffff;
      t_fielddesc *f;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0))
!         return (0);
!     for (i = 0, f = x->x_vec; i < n; i++, f += 2)
!     {
!         int xval = fielddesc_getcoord(f, template, data, 0),
!             xloc = glist_xtopixels(glist, basex + xval);
!         int yval = fielddesc_getcoord(f+1, template, data, 0),
!             yloc = glist_ytopixels(glist, basey + yval);
          int xerr = xloc - xpix, yerr = yloc - ypix;
!         if (!f->fd_var && !(f+1)->fd_var)
!             continue;
!         if (xerr < 0)
!             xerr = -xerr;
!         if (yerr < 0)
!             yerr = -yerr;
!         if (yerr > xerr)
!             xerr = yerr;
!         if (xerr < besterror)
!         {
              curve_motion_xbase = xval;
              curve_motion_ybase = yval;
--- 6638,6651 ----
      int besterror = 0x7fffffff;
      t_fielddesc *f;
!     if (!fielddesc_getfloat(&x->x_vis, template, data, 0)) return 0;
!     for (i = 0, f = x->x_vec; i < n; i++, f += 2) {
!         int xval = fielddesc_getcoord(f, template, data, 0),   xloc = glist_xtopixels(glist, basex + xval);
!         int yval = fielddesc_getcoord(f+1, template, data, 0), yloc = glist_ytopixels(glist, basey + yval);
          int xerr = xloc - xpix, yerr = yloc - ypix;
!         if (!f->fd_var && !(f+1)->fd_var) continue;
!         if (xerr < 0) xerr = -xerr;
!         if (yerr < 0) yerr = -yerr;
!         if (yerr > xerr) xerr = yerr;
!         if (xerr < besterror) {
              curve_motion_xbase = xval;
              curve_motion_ybase = yval;
***************
*** 6705,6716 ****
          }
      }
!     if (besterror > 10)
!         return (0);
!     if (doit)
!     {
!         curve_motion_xper = glist_pixelstox(glist, 1)
!             - glist_pixelstox(glist, 0);
!         curve_motion_yper = glist_pixelstoy(glist, 1)
!             - glist_pixelstoy(glist, 0);
          curve_motion_xcumulative = 0;
          curve_motion_ycumulative = 0;
--- 6654,6661 ----
          }
      }
!     if (besterror > 10) return 0;
!     if (doit) {
!         curve_motion_xper = glist_pixelstox(glist, 1) - glist_pixelstox(glist, 0);
!         curve_motion_yper = glist_pixelstoy(glist, 1) - glist_pixelstoy(glist, 0);
          curve_motion_xcumulative = 0;
          curve_motion_ycumulative = 0;
***************
*** 6721,6731 ****
          curve_motion_field = 2*bestn;
          curve_motion_template = template;
!         glist_grab(glist, z, curve_motion, 0, xpix, ypix);
      }
!     return (1);
  }
  
! t_parentwidgetbehavior curve_widgetbehavior =
! {
      curve_getrect,
      curve_displace,
--- 6666,6675 ----
          curve_motion_field = 2*bestn;
          curve_motion_template = template;
!         /* glist_grab(glist, z, curve_motion, 0, xpix, ypix); */
      }
!     return 1;
  }
  
! t_parentwidgetbehavior curve_widgetbehavior = {
      curve_getrect,
      curve_displace,
***************
*** 6736,6746 ****
  };
  
! static void curve_free(t_curve *x)
! {
      t_freebytes(x->x_vec, 2 * x->x_npoints * sizeof(*x->x_vec));
  }
  
! static void curve_setup(void)
! {
      curve_class = class_new(gensym("drawpolygon"), (t_newmethod)curve_new,
          (t_method)curve_free, sizeof(t_curve), 0, A_GIMME, 0);
--- 6680,6688 ----
  };
  
! static void curve_free(t_curve *x) {
      t_freebytes(x->x_vec, 2 * x->x_npoints * sizeof(*x->x_vec));
  }
  
! static void curve_setup(void) {
      curve_class = class_new(gensym("drawpolygon"), (t_newmethod)curve_new,
          (t_method)curve_free, sizeof(t_curve), 0, A_GIMME, 0);
***************
*** 7406,7411 ****
      probably by attaching a gpointer here ... */
  
! static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy)
! {
      t_drawnumber *x = (t_drawnumber *)z;
      t_fielddesc *f = &x->x_value;
--- 7348,7353 ----
      probably by attaching a gpointer here ... */
  
! #if 0
! static void drawnumber_motion(void *z, t_floatarg dx, t_floatarg dy) {
      t_drawnumber *x = (t_drawnumber *)z;
      t_fielddesc *f = &x->x_value;
***************
*** 7416,7419 ****
--- 7358,7362 ----
      if (drawnumber_motion_array)   array_redraw(drawnumber_motion_array, drawnumber_motion_glist);
  }
+ #endif
  
  static int drawnumber_click(t_gobj *z, t_glist *glist, 
***************
*** 7437,7441 ****
              drawnumber_motion_ycumulative =
                  fielddesc_getfloat(&x->x_value, template, data, 0);
!             glist_grab(glist, z, drawnumber_motion, 0, xpix, ypix);
          }
          return 1;
--- 7380,7384 ----
              drawnumber_motion_ycumulative =
                  fielddesc_getfloat(&x->x_value, template, data, 0);
!             /* glist_grab(glist, z, drawnumber_motion, 0, xpix, ypix); */
          }
          return 1;





More information about the Pd-cvs mailing list