aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 18:23:49 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 18:23:49 +0000
commitc45b62641956eea55b98f7bcaba98fd85fc623d3 (patch)
treec7d2a782d59f1b555030888f911e4e91bb98a57a /src
parentf9d32c165a873bab44967fa4b069a7945ecb6f7f (diff)
Modified getdollarzero so it works with the root keyword
svn path=/trunk/externals/tof/; revision=12490
Diffstat (limited to 'src')
-rw-r--r--src/getdollarzero.c69
1 files changed, 40 insertions, 29 deletions
diff --git a/src/getdollarzero.c b/src/getdollarzero.c
index 8a19486..8a7da38 100644
--- a/src/getdollarzero.c
+++ b/src/getdollarzero.c
@@ -1,30 +1,19 @@
-/* (C) 2005 Guenter Geiger */
+// Original object by (C) 2005 Guenter Geiger
+// New version by Thomas Ouellet Fredericks
+
#include "m_pd.h"
#include "g_canvas.h"
-
-/* HACK
-
-struct _glist
-{
- t_object gl_obj; // header in case we're a glist
- t_gobj *gl_list; // the actual data
- struct _gstub *gl_stub; // safe pointer handler
- int gl_valid; // incremented when pointers might be stale
- struct _glist *gl_owner; // parent glist, supercanvas, or 0 if none
-};
-
-END HACK
-
-*/
+#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
+#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT)
typedef struct getdollarzero
{
t_object x_ob;
t_canvas * x_canvas;
t_outlet* x_outlet;
- int x_level;
+ //int x_level;
} t_getdollarzero;
@@ -32,33 +21,55 @@ typedef struct getdollarzero
static void getdollarzero_bang(t_getdollarzero *x)
{
- int i = x->x_level;
- t_canvas* last = x->x_canvas;
-
- while (i>0) {
- i--;
- if (last->gl_owner) last = last->gl_owner;
- }
+
// x->s_parent_unique = canvas_realizedollar((t_canvas *)this_canvas->gl_owner, gensym("$0"));
//outlet_symbol(x->x_outlet,canvas_getdir(last));
- outlet_symbol(x->x_outlet,canvas_realizedollar(last, gensym("$0")));
+ outlet_symbol(x->x_outlet,canvas_realizedollar(x->x_canvas, gensym("$0")));
}
t_class *getdollarzero_class;
-static void *getdollarzero_new(t_floatarg level)
+static void *getdollarzero_new(t_symbol *s, int argc, t_atom *argv)
{
t_getdollarzero *x = (t_getdollarzero *)pd_new(getdollarzero_class);
- x->x_canvas = canvas_getcurrent();
+
+
+ t_canvas* last = canvas_getcurrent();
+
+ if ( argc > 0 && IS_A_FLOAT(argv,0) ) {
+ int i = atom_getfloat(argv);
+
+ while (i>0) {
+ i--;
+ if (last->gl_owner) {
+ last = last->gl_owner;
+ } else {
+ break;
+ }
+ }
+
+ } else if ( argc > 0 && IS_A_SYMBOL(argv,0) && atom_getsymbol(argv) == gensym("root") ) {
+
+ while ( last->gl_owner) {
+
+ last = last->gl_owner;
+ }
+ }
+
+ x->x_canvas = last;
+
+
+
x->x_outlet = outlet_new(&x->x_ob, &s_);
- x->x_level = level;
+
+
return (void *)x;
}
void getdollarzero_setup(void)
{
getdollarzero_class = class_new(gensym("getdollarzero"), (t_newmethod)getdollarzero_new, 0,
- sizeof(t_getdollarzero), 0, A_DEFFLOAT,0);
+ sizeof(t_getdollarzero), 0, A_GIMME,0);
class_addbang(getdollarzero_class, getdollarzero_bang);
}