aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2008-07-29 12:20:52 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2008-07-29 12:20:52 +0000
commit330173fc6f2897c2b15b523ea5ee9679bd5ca045 (patch)
tree362e812b4451b1acb63128d20c5d72265d18dde3 /src
parent14a08e3d8a694b7fb718717130d4ff69d14243fb (diff)
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 svn path=/trunk/externals/iem/iemguts/; revision=10225
Diffstat (limited to 'src')
-rw-r--r--src/canvasconnections.c7
-rw-r--r--src/canvasdollarzero.c58
-rw-r--r--src/canvasindex.c25
-rw-r--r--src/parentposition.c27
-rw-r--r--src/propertybang.c22
5 files changed, 114 insertions, 25 deletions
diff --git a/src/canvasconnections.c b/src/canvasconnections.c
index 260e946..cebd085 100644
--- a/src/canvasconnections.c
+++ b/src/canvasconnections.c
@@ -110,7 +110,6 @@ static void *canvasconnections_new(t_floatarg f)
depth--;
}
-
if(canvas) {
x->x_object = pd_checkobject((t_pd*)canvas);
x->x_parent = canvas->gl_owner;
@@ -123,7 +122,9 @@ static void *canvasconnections_new(t_floatarg f)
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);
}
diff --git a/src/canvasdollarzero.c b/src/canvasdollarzero.c
new file mode 100644
index 0000000..6a43eb9
--- /dev/null
+++ b/src/canvasdollarzero.c
@@ -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);
+}
diff --git a/src/canvasindex.c b/src/canvasindex.c
index 8092351..2ebd6d8 100644
--- a/src/canvasindex.c
+++ b/src/canvasindex.c
@@ -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 @@ static void canvasindex_bang(t_canvasindex *x)
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 @@ static void canvasindex_free(t_canvasindex *x)
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 @@ static void *canvasindex_new(void)
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);
}
diff --git a/src/parentposition.c b/src/parentposition.c
index 7f25951..086c902 100644
--- a/src/parentposition.c
+++ b/src/parentposition.c
@@ -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 @@ typedef struct _parentposition
{
t_object x_obj;
t_canvas *x_canvas;
- t_glist *x_glist;
t_outlet*xoutlet, *youtlet;
} t_parentposition;
@@ -107,14 +112,20 @@ static void parentposition_free(t_parentposition *x)
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 @@ static void *parentposition_new(void)
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);
}
diff --git a/src/propertybang.c b/src/propertybang.c
index d994582..63d541a 100644
--- a/src/propertybang.c
+++ b/src/propertybang.c
@@ -48,15 +48,21 @@ static void propertybang_free(t_propertybang *x)
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 @@ void propertybang_setup(void)
{
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);
}