[PD-cvs] SF.net SVN: pure-data:[10225] trunk/externals/iem/iemguts/src

zmoelnig at users.sourceforge.net zmoelnig at users.sourceforge.net
Tue Jul 29 14:20:52 CEST 2008


Revision: 10225
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10225&view=rev
Author:   zmoelnig
Date:     2008-07-29 12:20:52 +0000 (Tue, 29 Jul 2008)

Log Message:
-----------
added new object [canvasdollarzero] which is a clone of 
iemlib2's [parentdollarzero] with the added feature of 
allowing you to specify the depth of the parent.
depthified other objects

Modified Paths:
--------------
    trunk/externals/iem/iemguts/src/canvasconnections.c
    trunk/externals/iem/iemguts/src/canvasindex.c
    trunk/externals/iem/iemguts/src/parentposition.c
    trunk/externals/iem/iemguts/src/propertybang.c

Added Paths:
-----------
    trunk/externals/iem/iemguts/src/canvasdollarzero.c

Modified: trunk/externals/iem/iemguts/src/canvasconnections.c
===================================================================
--- trunk/externals/iem/iemguts/src/canvasconnections.c	2008-07-29 05:18:59 UTC (rev 10224)
+++ trunk/externals/iem/iemguts/src/canvasconnections.c	2008-07-29 12:20:52 UTC (rev 10225)
@@ -110,7 +110,6 @@
     depth--;
   }
 
-
   if(canvas) {
     x->x_object = pd_checkobject((t_pd*)canvas);
     x->x_parent = canvas->gl_owner;
@@ -123,7 +122,9 @@
 
 void canvasconnections_setup(void)
 {
-  canvasconnections_class = class_new(gensym("canvasconnections"), (t_newmethod)canvasconnections_new,
-                               (t_method)canvasconnections_free, sizeof(t_canvasconnections), 0, A_DEFFLOAT, 0);
+  canvasconnections_class = class_new(gensym("canvasconnections"), 
+                                      (t_newmethod)canvasconnections_new, (t_method)canvasconnections_free, 
+                                      sizeof(t_canvasconnections), 0, 
+                                      A_DEFFLOAT, 0);
   class_addbang(canvasconnections_class, (t_method)canvasconnections_bang);
 }

Copied: trunk/externals/iem/iemguts/src/canvasdollarzero.c (from rev 10224, trunk/externals/iemlib/iemlib2/src/parentdollarzero.c)
===================================================================
--- trunk/externals/iem/iemguts/src/canvasdollarzero.c	                        (rev 0)
+++ trunk/externals/iem/iemguts/src/canvasdollarzero.c	2008-07-29 12:20:52 UTC (rev 10225)
@@ -0,0 +1,58 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+based on iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+
+
+#include "m_pd.h"
+#include "g_canvas.h"
+
+
+/* -------------- canvasdollarzero --------------- */
+/* -- receives the $0 value of the parent canvas --*/
+
+static t_class *canvasdollarzero_class;
+
+typedef struct _canvasdollarzero
+{
+  t_object     x_obj;
+  t_symbol     *s_dollzero;
+} t_canvasdollarzero;
+
+static void canvasdollarzero_bang(t_canvasdollarzero *x)
+{
+  if(x->s_dollzero)
+    outlet_symbol(x->x_obj.ob_outlet, x->s_dollzero);
+}
+
+static void *canvasdollarzero_new(t_floatarg f)
+{
+  t_canvasdollarzero *x = (t_canvasdollarzero *)pd_new(canvasdollarzero_class);
+
+  t_glist *glist=(t_glist *)canvas_getcurrent();
+  t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
+  int depth=(int)f;
+
+  if(depth<0)depth=0;
+  while(depth && canvas) {
+    canvas=canvas->gl_owner;
+    depth--;
+  }
+
+  x->s_dollzero=0;
+  if(canvas) {
+    x->s_dollzero = canvas_realizedollar(canvas, gensym("$0"));
+  }
+
+  outlet_new(&x->x_obj, &s_symbol);
+  return (x);
+}
+
+void canvasdollarzero_setup(void)
+{
+  canvasdollarzero_class = class_new(gensym("canvasdollarzero"), 
+                                     (t_newmethod)canvasdollarzero_new, 0, 
+                                     sizeof(t_canvasdollarzero), 0, 
+                                     A_DEFFLOAT, 0);
+  class_addbang(canvasdollarzero_class, (t_method)canvasdollarzero_bang);
+}


Property changes on: trunk/externals/iem/iemguts/src/canvasdollarzero.c
___________________________________________________________________
Added: svn:mergeinfo
   + 

Modified: trunk/externals/iem/iemguts/src/canvasindex.c
===================================================================
--- trunk/externals/iem/iemguts/src/canvasindex.c	2008-07-29 05:18:59 UTC (rev 10224)
+++ trunk/externals/iem/iemguts/src/canvasindex.c	2008-07-29 12:20:52 UTC (rev 10225)
@@ -20,6 +20,11 @@
  * this object provides a way to get the position of the containing abstraction
  * within the parent-patch
  * this makes it easy to (dis)connect this abstraction to others
+ *
+ * by default the index of the containing abstraction within the parent-patch is 
+ * queried; however you can give the "depth" as argument:
+ * e.g. [canvasindex 1] will give you the index of the abstraction containing the
+ * abstraction that holds this object
  */
 
 #include "m_pd.h"
@@ -44,14 +49,10 @@
   t_canvas*c=x->x_canvas;
   t_canvas*c0=0;
 
-  //  int index=-1;
-
   if(!c) return;
   c0=c->gl_owner;
   if(!c0)return;
 
-  //  index=glist_getindex(c0, c);
-  //  index=glist_getindex(c0, (t_gobj*)c);
   outlet_float(x->youtlet, (t_float)(glist_getindex(c0, 0)));
   outlet_float(x->xoutlet, (t_float)(glist_getindex(c0, (t_gobj*)c)));
 }
