Beispiel #1
0
bool PdParamGetter::fillIemObj(_iemgui * o,t_gobj * gobj,PulpParameterDesc * p) {


    if(o->x_glist->gl_isgraph) {
        if(
            o->x_obj.te_xpix < o->x_glist->gl_xmargin ||
            o->x_obj.te_ypix < o->x_glist->gl_ymargin ||
            o->x_obj.te_xpix > o->x_glist->gl_xmargin + o->x_glist->gl_pixwidth||
            o->x_obj.te_ypix > o->x_glist->gl_ymargin + o->x_glist->gl_pixheight


        )
        {
            //        DBG2(o->x_obj.te_xpix ,o->x_obj.te_ypix)
            //        DBG4(o->x_glist->gl_xmargin, o->x_glist->gl_ymargin, o->x_glist->gl_xmargin + o->x_glist->gl_pixwidth,o->x_glist->gl_ymargin + o->x_glist->gl_pixheight);
//            DBG("dropping out component out of canvas viewport " << o->x_snd->s_name);
            return false;
        }
    }
    int x01,y01,x02,y02;
    gobj_getrect(gobj, o->x_glist,&x01,&y01,&x02,&y02);
    p->setBounds(  x01,y01,x02-x01,y02-y01);


    p->sendName = String(o->x_snd->s_name,MAX_STRING_LENGTH_FROM_PD);
    p->recieveName = String(o->x_rcv->s_name,MAX_STRING_LENGTH_FROM_PD);
    p->labelName = String();
//     DBG3(p->sendName,p->recieveName,p->labelName);
    if( strcmp(o->x_lab->s_name, "empty")!=0) {
        p->labelName = String(o->x_lab->s_name,MAX_STRING_LENGTH_FROM_PD);
        p->hasLabel = true;
        p->labelSize = o->x_fontsize;
        p->labelRect.setBounds(o->x_ldx,
                               o->x_ldy - p->labelSize/3,
                               (p->sendName.length()*p->labelSize),
                               (p->labelSize));
    }
    else {

        p->hasLabel = false;
    }
    //    Point<int> offset(o->x_obj.te_xpix,o->x_obj.te_ypix);



    p->backColour = getPdColour(o->x_bcol);
    p->mainColour =getPdColour(o->x_fcol);


    return true;

}
Beispiel #2
0
void canvas_resortoutlets(t_canvas *x)
{
    int noutlets = 0, i, j, xmax;
    t_gobj *y, **vec, **vp, **maxp;

    for (noutlets = 0, y = x->gl_list; y; y = y->g_next)
        if (pd_class(&y->g_pd) == voutlet_class) noutlets++;

    if (noutlets < 2) return;

    vec = (t_gobj **)getbytes(noutlets * sizeof(*vec));

    for (y = x->gl_list, vp = vec; y; y = y->g_next)
        if (pd_class(&y->g_pd) == voutlet_class) *vp++ = y;

    for (i = noutlets; i--;)
    {
        t_outlet *ip;
        for (vp = vec, xmax = -0x7fffffff, maxp = 0, j = noutlets;
                j--; vp++)
        {
            int x1, y1, x2, y2;
            t_gobj *g = *vp;
            if (!g) continue;
            gobj_getrect(g, x, &x1, &y1, &x2, &y2);
            if (x1 > xmax) xmax = x1, maxp = vp;
        }
        if (!maxp) break;
        y = *maxp;
        *maxp = 0;
        ip = voutlet_getit(&y->g_pd);

        obj_moveoutletfirst(&x->gl_obj, ip);
    }
    freebytes(vec, noutlets * sizeof(*vec));
    if (x->gl_owner && glist_isvisible(x->gl_owner))
        canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
}
Beispiel #3
0
t_osc_bndl_u *ocontext_processCanvas(t_canvas *canvas)
{
	t_osc_bndl_u *canvas_bndl = osc_bundle_u_alloc();
	if(canvas == NULL){
		// return empty bundle---this is intentional
		return canvas_bndl;
	}

    t_osc_msg_u *msg = NULL;

    msg = osc_message_u_allocWithAddress("/name");
    osc_message_u_appendString(msg, canvas->gl_name->s_name);
    osc_bundle_u_addMsg(canvas_bndl, msg);

    t_canvasenvironment *c_env = canvas_getenv(canvas);
    
    msg = osc_message_u_allocWithAddress("/path");
    osc_message_u_appendString(msg, c_env->ce_dir->s_name);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/$0");
    osc_message_u_appendInt32(msg, c_env->ce_dollarzero);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/isabstraction");
    osc_message_u_appendBool(msg, !canvas_isabstraction(canvas));
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/editmode");
    osc_message_u_appendBool(msg, canvas->gl_edit);
    osc_bundle_u_addMsg(canvas_bndl, msg);

    msg = osc_message_u_allocWithAddress("/font");
    osc_message_u_appendString(msg, sys_font);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/fontsize");
    osc_message_u_appendInt32(msg, canvas->gl_font);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/dirty");
    osc_message_u_appendBool(msg, canvas->gl_dirty);
    osc_bundle_u_addMsg(canvas_bndl, msg);

    if(!canvas_isabstraction(canvas))
    {
        msg = osc_message_u_allocWithAddress("/abstraction/position/x1");
        osc_message_u_appendInt32(msg, canvas->gl_obj.te_xpix);
        osc_bundle_u_addMsg(canvas_bndl, msg);
        
        msg = osc_message_u_allocWithAddress("/abstraction/position/y1");
        osc_message_u_appendInt32(msg, canvas->gl_obj.te_ypix);
        osc_bundle_u_addMsg(canvas_bndl, msg);
    }
    
    msg = osc_message_u_allocWithAddress("/pixwidth");
    osc_message_u_appendInt32(msg, canvas->gl_pixwidth);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/pixheight");
    osc_message_u_appendInt32(msg, canvas->gl_pixheight);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/screen/x1");
    osc_message_u_appendInt32(msg, canvas->gl_screenx1);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/screen/y1");
    osc_message_u_appendInt32(msg, canvas->gl_screeny1);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/screen/x2");
    osc_message_u_appendInt32(msg, canvas->gl_screenx2);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    msg = osc_message_u_allocWithAddress("/screen/y2");
    osc_message_u_appendInt32(msg, canvas->gl_screeny2);
    osc_bundle_u_addMsg(canvas_bndl, msg);

    msg = osc_message_u_allocWithAddress("/xmargin");
    osc_message_u_appendInt32(msg, canvas->gl_xmargin);
    osc_bundle_u_addMsg(canvas_bndl, msg);

    msg = osc_message_u_allocWithAddress("/ymargin");
    osc_message_u_appendInt32(msg, canvas->gl_ymargin);
    osc_bundle_u_addMsg(canvas_bndl, msg);
    
    if(canvas->gl_goprect && canvas->gl_owner)
    {
        int x1,y1,x2,y2;
        gobj_getrect(&canvas->gl_obj.te_g, canvas->gl_owner, &x1, &y1, &x2, &y2);

        msg = osc_message_u_allocWithAddress("/graphrect");
        osc_message_u_appendInt32(msg, x1);
        osc_message_u_appendInt32(msg, y1);
        osc_message_u_appendInt32(msg, x2);
        osc_message_u_appendInt32(msg, y2);
        osc_bundle_u_addMsg(canvas_bndl, msg);
    }
    
    t_binbuf *b = NULL;
    b = canvas->gl_obj.te_binbuf;
    
    if(b)
    {
        int argc = binbuf_getnatom(b);
        t_atom *argv = binbuf_getvec(b);

        if(argc)
        {
            t_osc_msg_u *msg_u = NULL;
            int abstr = !canvas_isabstraction(canvas);
            t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, gensym("/arguments"), argc-1-abstr, argv+1+abstr);
            if(e)
            {
                if(e){
                    object_error((t_object *)x, "%s", osc_error_string(e));
                    goto exit;
                }
            }
            osc_bundle_u_addMsg(canvas_bndl, msg_u);
        }
        else
        {
            msg = osc_message_u_allocWithAddress("/arguments");
            osc_message_u_appendString(msg, "");
            osc_bundle_u_addMsg(canvas_bndl, msg);
        }
    }
    else
    {
        msg = osc_message_u_allocWithAddress("/arguments");
        osc_message_u_appendString(msg, "");
        osc_bundle_u_addMsg(canvas_bndl, msg);
    }
    
