aboutsummaryrefslogtreecommitdiff
path: root/toxy
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2004-03-09 12:41:22 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2004-03-09 12:41:22 +0000
commitbc5e203f7787980f65f81ddbf69a619ab34fa85e (patch)
tree008164a186948e7821e67e5325c0acc3024f6d98 /toxy
parentd9072a0e0ecb227c9a42dddf027e29a04f080f4e (diff)
toxy alpha6
svn path=/trunk/externals/miXed/; revision=1396
Diffstat (limited to 'toxy')
-rw-r--r--toxy/Makefile6
-rw-r--r--toxy/Makefile.sources5
-rw-r--r--toxy/build_counter2
-rw-r--r--toxy/widget.c53
-rw-r--r--toxy/widgettype.c53
5 files changed, 79 insertions, 40 deletions
diff --git a/toxy/Makefile b/toxy/Makefile
index 1718111..a9b675c 100644
--- a/toxy/Makefile
+++ b/toxy/Makefile
@@ -1,6 +1,6 @@
ROOT_DIR = ..
-redefault: default.wiq default
-default.wiq: $(ROOT_DIR)/test/toxy/default.wid
+redefault: setup.wiq default
+setup.wiq: $(ROOT_DIR)/test/toxy/setup.wid
$(ROOT_DIR)/quoteinitializer $< \
- '"puts [concat loading built-in widget definitions]\n"' > $@
+ '"puts stderr [concat loading built-in widget definitions]\n"' > $@
include $(ROOT_DIR)/Makefile.common
diff --git a/toxy/Makefile.sources b/toxy/Makefile.sources
index 1626cd6..8befa8d 100644
--- a/toxy/Makefile.sources
+++ b/toxy/Makefile.sources
@@ -1,4 +1,9 @@
+# this conditional will make sense LATER, when TCL_LIB is ./configured
+ifdef TCL_LIB
TYPES = TOT TOW WIDGET PLUSTOT
+else
+TYPES = TOT TOW WIDGET
+endif
TOT_SOURCES = tot.c
TOW_SOURCES = tow.c
diff --git a/toxy/build_counter b/toxy/build_counter
index 2e12651..7f25b3b 100644
--- a/toxy/build_counter
+++ b/toxy/build_counter
@@ -1,3 +1,3 @@
#define TOXY_VERSION "0.1"
#define TOXY_RELEASE "alpha"
-#define TOXY_BUILD 4
+#define TOXY_BUILD 6
diff --git a/toxy/widget.c b/toxy/widget.c
index 03be25d..9d1413a 100644
--- a/toxy/widget.c
+++ b/toxy/widget.c
@@ -1,7 +1,9 @@
-/* Copyright (c) 2003 krzYszcz and others.
+/* Copyright (c) 2003-2004 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+/* LATER consider supporting a special @ini handler, also think about
+ differentiating 'ini' from 'vis' */
/* LATER think about reloading method for .wid files */
#include <stdio.h>
@@ -164,6 +166,10 @@ static void widget_postatoms(char *msg, int ac, t_atom *av)
has to be scheduled through a 'transclock', instead. When the clock
fires, the widget object creates, and glist_adds a 'makeshift' text
object, then glist_deletes itself. */
+
+/* this lock prevents glist_noselect() from reevaluating failure boxes */
+static int widget_transforming = 0;
+
/* LATER also bind this to F4 or something */
static void widget_transtick(t_widget *x)
{
@@ -173,6 +179,8 @@ static void widget_transtick(t_widget *x)
t_atom *opt = props_getall(x->x_options, &nopt);
t_atom *hnd = props_getall(x->x_handlers, &nhnd);
t_atom *arg = props_getall(x->x_arguments, &narg);
+ if (widget_transforming++)
+ bug("widget_transtick");
binbuf_addv(bb, "sss", gensym("widget"), x->x_type, x->x_name);
if (narg) binbuf_add(bb, narg, arg);
if (nopt) binbuf_add(bb, nopt, opt);
@@ -195,6 +203,7 @@ static void widget_transtick(t_widget *x)
canvas_unsetcurrent(x->x_glist);
canvas_dirty(x->x_glist, 1);
glist_delete(x->x_glist, (t_gobj *)x);
+ widget_transforming--;
}
/* FIXME x_glist field validation against glist parameter (all handlers) */
@@ -419,6 +428,12 @@ static t_widgetbehavior widget_behavior =
FORKY_WIDGETPADDING
};
+static void widget_novis(t_widget *x)
+{
+ sys_vgui("::toxy::itemdestroy %s %s\n",
+ widget_getmypathname(x, x->x_glist)->s_name, x->x_varname->s_name);
+}
+
static void widget_update(t_widget *x, t_props *op)
{
if (op == x->x_options)
@@ -435,7 +450,7 @@ static void widget_update(t_widget *x, t_props *op)
{
if (x->x_update == WIDGET_REVIS)
{
- widget_vis((t_gobj *)x, x->x_glist, 0);
+ widget_novis(x);
widget_vis((t_gobj *)x, x->x_glist, 1);
}
else if (x->x_update == WIDGET_PUSHVIS)
@@ -475,9 +490,9 @@ static t_symbol *widget_addprops(t_widget *x, t_props *op, int single,
static t_symbol *widget_addmessage(t_widget *x, t_symbol *s, int ac, t_atom *av)
{
t_symbol *empty;
- if (!(empty = widget_addprops(x, x->x_options, 0, s, ac, av)) &&
+ if (!(empty = widget_addprops(x, x->x_arguments, 0, s, ac, av)) &&
!(empty = widget_addprops(x, x->x_handlers, 0, s, ac, av)))
- empty = widget_addprops(x, x->x_arguments, 0, s, ac, av);
+ empty = widget_addprops(x, x->x_options, 0, s, ac, av);
return (empty);
}
@@ -488,7 +503,13 @@ static void widget_anything(t_widget *x, t_symbol *s, int ac, t_atom *av)
if (*s->s_name == '-' || *s->s_name == '@' || *s->s_name == '#')
{
t_symbol *empty;
- x->x_update = WIDGET_PUSHVIS;
+ /* FIXME mixed messages */
+ if (*s->s_name == '-')
+ x->x_update = WIDGET_PUSHVIS;
+ else if (*s->s_name == '#')
+ x->x_update = WIDGET_REVIS;
+ else
+ x->x_update = WIDGET_NOVIS;
if (empty = widget_addmessage(x, s, ac, av))
loud_errand((t_pd *)x,
"(use 'remove %s' if that is what you want).",
@@ -672,9 +693,12 @@ static void widget_refresh(t_widget *x)
static void widget__failure(t_widget *x, t_symbol *s, int ac, t_atom *av)
{
+#if 0
+ /* moved to the gui side, in order to alow special chars in error message */
startpost("tcl error:");
postatom(ac, av);
endpost();
+#endif
loud_error((t_pd *)x, "creation failure");
x->x_vised = 0;
clock_delay(x->x_transclock, 0);
@@ -859,8 +883,7 @@ static void gui_unbind(t_pd *x, t_symbol *s)
static void widget_free(t_widget *x)
{
- sys_vgui("::toxy::itemdestroy %s %s\n",
- widget_getmypathname(x, x->x_glist)->s_name, x->x_varname->s_name);
+ widget_novis(x);
gui_unbind((t_pd *)x, x->x_cbtarget);
gui_unbind((t_pd *)x, x->x_rptarget);
props_freeall(x->x_options);
@@ -875,9 +898,12 @@ static void widget_free(t_widget *x)
static void *widget_new(t_symbol *s, int ac, t_atom *av)
{
- t_widget *x = (t_widget *)pd_new(widget_class);
+ t_widget *x;
char buf[MAXPDSTRING];
+ if (widget_transforming)
+ return (0);
masterwidget_initialize();
+ x = (t_widget *)pd_new(widget_class);
x->x_type = 0;
x->x_name = 0;
if (ac && av->a_type == A_SYMBOL)
@@ -904,11 +930,11 @@ static void *widget_new(t_symbol *s, int ac, t_atom *av)
sprintf(buf, "%s%x.rp", x->x_name->s_name, (int)x);
pd_bind((t_pd *)x, x->x_rptarget = gensym(buf));
+ x->x_glist = canvas_getcurrent();
x->x_typedef = widgettype_get(x->x_type);
if (!(x->x_tkclass = widgettype_tkclass(x->x_typedef)))
x->x_tkclass = x->x_type;
- x->x_glist = canvas_getcurrent();
sprintf(buf, ".x%x.c", (int)x->x_glist);
x->x_cvpathname = gensym(buf);
sprintf(buf, ".x%x", (int)x->x_glist);
@@ -931,9 +957,12 @@ static void *widget_new(t_symbol *s, int ac, t_atom *av)
widget_propsresolver);
outlet_new((t_object *)x, &s_anything);
- /* LATER consider estimating these, based on widget class and options */
- x->x_width = 50;
- x->x_height = 50;
+ /* LATER consider estimating these, based on widget class and options.
+ The default used to be 50x50, which confused people wanting widgets
+ in small gops, of size exactly as specified by the 'coords' message,
+ but finding gops stretched, to accomodate the widget's default area. */
+ x->x_width = 5;
+ x->x_height = 5;
props_clone(x->x_arguments, widgettype_getarguments(x->x_typedef));
widget_addmessage(x, 0, ac, av);
x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, 0, 0);
diff --git a/toxy/widgettype.c b/toxy/widgettype.c
index 3e04824..4541947 100644
--- a/toxy/widgettype.c
+++ b/toxy/widgettype.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003 krzYszcz and others.
+/* Copyright (c) 2003-2004 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
@@ -12,7 +12,7 @@
#include "widgettype.h"
static char masterwidget_builtin[] =
-#include "default.wiq"
+#include "setup.wiq"
;
#define WIDGETTYPE_VERBOSE
@@ -36,9 +36,9 @@ struct _masterwidget
t_symbol *mw_target;
t_scriptlet *mw_setupscript;
t_dict *mw_typemap;
- t_widgettype *mw_defaulttype; /* contains master iniscript */
- t_widgettype *mw_parsedtype; /* the type currently parsed, if loading */
- t_binbuf *mw_bb; /* auxiliary, LATER remove */
+ t_widgettype *mw_mastertype; /* contains master iniscript */
+ t_widgettype *mw_parsedtype; /* the type currently parsed, if loading */
+ t_binbuf *mw_bb; /* auxiliary, LATER remove */
};
static t_class *widgettype_class;
@@ -95,10 +95,10 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc,
typekey = dict_key(mw->mw_typemap, buf);
typeval = (t_widgettype *)dict_value(mw->mw_typemap, typekey);
if (caller == (t_pd *)mw)
- { /* default.wid or built-in defaults */
- if (mw->mw_defaulttype)
- { /* no default type in default.wid, extracting built-in one */
- if (typeval != mw->mw_defaulttype)
+ { /* setup.wid or built-in defaults */
+ if (mw->mw_mastertype)
+ { /* no master type in setup.wid, extracting built-in one */
+ if (typeval != mw->mw_mastertype)
return (SCRIPTLET_LOCK);
}
else
@@ -168,23 +168,26 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc,
t_widgettype *widgettype_get(t_symbol *s)
{
t_widgettype *wt;
- /* default.wid defs are NOT overridden by <type>.wid --
- feature stability comes first, LATER rethink */
+ /* Design decision: setup.wid defs are NOT overridden by <type>.wid
+ (sacrificing flexibility for feature stability). */
if (wt = (t_widgettype *)dict_value(masterwidget->mw_typemap,
dict_key(masterwidget->mw_typemap,
s->s_name)))
masterwidget->mw_parsedtype = 0;
else
{
- /* first instance of a type not defined in default.wid */
+ /* first instance of a type not defined in setup.wid */
wt = widgettype_new(masterwidget, s->s_name, 0, 0);
masterwidget->mw_parsedtype = wt;
}
if (masterwidget->mw_parsedtype)
{
+ /* <type>.wid searched in the current patch's dir + pd_path,
+ but not in `pwd` */
t_scriptlet *mwsp =
scriptlet_new((t_pd *)masterwidget, masterwidget->mw_target,
- masterwidget->mw_target, 0, 0, 0);
+ masterwidget->mw_target, 0,
+ canvas_getcurrent(), 0);
if (scriptlet_rcload(mwsp, (t_pd *)wt,
s->s_name, ".wid", 0, masterwidget_cmnthook)
== SCRIPTLET_OK)
@@ -264,7 +267,7 @@ void widgettype_setup(void)
int masterwidget_evaluate(t_scriptlet *outsp, int visedonly,
int ac, t_atom *av, t_props *argprops)
{
- return (scriptlet_evaluate(masterwidget->mw_defaulttype->wt_iniscript,
+ return (scriptlet_evaluate(masterwidget->mw_mastertype->wt_iniscript,
outsp, visedonly, ac, av, argprops));
}
@@ -288,44 +291,46 @@ void masterwidget_initialize(void)
masterwidget->mw_typemap = dict_new(0);
+ /* setup.wid searched in `pwd` + pd_path, but not in current patch's dir
+ (LATER only the pd_path should be searched) */
masterwidget->mw_setupscript =
scriptlet_new((t_pd *)masterwidget, masterwidget->mw_target,
masterwidget->mw_target, 0, 0, 0);
masterwidget->mw_bb = binbuf_new();
masterwidget->mw_parsedtype = 0;
- masterwidget->mw_defaulttype = 0;
+ masterwidget->mw_mastertype = 0;
rcresult =
- scriptlet_rcload(masterwidget->mw_setupscript, 0, "default", ".wid",
+ scriptlet_rcload(masterwidget->mw_setupscript, 0, "setup", ".wid",
masterwidget_builtin, masterwidget_cmnthook);
if (rcresult == SCRIPTLET_OK)
{
#ifdef WIDGETTYPE_VERBOSE
- post("using file 'default.wid'");
+ post("using file 'setup.wid'");
#endif
}
else
{
loud_warning((t_pd *)masterwidget,
- "no file 'default.wid'... using built-in defaults");
+ "no file 'setup.wid'... using built-in defaults");
}
- typekey = dict_key(masterwidget->mw_typemap, "default");
+ typekey = dict_key(masterwidget->mw_typemap, "master");
if ((typeval = (t_widgettype *)dict_value(masterwidget->mw_typemap, typekey))
&& !scriptlet_isempty(masterwidget->mw_setupscript))
{
- masterwidget->mw_defaulttype = typeval;
+ masterwidget->mw_mastertype = typeval;
rcresult = SCRIPTLET_OK;
}
else if (rcresult == SCRIPTLET_OK)
{
/* LATER think about adding only missing part to existing local defs */
- loud_warning((t_pd *)masterwidget, "%s missing in file 'default.wid'",
+ loud_warning((t_pd *)masterwidget, "%s missing in file 'setup.wid'",
(typeval ? "setup definitions" : "master initializer"));
- masterwidget->mw_defaulttype =
- widgettype_new(masterwidget, "default", 0, 0);
+ masterwidget->mw_mastertype =
+ widgettype_new(masterwidget, "master", 0, 0);
scriptlet_reset(masterwidget->mw_setupscript);
rcresult =
- scriptlet_rcparse(masterwidget->mw_setupscript, 0, "default",
+ scriptlet_rcparse(masterwidget->mw_setupscript, 0, "master",
masterwidget_builtin, masterwidget_cmnthook);
}
else