@@ -62,12 +63,20 @@
   outlet_free(x->youtlet);
 }
 
-static void *canvasindex_new(void)
+static void *canvasindex_new(t_floatarg f)
 {
   t_canvasindex *x = (t_canvasindex *)pd_new(canvasindex_class);
   t_glist *glist=(t_glist *)canvas_getcurrent();
   t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
 
+  int depth=(int)f;
+
+  if(depth<0)depth=0;
+  while(depth && canvas) {
+    canvas=canvas->gl_owner;
+    depth--;
+  }
+
   x->x_canvas = canvas;
 
   x->xoutlet=outlet_new(&x->x_obj, &s_float);
@@ -78,7 +87,9 @@
 
 void canvasindex_setup(void)
 {
-  canvasindex_class = class_new(gensym("canvasindex"), (t_newmethod)canvasindex_new,
-    (t_method)canvasindex_free, sizeof(t_canvasindex), 0, 0);
+  canvasindex_class = class_new(gensym("canvasindex"), 
+                                (t_newmethod)canvasindex_new, (t_method)canvasindex_free, 
+                                sizeof(t_canvasindex), 0, 
+                                A_DEFFLOAT, 0);
   class_addbang(canvasindex_class, (t_method)canvasindex_bang);
 }

Modified: trunk/externals/iem/iemguts/src/parentposition.c
===================================================================
--- trunk/externals/iem/iemguts/src/parentposition.c	2008-07-29 05:18:59 UTC (rev 10224)
+++ trunk/externals/iem/iemguts/src/parentposition.c	2008-07-29 12:20:52 UTC (rev 10225)
@@ -17,8 +17,14 @@
 
 
 /* 
- * this object provides a way to get the position of the containing abstraction
- * within the parent-patch
+ * this object provides a way to get and set the position of the containing
+ * abstraction within the parent-patch
+ *
+ * by default the position of the containing abstraction within the parent-patch is 
+ * queried
+ * you can give the "depth" as argument;
+ * e.g. [parentposition 1] will set/get the position of the abstraction containing the
+ * abstraction within its canvas.
  */
 
 #include "m_pd.h"
@@ -34,7 +40,6 @@
 {
   t_object  x_obj;
   t_canvas  *x_canvas;
-  t_glist  *x_glist;
 
   t_outlet*xoutlet, *youtlet;
 } t_parentposition;
@@ -107,14 +112,20 @@
   outlet_free(x->youtlet);
 }
 
