diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2009-11-10 21:08:48 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2009-11-10 21:08:48 +0000 |
commit | 49180536552f487ca12e2173a93aae6a17ccfcca (patch) | |
tree | 93c9729987034227e1283c16380397bc1f957a49 | |
parent | 33b135d7fc381a22965586e0567ede4da11eade3 (diff) |
split out the objects in x_gui.c into standalone files and put the gfxstub stuff into e_gfxstub.c
svn path=/trunk/; revision=12749
-rw-r--r-- | externals/vanilla/LICENSE.txt | 30 | ||||
-rw-r--r-- | externals/vanilla/Makefile | 4 | ||||
-rw-r--r-- | externals/vanilla/e_gfxstub.c | 174 | ||||
-rwxr-xr-x | externals/vanilla/generate.sh | 2 | ||||
-rw-r--r-- | externals/vanilla/key.c | 43 | ||||
-rw-r--r-- | externals/vanilla/keyname.c | 50 | ||||
-rw-r--r-- | externals/vanilla/keyup.c | 43 | ||||
-rw-r--r-- | externals/vanilla/lib_x_gui.c | 5 | ||||
-rw-r--r-- | externals/vanilla/openpanel.c | 62 | ||||
-rw-r--r-- | externals/vanilla/savepanel.c | 63 |
10 files changed, 469 insertions, 7 deletions
diff --git a/externals/vanilla/LICENSE.txt b/externals/vanilla/LICENSE.txt new file mode 100644 index 00000000..a56a51eb --- /dev/null +++ b/externals/vanilla/LICENSE.txt @@ -0,0 +1,30 @@ +This software is copyrighted by Miller Puckette and others. The following +terms (the "Standard Improved BSD License") apply to all files associated with +the software unless explicitly disclaimed in individual files: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/externals/vanilla/Makefile b/externals/vanilla/Makefile index 5c635ff0..390c6d46 100644 --- a/externals/vanilla/Makefile +++ b/externals/vanilla/Makefile @@ -4,7 +4,7 @@ LIBRARY_NAME = vanilla # Next, add your source files to the SOURCES variable. -SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c exp~.c ftom~.c hradio.c hsl.c list.c log~.c mtof~.c nbx.c powtodb~.c pow~.c print.c qlist.c rmstodb~.c rsqrt~.c sqrt~.c textfile.c tgl.c vradio.c vslider.c vu.c wrap~.c +SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c exp~.c ftom~.c hradio.c hsl.c key.c keyname.c keyup.c list.c log~.c mtof~.c nbx.c openpanel.c powtodb~.c pow~.c print.c qlist.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c vradio.c vslider.c vu.c wrap~.c # For objects that only build on certain platforms, add those to the SOURCES @@ -132,6 +132,8 @@ install-doc: install -m644 -p $(wildcard *.pd) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) install -m644 -p README $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt install -m644 -p VERSION $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/VERSION.txt + install -m644 -p TODO $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/TODO.txt + install -m644 -p LICENSE $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt install-exec: install -d $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) diff --git a/externals/vanilla/e_gfxstub.c b/externals/vanilla/e_gfxstub.c new file mode 100644 index 00000000..e3321ec9 --- /dev/null +++ b/externals/vanilla/e_gfxstub.c @@ -0,0 +1,174 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* gfxstub stuff from pd-vanilla's x_gui.c */ + +/* dialogs. LATER, deal with the situation where the object goes +away before the panel does... */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +/* --------------------- graphics responder ---------------- */ + +/* make one of these if you want to put up a dialog window but want to be +protected from getting deleted and then having the dialog call you back. In +this design the calling object doesn't have to keep the address of the dialog +window around; instead we keep a list of all open dialogs. Any object that +might have dialogs, when it is deleted, simply checks down the dialog window +list and breaks off any dialogs that might later have sent messages to it. +Only when the dialog window itself closes do we delete the gfxstub object. */ + +static t_class *gfxstub_class; + +typedef struct _gfxstub +{ + t_pd x_pd; + t_pd *x_owner; + void *x_key; + t_symbol *x_sym; + struct _gfxstub *x_next; +} t_gfxstub; + +static t_gfxstub *gfxstub_list; + + /* create a new one. the "key" is an address by which the owner + will identify it later; if the owner only wants one dialog, this + could just be a pointer to the owner itself. The string "cmd" + is a TK command to create the dialog, with "%s" embedded in + it so we can provide a name by which the GUI can send us back + messages; e.g., "pdtk_canvas_dofont %s 10". */ + +void gfxstub_new(t_pd *owner, void *key, const char *cmd) +{ + char buf[4*MAXPDSTRING]; + char namebuf[80]; + t_gfxstub *x; + t_symbol *s; + /* if any exists with matching key, burn it. */ + for (x = gfxstub_list; x; x = x->x_next) + if (x->x_key == key) + gfxstub_deleteforkey(key); + if (strlen(cmd) + 50 > 4*MAXPDSTRING) + { + bug("audio dialog too long"); + bug("%x", cmd); + return; + } + x = (t_gfxstub *)pd_new(gfxstub_class); + sprintf(namebuf, ".gfxstub%lx", (t_int)x); + + s = gensym(namebuf); + pd_bind(&x->x_pd, s); + x->x_owner = owner; + x->x_sym = s; + x->x_key = key; + x->x_next = gfxstub_list; + gfxstub_list = x; + sprintf(buf, cmd, s->s_name); + sys_gui(buf); +} + +static void gfxstub_offlist(t_gfxstub *x) +{ + t_gfxstub *y1, *y2; + if (gfxstub_list == x) + gfxstub_list = x->x_next; + else for (y1 = gfxstub_list; y2 = y1->x_next; y1 = y2) + if (y2 == x) + { + y1->x_next = y2->x_next; + break; + } +} + + /* if the owner disappears, we still may have to stay around until our + dialog window signs off. Anyway we can now tell the GUI to destroy the + window. */ +void gfxstub_deleteforkey(void *key) +{ + t_gfxstub *y; + int didit = 1; + while (didit) + { + didit = 0; + for (y = gfxstub_list; y; y = y->x_next) + { + if (y->x_key == key) + { + sys_vgui("destroy .gfxstub%lx\n", y); + y->x_owner = 0; + gfxstub_offlist(y); + didit = 1; + break; + } + } + } +} + +/* --------- pd messages for gfxstub (these come from the GUI) ---------- */ + + /* "cancel" to request that we close the dialog window. */ +static void gfxstub_cancel(t_gfxstub *x) +{ + gfxstub_deleteforkey(x->x_key); +} + + /* "signoff" comes from the GUI to say the dialog window closed. */ +static void gfxstub_signoff(t_gfxstub *x) +{ + gfxstub_offlist(x); + pd_free(&x->x_pd); +} + +static t_binbuf *gfxstub_binbuf; + + /* a series of "data" messages rebuilds a scalar */ +static void gfxstub_data(t_gfxstub *x, t_symbol *s, int argc, t_atom *argv) +{ + if (!gfxstub_binbuf) + gfxstub_binbuf = binbuf_new(); + binbuf_add(gfxstub_binbuf, argc, argv); + binbuf_addsemi(gfxstub_binbuf); +} + /* the "end" message terminates rebuilding the scalar */ +static void gfxstub_end(t_gfxstub *x) +{ + canvas_dataproperties((t_canvas *)x->x_owner, + (t_scalar *)x->x_key, gfxstub_binbuf); + binbuf_free(gfxstub_binbuf); + gfxstub_binbuf = 0; +} + + /* anything else is a message from the dialog window to the owner; + just forward it. */ +static void gfxstub_anything(t_gfxstub *x, t_symbol *s, int argc, t_atom *argv) +{ + if (x->x_owner) + pd_typedmess(x->x_owner, s, argc, argv); +} + +static void gfxstub_free(t_gfxstub *x) +{ + pd_unbind(&x->x_pd, x->x_sym); +} + +static void gfxstub_setup(void) +{ + gfxstub_class = class_new(gensym("gfxstub"), 0, (t_method)gfxstub_free, + sizeof(t_gfxstub), CLASS_PD, 0); + class_addanything(gfxstub_class, gfxstub_anything); + class_addmethod(gfxstub_class, (t_method)gfxstub_signoff, + gensym("signoff"), 0); + class_addmethod(gfxstub_class, (t_method)gfxstub_data, + gensym("data"), A_GIMME, 0); + class_addmethod(gfxstub_class, (t_method)gfxstub_end, + gensym("end"), 0); + class_addmethod(gfxstub_class, (t_method)gfxstub_cancel, + gensym("cancel"), 0); +} diff --git a/externals/vanilla/generate.sh b/externals/vanilla/generate.sh index a57e200f..e7bc5a4e 100755 --- a/externals/vanilla/generate.sh +++ b/externals/vanilla/generate.sh @@ -24,4 +24,4 @@ rm lib_d_fftroutine.c lib_d_fft_mayer.c lib_d_resample.c rm lib_d_fft_fftw.c lib_d_fft_fftsg.c lib_d_fftsg_h.c # these files have been split out into separate files per object -rm lib_x_interface.c lib_x_qlist.c +rm lib_x_interface.c lib_x_qlist.c lib_x_gui.c diff --git a/externals/vanilla/key.c b/externals/vanilla/key.c new file mode 100644 index 00000000..d389a9b3 --- /dev/null +++ b/externals/vanilla/key.c @@ -0,0 +1,43 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> + +static t_symbol *key_sym; +static t_class *key_class; + +typedef struct _key +{ + t_object x_obj; +} t_key; + +static void *key_new( void) +{ + t_key *x = (t_key *)pd_new(key_class); + outlet_new(&x->x_obj, &s_float); + pd_bind(&x->x_obj.ob_pd, key_sym); + return (x); +} + +static void key_float(t_key *x, t_floatarg f) +{ + outlet_float(x->x_obj.ob_outlet, f); +} + +static void key_free(t_key *x) +{ + pd_unbind(&x->x_obj.ob_pd, key_sym); +} + +void key_setup(void) +{ + key_class = class_new(gensym("key"), + (t_newmethod)key_new, (t_method)key_free, + sizeof(t_key), CLASS_NOINLET, 0); + class_addfloat(key_class, key_float); + key_sym = gensym("#key"); +} + diff --git a/externals/vanilla/keyname.c b/externals/vanilla/keyname.c new file mode 100644 index 00000000..8834cc30 --- /dev/null +++ b/externals/vanilla/keyname.c @@ -0,0 +1,50 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* dialogs. LATER, deal with the situation where the object goes +away before the panel does... */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> + +static t_symbol *keyname_sym; +static t_class *keyname_class; + +typedef struct _keyname +{ + t_object x_obj; + t_outlet *x_outlet1; + t_outlet *x_outlet2; +} t_keyname; + +static void *keyname_new( void) +{ + t_keyname *x = (t_keyname *)pd_new(keyname_class); + x->x_outlet1 = outlet_new(&x->x_obj, &s_float); + x->x_outlet2 = outlet_new(&x->x_obj, &s_symbol); + pd_bind(&x->x_obj.ob_pd, keyname_sym); + return (x); +} + +static void keyname_list(t_keyname *x, t_symbol *s, int ac, t_atom *av) +{ + outlet_symbol(x->x_outlet2, atom_getsymbolarg(1, ac, av)); + outlet_float(x->x_outlet1, atom_getfloatarg(0, ac, av)); +} + +static void keyname_free(t_keyname *x) +{ + pd_unbind(&x->x_obj.ob_pd, keyname_sym); +} + +void keyname_setup(void) +{ + keyname_class = class_new(gensym("keyname"), + (t_newmethod)keyname_new, (t_method)keyname_free, + sizeof(t_keyname), CLASS_NOINLET, 0); + class_addlist(keyname_class, keyname_list); + keyname_sym = gensym("#keyname"); + class_sethelpsymbol(keyname_class, gensym("key")); +} diff --git a/externals/vanilla/keyup.c b/externals/vanilla/keyup.c new file mode 100644 index 00000000..5034b75a --- /dev/null +++ b/externals/vanilla/keyup.c @@ -0,0 +1,43 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> + +static t_symbol *keyup_sym; +static t_class *keyup_class; + +typedef struct _keyup +{ + t_object x_obj; +} t_keyup; + +static void *keyup_new( void) +{ + t_keyup *x = (t_keyup *)pd_new(keyup_class); + outlet_new(&x->x_obj, &s_float); + pd_bind(&x->x_obj.ob_pd, keyup_sym); + return (x); +} + +static void keyup_float(t_keyup *x, t_floatarg f) +{ + outlet_float(x->x_obj.ob_outlet, f); +} + +static void keyup_free(t_keyup *x) +{ + pd_unbind(&x->x_obj.ob_pd, keyup_sym); +} + +void keyup_setup(void) +{ + keyup_class = class_new(gensym("keyup"), + (t_newmethod)keyup_new, (t_method)keyup_free, + sizeof(t_keyup), CLASS_NOINLET, 0); + class_addfloat(keyup_class, keyup_float); + keyup_sym = gensym("#keyup"); + class_sethelpsymbol(keyup_class, gensym("key")); +} diff --git a/externals/vanilla/lib_x_gui.c b/externals/vanilla/lib_x_gui.c deleted file mode 100644 index d1f20bd8..00000000 --- a/externals/vanilla/lib_x_gui.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "../../pd/src/x_gui.c" -void lib_x_gui_setup(void) -{ - x_gui_setup(); -} diff --git a/externals/vanilla/openpanel.c b/externals/vanilla/openpanel.c new file mode 100644 index 00000000..2efd8dfd --- /dev/null +++ b/externals/vanilla/openpanel.c @@ -0,0 +1,62 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* dialogs. LATER, deal with the situation where the object goes +away before the panel does... */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> + +static t_class *openpanel_class; + +typedef struct _openpanel +{ + t_object x_obj; + t_symbol *x_s; +} t_openpanel; + +static void *openpanel_new( void) +{ + char buf[50]; + t_openpanel *x = (t_openpanel *)pd_new(openpanel_class); + sprintf(buf, "d%lx", (t_int)x); + x->x_s = gensym(buf); + pd_bind(&x->x_obj.ob_pd, x->x_s); + outlet_new(&x->x_obj, &s_symbol); + return (x); +} + +static void openpanel_symbol(t_openpanel *x, t_symbol *s) +{ + char *path = (s && s->s_name) ? s->s_name : "\"\""; + sys_vgui("pdtk_openpanel {%s} {%s}\n", x->x_s->s_name, path); +} + +static void openpanel_bang(t_openpanel *x) +{ + openpanel_symbol(x, &s_); +} + +static void openpanel_callback(t_openpanel *x, t_symbol *s) +{ + outlet_symbol(x->x_obj.ob_outlet, s); +} + + +static void openpanel_free(t_openpanel *x) +{ + pd_unbind(&x->x_obj.ob_pd, x->x_s); +} + +void openpanel_setup(void) +{ + openpanel_class = class_new(gensym("openpanel"), + (t_newmethod)openpanel_new, (t_method)openpanel_free, + sizeof(t_openpanel), 0, 0); + class_addbang(openpanel_class, openpanel_bang); + class_addsymbol(openpanel_class, openpanel_symbol); + class_addmethod(openpanel_class, (t_method)openpanel_callback, + gensym("callback"), A_SYMBOL, 0); +} diff --git a/externals/vanilla/savepanel.c b/externals/vanilla/savepanel.c new file mode 100644 index 00000000..33c8cb8a --- /dev/null +++ b/externals/vanilla/savepanel.c @@ -0,0 +1,63 @@ +/* Copyright (c) 1997-2000 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* dialogs. LATER, deal with the situation where the object goes +away before the panel does... */ + +#include "m_pd.h" +#include <stdio.h> +#include <string.h> + +static t_class *savepanel_class; + +typedef struct _savepanel +{ + t_object x_obj; + t_canvas *x_canvas; + t_symbol *x_s; +} t_savepanel; + +static void *savepanel_new( void) +{ + char buf[50]; + t_savepanel *x = (t_savepanel *)pd_new(savepanel_class); + sprintf(buf, "d%lx", (t_int)x); + x->x_s = gensym(buf); + x->x_canvas = canvas_getcurrent(); + pd_bind(&x->x_obj.ob_pd, x->x_s); + outlet_new(&x->x_obj, &s_symbol); + return (x); +} + +static void savepanel_symbol(t_savepanel *x, t_symbol *s) +{ + char *path = (s && s->s_name) ? s->s_name : "\"\""; + sys_vgui("pdtk_savepanel {%s} {%s}\n", x->x_s->s_name, path); +} + +static void savepanel_bang(t_savepanel *x) +{ + savepanel_symbol(x, &s_); +} + +static void savepanel_callback(t_savepanel *x, t_symbol *s) +{ + outlet_symbol(x->x_obj.ob_outlet, s); +} + +static void savepanel_free(t_savepanel *x) +{ + pd_unbind(&x->x_obj.ob_pd, x->x_s); +} + +void savepanel_setup(void) +{ + savepanel_class = class_new(gensym("savepanel"), + (t_newmethod)savepanel_new, (t_method)savepanel_free, + sizeof(t_savepanel), 0, 0); + class_addbang(savepanel_class, savepanel_bang); + class_addsymbol(savepanel_class, savepanel_symbol); + class_addmethod(savepanel_class, (t_method)savepanel_callback, + gensym("callback"), A_SYMBOL, 0); +} |