t_max_err ww_notify(t_ww *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { t_symbol *name = NULL; t_rect r; t_atom a[4]; if (sender == x->w_patcherview) { if (msg == gensym("attr_modified")) { name = (t_symbol *)object_method((t_object *)data, gensym("getname")); // the patcherview is notified when its rect changes size if (name == gensym("rect")) { object_attr_get_rect(x->w_patcherview, gensym("rect"), &r); atom_setfloat(a+0, r.x); atom_setfloat(a+1, r.y); atom_setfloat(a+2, r.width); atom_setfloat(a+3, r.height); outlet_anything(x->w_outlet, gensym("patcherview"), 4, a); } // the patcherview is notified when its visible rect has changed (i.e. scrollbars have been moved) if (name == gensym("visiblecanvasrect")) { object_attr_get_rect(x->w_patcherview,gensym("visiblecanvasrect"), &r); atom_setfloat(a+0, r.x); atom_setfloat(a+1, r.y); atom_setfloat(a+2, r.width); atom_setfloat(a+3, r.height); outlet_anything(x->w_outlet, gensym("visiblecanvasrect"), 4, a); } } else if (msg == gensym("free")) { object_detach_byptr((t_object *)x, x->w_patcherview); x->w_patcherview = NULL; } } return MAX_ERR_NONE; }
void ww_boxscreenrectchanged(t_jbox *box, t_object *patcherview) { t_rect r; t_atom a[4]; t_ww *x = (t_ww *)box->b_firstin; // This method is an instance method of our box object (newobj) // So ... object_attr_get_rect(x->w_patcherview, gensym("rect"), &r); atom_setfloat(a+0, r.x); atom_setfloat(a+1, r.y); atom_setfloat(a+2, r.width); atom_setfloat(a+3, r.height); outlet_anything(x->w_outlet, gensym("boxscreenrectchanged"), 4, a); }
// TODO: When running in the debugger, it seems like we are iterating through this function a whole bunch of times! // Can we put it in a qelem or something so that it only gets called once? [TAP] // But actually, maybe it is just a Max 4.6 funky Runtime thing? Let's take a look again when we get to Max 5 void hub_examine_context(t_hub *x) { AtomCount argc = 0; AtomPtr argv = NULL; SymbolPtr context = jamoma_patcher_getcontext(x->container); // Try to get OSC Name of module from an argument jamoma_patcher_getargs(x->container, &argc, &argv); // <-- this call allocates memory for argv if(argc){ x->osc_name = atom_getsym(argv+(argc-1)); sysmem_freeptr(argv); } else x->osc_name = _sym_nothing; // Try to get OSC Name of module from scripting name if(x->osc_name == _sym_nothing) x->osc_name = jamoma_patcher_getvarname(x->container); // In this case we overwrite whatever happened above if(context == gensym("toplevel")){ x->osc_name = gensym("/editing_this_module"); x->editing = true; } else{ t_object* patcher = jamoma_object_getpatcher((t_object*)x); t_object* box = object_attr_getobj(patcher, jps_box); t_object* ui = NULL; t_symbol* objclass = NULL; x->editing = false; ui = object_attr_getobj(patcher, gensym("firstobject")); while(ui){ objclass = object_attr_getsym(ui, gensym("maxclass")); if(objclass == gensym("jcom.ui")) break; ui = object_attr_getobj(ui, gensym("nextobject")); } if(ui){ t_rect boxRect; t_rect uiRect; if(context == gensym("bpatcher")){ object_attr_get_rect(ui, _sym_presentation_rect, &uiRect); object_attr_get_rect(box, _sym_patching_rect, &boxRect); boxRect.width = uiRect.width; boxRect.height = uiRect.height; object_attr_set_rect(box, _sym_patching_rect, &boxRect); object_attr_get_rect(box, _sym_presentation_rect, &boxRect); boxRect.width = uiRect.width; boxRect.height = uiRect.height; object_attr_set_rect(box, _sym_presentation_rect, &boxRect); } else if(context == gensym("subpatcher")){ object_attr_get_rect(ui, _sym_presentation_rect, &uiRect); object_attr_get_rect(patcher, _sym_defrect, &boxRect); boxRect.width = uiRect.width; boxRect.height = uiRect.height; object_attr_set_rect(patcher, _sym_defrect, &boxRect); object_attr_setchar(patcher, _sym_toolbarvisible, 0); } } } object_attr_setsym(x, _sym_name, x->osc_name); hub_subscriptions_refresh(x); hub_internals_create(x); qelem_unset(x->init_qelem); // clear the last thing to make sure we don't call into this a bunch of times qelem_set(x->init_qelem); // flag the queue for initialization }