diff --git a/pd/src/g_readwrite.c b/pd/src/g_readwrite.c index 78f8dd19e64281d24fb19eae072b0aefbf559cd5..63ca3bc1f0bab7d0f247e1222f83a202bc3978a5 100644 --- a/pd/src/g_readwrite.c +++ b/pd/src/g_readwrite.c @@ -105,6 +105,8 @@ static void glist_readatoms(t_glist *x, int natoms, t_atom *vec, } } +void scalar_doloadbang(t_scalar *x); + int glist_readscalar(t_glist *x, int natoms, t_atom *vec, int *p_nextmsg, int selectit) { @@ -158,6 +160,8 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec, { glist_select(x, &sc->sc_gobj); } + /* send a loadbang for any canvas fields in this scalar */ + scalar_doloadbang(sc); return (1); } diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c index 141b7f252abe29823c7f9eec469f2f9fd605b64a..1212e79b47b6408a7d95013d364841b8f4d6855c 100644 --- a/pd/src/g_scalar.c +++ b/pd/src/g_scalar.c @@ -73,6 +73,8 @@ void word_init(t_word *data, t_template *template, t_gpointer *gp) /* Here too we're being dangerous-- I'm not unsetting this gpointer yet. */ gpointer_copy(gp, &wp->w_list->gl_gp); + /* make the parent glist the parent of our canvas field */ + wp->w_list->gl_owner = gp->gp_stub->gs_un.gs_glist; while ((x != s__X.s_thing) && s__X.s_thing) { @@ -93,6 +95,22 @@ void word_init(t_word *data, t_template *template, t_gpointer *gp) } } +void scalar_doloadbang(t_scalar *x) +{ + t_template *template = template_findbyname(x->sc_template); + t_dataslot *datatypes = template->t_vec; + t_word *wp = x->sc_vec; + int i, nitems = template->t_n; + for (i = 0; i < nitems; i++, datatypes++, wp++) + { + if (datatypes->ds_type == DT_LIST) + { + t_canvas *c = wp->w_list; + pd_vmess((t_pd *)c, gensym("loadbang"), ""); + } + } +} + void word_restore(t_word *wp, t_template *template, int argc, t_atom *argv) { diff --git a/pd/src/g_template.c b/pd/src/g_template.c index cab698739d47f61543307d94c731b7a61aea96e8..d77f5ff20558603ca4ebd2e26667600efc4b5b52 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -3410,7 +3410,7 @@ static void svg_togui(t_svg *x, t_template *template, t_word *data) if (x->x_fillopacity.a_flag) { gui_s("fill-opacity"); - gui_f(fielddesc_getfloat(&x->x_fillopacity.a_attr, template, data, 1)); + gui_f(fielddesc_getcoord(&x->x_fillopacity.a_attr, template, data, 1)); } if (x->x_fillrule.a_flag) { diff --git a/pd/src/g_traversal.c b/pd/src/g_traversal.c index 2d5ee264f4f19c6902ffdce4cec61ccea5903d76..d9e7996fec9343ad4e44b35911b88ffb8b867453 100644 --- a/pd/src/g_traversal.c +++ b/pd/src/g_traversal.c @@ -1323,8 +1323,7 @@ static void *field_new(t_symbol *s) t_field *x = (t_field *)pd_new(field_class); x->x_s = s; x->x_canvas = canvas_getcurrent(); - // do some error checking here - x->x_template = template_findbyname(x->x_canvas->gl_templatesym); + x->x_template = NULL; outlet_new(&x->x_obj, &s_list); return (x); } @@ -1334,31 +1333,56 @@ static void field_set(t_field *x, t_symbol *s) x->x_s = s; } + /* Contortions to get and possibly cache template after + the first lookup. We can't get it in field_new because + word_init only sets the template after we've been created. */ +static t_template *field_gettemplate(t_field *x) +{ + if (x->x_template) + return x->x_template; + else + { + if (x->x_canvas->gl_templatesym) + { + x->x_template = template_findbyname(x->x_canvas->gl_templatesym); + return x->x_template; + } + else + return 0; + } +} + static void field_bang(t_field *x) { - t_word *vec = x->x_canvas->gl_vec; - t_template *template = x->x_template; - t_symbol *fieldsym = x->x_s; - int onset, type; - t_symbol *arraytype; - if (template_find_field(template, fieldsym, &onset, &type, &arraytype)) + t_template *template = field_gettemplate(x); + if (template) { - if (type == DT_FLOAT) - outlet_float(x->x_obj.ob_outlet, - *(t_float *)(((char *)vec) + onset)); - else if (type == DT_SYMBOL) - outlet_symbol(x->x_obj.ob_outlet, - *(t_symbol **)(((char *)vec)+ onset)); - else pd_error(x, "field: %s.%s is not a number or symbol", - template->t_sym->s_name, fieldsym->s_name); + t_word *vec = x->x_canvas->gl_vec; + t_symbol *fieldsym = x->x_s; + int onset, type; + t_symbol *arraytype; + if (template_find_field(template, fieldsym, &onset, &type, &arraytype)) + { + if (type == DT_FLOAT) + outlet_float(x->x_obj.ob_outlet, + *(t_float *)(((char *)vec) + onset)); + else if (type == DT_SYMBOL) + outlet_symbol(x->x_obj.ob_outlet, + *(t_symbol **)(((char *)vec)+ onset)); + else pd_error(x, "field: %s.%s is not a number or symbol", + template->t_sym->s_name, fieldsym->s_name); + } + else pd_error(x, "field: %s.%s: no such field", + template->t_sym->s_name, fieldsym->s_name); } - else pd_error(x, "field: %s.%s: no such field", - template->t_sym->s_name, fieldsym->s_name); + else /* send a bang to signal that we're not in a scalar */ + outlet_bang(x->x_obj.ob_outlet); } static void field_setvalue(t_field *x, t_symbol *s, int argc, t_atom *argv) { - t_template *template = x->x_template; + t_template *template = field_gettemplate(x); + if (!template) return; t_word *vec = x->x_canvas->gl_vec; t_gpointer *gp = &x->x_canvas->gl_gp; t_gstub *gs = gp->gp_stub;