[PD-cvs] SF.net SVN: pure-data: [9744] trunk/externals/iem/iemguts/src
zmoelnig at users.sourceforge.net
zmoelnig at users.sourceforge.net
Wed Apr 30 19:52:29 CEST 2008
Revision: 9744
http://pure-data.svn.sourceforge.net/pure-data/?rev=9744&view=rev
Author: zmoelnig
Date: 2008-04-30 10:52:29 -0700 (Wed, 30 Apr 2008)
Log Message:
-----------
added new object [parentposition] that will output
the position of the containing abstraction within
it's parent-patch
Modified Paths:
--------------
trunk/externals/iem/iemguts/src/Makefile
Added Paths:
-----------
trunk/externals/iem/iemguts/src/parentposition.c
Modified: trunk/externals/iem/iemguts/src/Makefile
===================================================================
--- trunk/externals/iem/iemguts/src/Makefile 2008-04-28 21:25:29 UTC (rev 9743)
+++ trunk/externals/iem/iemguts/src/Makefile 2008-04-30 17:52:29 UTC (rev 9744)
@@ -3,7 +3,7 @@
# path to pd
## change this according to your setup!
-PDROOT?=../../pd
+PDROOT?=../../../../pd
#PDROOT=/home/zmoelnig/src/pd/
# here we find the sources of pd (and evtl. the pd.lib)
Added: trunk/externals/iem/iemguts/src/parentposition.c
===================================================================
--- trunk/externals/iem/iemguts/src/parentposition.c (rev 0)
+++ trunk/externals/iem/iemguts/src/parentposition.c 2008-04-30 17:52:29 UTC (rev 9744)
@@ -0,0 +1,98 @@
+
+/******************************************************
+ *
+ * parentposition - implementation file
+ *
+ * copyleft (c) IOhannes m zm\xF6lnig
+ *
+ * 2007:forum::f\xFCr::uml\xE4ute:2007
+ *
+ * institute of electronic music and acoustics (iem)
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+
+/*
+ * this object provides a way to get the position of the containing abstraction
+ * within the parent-patch
+ */
+
+#include "m_pd.h"
+
+#include "g_canvas.h"
+#include "m_imp.h"
+
+/* ------------------------- parentposition ---------------------------- */
+
+static t_class *parentposition_class;
+
+typedef struct _parentposition
+{
+ t_object x_obj;
+ t_canvas *x_canvas;
+
+ t_outlet*xoutlet, *youtlet;
+} t_parentposition;
+
+static void parentposition_bang(t_parentposition *x)
+{
+ t_canvas*c=x->x_canvas;
+ t_canvas*c0=0;
+
+ int x1=0, y1=0, width=0, height=0;
+ t_atom alist[2];
+
+ if(!c) return;
+
+
+ x1=c->gl_obj.te_xpix;
+ y1=c->gl_obj.te_ypix;
+
+
+ c0=c->gl_owner;
+ if(c0!=0) {
+ width= (int)(c0->gl_screenx2 - c0->gl_screenx1);
+ height=(int)(c0->gl_screeny2 - c0->gl_screeny1);
+ }
+
+ SETFLOAT(alist, (t_float)width);
+ SETFLOAT(alist+1, (t_float)height);
+ outlet_list(x->youtlet, 0, 2, alist);
+
+ // outlet_float(x->youtlet, y1);
+ SETFLOAT(alist, (t_float)x1);
+ SETFLOAT(alist+1, (t_float)y1);
+ outlet_list(x->xoutlet, 0, 2, alist);
+
+}
+
+static void parentposition_free(t_parentposition *x)
+{
+ outlet_free(x->xoutlet);
+ outlet_free(x->youtlet);
+}
+
+static void *parentposition_new(void)
+{
+ t_parentposition *x = (t_parentposition *)pd_new(parentposition_class);
+ t_glist *glist=(t_glist *)canvas_getcurrent();
+ t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
+
+ x->x_canvas = canvas;
+
+ x->xoutlet=outlet_new(&x->x_obj, &s_list);
+ x->youtlet=outlet_new(&x->x_obj, &s_list);
+
+ return (x);
+}
+
+void parentposition_setup(void)
+{
+ parentposition_class = class_new(gensym("parentposition"), (t_newmethod)parentposition_new,
+ (t_method)parentposition_free, sizeof(t_parentposition), 0, 0);
+ class_addbang(parentposition_class, (t_method)parentposition_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