exit:
    if(canvas->gl_owner)
    {
        t_osc_bndl_u *parent_bndl = ocontext_processCanvas(canvas->gl_owner);
		t_osc_msg_u *pmsg = osc_message_u_allocWithAddress("/parent");
		osc_message_u_appendBndl_u(pmsg, parent_bndl);
		osc_bundle_u_addMsg(canvas_bndl, pmsg);
    }
    
	return canvas_bndl;
}
Beispiel #4
0
void PdParamGetter::getFromPdCanvas(t_canvas * x,int guiIdx) {
    {

        Rectangle<int> patchRect = guiSizes[guiIdx];
        //        Rectangle<int> region( x->gl_xmargin,x->gl_ymargin,x->gl_xmargin+ x->gl_pixwidth, x->gl_ymargin + x->gl_pixheight);//guiSizes[guiIdx];



        t_gobj * y = x->gl_list;
        for(t_gobj * y2 = y ; y2 ; y2 = y2->g_next) {


            PulpParameterDesc * p = new PulpParameterDesc ;
            p->guiNum = guiIdx;
            p->elements.clear();

            String objName = y2->g_pd->c_name->s_name;
//            DBG(objName);
            int split = objName.indexOfWholeWord("/");
            if(split>0) {
                objName = objName.substring(split, objName.length() - split);
//                DBG(objName);
            }
            bool found = true;
            if(objName=="canvas" ) {
                _glist * gl;
                if((gl = pd_checkglist(&y2->g_pd))) {
                    if(gl->gl_isgraph) {
                        //                        DBGN(gl->gl_env->ce_dir->s_name)
                        //                        DBG2("/",gl->gl_list);
                        getFromPdCanvas(gl, guiIdx);
                    }
                }
                found = false;
            }
            else if(y2->g_pd->c_gobj) {
                if(objName== "hsl") {
                    p->type = PulpParameterDesc::HSL;
                    t_hslider *hsl = (t_hslider *)y2;
                    found = fillIemObj(&hsl->x_gui,y2, p);
                    p->min = hsl->x_min;
                    p->max = hsl->x_max;
                    if(hsl->x_gui.x_isa.x_loadinit) {
                        p->defaultV = (hsl->x_val/100)*hsl->x_k + p->min;
                    }
                }
                else if(objName=="vsl") {
                    p->type = PulpParameterDesc::VSL;
                    t_vslider *vsl = (t_vslider *)y2;
                    found = fillIemObj(&vsl->x_gui,y2, p);
                    p->min = vsl->x_min;
                    p->max = vsl->x_max;
                    if(vsl->x_gui.x_isa.x_loadinit) {
                        p->defaultV = (vsl->x_val/100)*vsl->x_k + p->min;
                    }
                }

                else if(objName== "tgl") {
                    p->type = PulpParameterDesc::TOGGLE;
                    t_toggle *tgl = (t_toggle *)y2;
                    found = fillIemObj(&tgl->x_gui,y2, p);
                    p->min = 0;
                    p->max = 1;
                }
                else if(objName== "bng") {
                    p->type = PulpParameterDesc::BANG;
                    t_bng *tgl = (t_bng *)y2;
                    found = fillIemObj(&tgl->x_gui,y2, p);
                    p->min = 0;
                    p->max = 1;
                }
                else if(objName== "vradio") {
                    p->type = PulpParameterDesc::VRADIO;
                    t_vradio *tgl = (t_vradio *)y2;
                    found = fillIemObj(&tgl->x_gui,y2, p);
                    p->min = 0;
                    p->max = tgl->x_number-1;
                    for(int i = 0 ; i < tgl->x_number ; i++) {
                        p->elements.add(String(i));
                    }
                }
                else if(objName== "hradio") {
                    p->type = PulpParameterDesc::HRADIO;
                    t_hradio *tgl = (t_hradio *)y2;
                    found = fillIemObj(&tgl->x_gui,y2, p);
                    p->min = 0;
                    p->max = tgl->x_number-1;
                    for(int i = 0 ; i < tgl->x_number ; i++) {
                        p->elements.add(String(i));
                    }
                }
                else if(objName== "cnv") {
                    p->type = PulpParameterDesc::CNV;
                    t_my_canvas * cnv = (t_my_canvas*) y2;
                    found = fillIemObj(&cnv->x_gui,y2, p);
                    p->setSize(cnv->x_vis_w, cnv->x_vis_h);

                }
                else if(objName== "popup") {
                    p->type = PulpParameterDesc::POPUP;
                    t_popup * popup = (t_popup *) y2;
                    int x01,y01,x02,y02;
                    gobj_getrect(&popup->x_obj.te_g, x,&x01,&y01,&x02,&y02);
                    p->sendName = popup->x_name->s_name;
                    p->setBounds(  x01,y01,x02-x01,y02-y01);
                    DBG4(x01,y01,x02 ,y02);
                    found = true;
                    //                    found = fillIemObj(;,y2, p);
                    p->setSize(popup->x_width, popup->x_height);

                    for(int i =0 ; i < popup->x_num_options ; i++) {
                        p->elements.add(popup->x_options[i]->s_name);
                    }
                    p->min = 0;
                    p->max =p->elements.size()-1;

                }
                else if(strcmp(y2->g_pd->c_name->s_name, "knob")==0) {
                    p->type = PulpParameterDesc::KNOB;
                    t_knob *knob = (t_knob *)y2;
                    found = fillIemObj(&knob->x_gui,y2, p);
                    p->min = knob->x_min;
                    p->max = knob->x_max;
                }

                else {
//                    DBG("not found " <<objName);
                    found = false;
                }
            }
            if(found ) {
                p->isAudioParameter = p->sendName.startsWith("param");
                p->setBounds((p->getX() )/patchRect.getWidth(),
                             (p->getY() )/patchRect.getHeight(),
                             p->getWidth()/patchRect.getWidth(),
                             p->getHeight()/patchRect.getHeight());
                p->labelRect.setBounds((p->labelRect.getX())/patchRect.getWidth(),
                                       (p->labelRect.getY())/patchRect.getHeight(),
                                       p->labelRect.getWidth()/patchRect.getWidth(),
                                       p->labelRect.getHeight()/patchRect.getHeight());
                p->sendName = resolveDollarzero(p->sendName);
                p->recieveName = resolveDollarzero(p->recieveName);
//                DBGN(y2->g_pd->c_name->s_name << " : ")
//                DBG("adding p " << p->sendName << "/" << p->recieveName <<  " at "<< ((Rectangle<float>)*p).toString());

                if(p->isAudioParameter) {
                    p->processorIdx = localParamCount;
                    localParamCount++;
                }
                else {
                    p->processorIdx = -1;
                }
                p->pdObjectIdx = localObjectCount;
                localObjectCount++;
                pulpParameterDescs.add(p);

            }

            else {

                delete p;

            }



        }
    }

}