-static void *parentposition_new(void)
+static void *parentposition_new(t_floatarg f)
 {
   t_parentposition *x = (t_parentposition *)pd_new(parentposition_class);
   t_glist *glist=(t_glist *)canvas_getcurrent();
   t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
+  int depth=(int)f;
 
+  if(depth<0)depth=0;
+  while(depth && canvas) {
+    canvas=canvas->gl_owner;
+    depth--;
+  }
+
   x->x_canvas = canvas;
-  x->x_glist  = glist;
 
   x->xoutlet=outlet_new(&x->x_obj, &s_list);
   x->youtlet=outlet_new(&x->x_obj, &s_list);
@@ -124,8 +135,10 @@
 
 void parentposition_setup(void)
 {
-  parentposition_class = class_new(gensym("parentposition"), (t_newmethod)parentposition_new,
-    (t_method)parentposition_free, sizeof(t_parentposition), 0, 0);
+  parentposition_class = class_new(gensym("parentposition"), 
+                                   (t_newmethod)parentposition_new, (t_method)parentposition_free, 
+                                   sizeof(t_parentposition), 0,
+                                   A_DEFFLOAT, 0);
   class_addbang(parentposition_class, (t_method)parentposition_bang);
   class_addlist(parentposition_class, (t_method)parentposition_list);
 }

Modified: trunk/externals/iem/iemguts/src/propertybang.c
===================================================================
--- trunk/externals/iem/iemguts/src/propertybang.c	2008-07-29 05:18:59 UTC (rev 10224)
+++ trunk/externals/iem/iemguts/src/propertybang.c	2008-07-29 12:20:52 UTC (rev 10225)
@@ -48,16 +48,22 @@
   pd_unbind(&x->x_obj.ob_pd, x->x_d0name);
 }
 
-static void propertybang_anything(t_propertybang *x, t_symbol*s, int argc, t_atom*argv) {
-  if(s==&s_bang && argc==0) {
-    outlet_bang(x->x_obj.ob_outlet);
-  }
+static void propertybang_bang(t_propertybang *x) {
+  outlet_bang(x->x_obj.ob_outlet);
 }
-
 static void propertybang_properties(t_gobj*z, t_glist*owner) {
-  // argh: z is the abstraction! but we need to access ourselfs!
-  // we handle this by binding to a special symbol. e.g. "$0-propertybang"
+  /* argh: z is the abstraction! but we need to access ourselfs!
+   * we handle this by binding to a special symbol. e.g. "$0 propertybang"
+   * (we use the space between in order to make it hard for the ordinary user 
+   * to use this symbol for other things...
+   */
 
+  /* alternatively we could just search the abstraction for all instances of propertybang_class
+   * and bang these;
+   * but using the pd_bind-trick is simpler for now
+   * though not as sweet, as somebody could use our bind-symbol for other things...
+   */
+
   t_symbol*s_d0name=canvas_realizedollar((t_canvas*)z, gensym("$0 propertybang"));
     pd_bang(s_d0name->s_thing);
 }
@@ -82,5 +88,5 @@
 {
   propertybang_class = class_new(gensym("propertybang"), (t_newmethod)propertybang_new,
     (t_method)propertybang_free, sizeof(t_propertybang), CLASS_NOINLET, 0);
-  class_addanything(propertybang_class, propertybang_anything);
+  class_addbang(propertybang_class, propertybang_bang);
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list