Exemple #1
0
void canvas_rmoutlet(t_canvas *x, t_outlet *op)
{
    t_canvas *owner = x->gl_owner;
    int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting)
        && glist_istoplevel(owner));
    
    if (owner) canvas_deletelinesforio(owner, &x->gl_obj, 0, op);
    if (redraw)
        gobj_vis(&x->gl_gobj, x->gl_owner, 0);

    outlet_free(op);
    if (redraw)
    {
        gobj_vis(&x->gl_gobj, x->gl_owner, 1);
        canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
    }
}
Exemple #2
0
void rtext_select(t_rtext *x, int state)
{
    t_glist *glist = x->x_glist;
    t_canvas *canvas = glist_getcanvas(glist);
    if (glist_istoplevel(glist))
        sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
            x->x_tag, (state? "$pd_colors(selection)" : "$pd_colors(text)"));
    if (x->x_text->te_pd->c_wb && x->x_text->te_pd->c_wb->w_displacefnwtag)
    {
        if (state)
            sys_vgui(".x%lx.c addtag selected withtag %s\n",
                   glist_getcanvas(glist), x->x_tag);
        else
            sys_vgui(".x%lx.c dtag %s selected\n",
                   glist_getcanvas(glist), x->x_tag);
    }
    canvas_editing = canvas;
}
Exemple #3
0
t_undo_action *canvas_undo_init(t_canvas *x)
{
    t_undo_action *a = 0;
    t_undo *udo = canvas_undo_get(x);
    if (!udo) return 0;
    a = (t_undo_action *)getbytes(sizeof(*a));
    a->type = 0;
    a->x = x;
    a->next = NULL;

    if (!udo->u_queue)
    {
        DEBUG_UNDO(post("%s: first init", __FUNCTION__));
        //this is the first init
        udo->u_queue = a;
        udo->u_last = a;

        canvas_undo_cleardirty(x);
            /* invalidate clean-state for re-created subpatches
             * since we do not know whether the re-created subpatch
             * is clean or unclean (it's undo-queue got lost when
             * it was deleted), we assume the worst */
        if (!canvas_isabstraction(x))
            udo->u_cleanstate = (void*)1;

        a->prev = NULL;
        a->name = "no";
        if (glist_isvisible(x) && glist_istoplevel(x))
            sys_vgui("pdtk_undomenu .x%lx no no\n", x);
    }
    else
    {
        DEBUG_UNDO(post("%s: re-init %p", __FUNCTION__, udo->u_last->next));
        if (udo->u_last->next)
        {
            //we need to rebranch first then add the new action
            canvas_undo_rebranch(x);
        }
        udo->u_last->next = a;
        a->prev = udo->u_last;
        udo->u_last = a;
    }
    return(a);
}
Exemple #4
0
static void mknob_draw_new(t_mknob *x, t_glist *glist)
{
    int xpos=text_xpix(&x->x_gui.x_obj, glist);
    int ypos=text_ypix(&x->x_gui.x_obj, glist);
    int r = xpos + (x->x_val + 50)/100;
    t_float xc=xpos+x->x_gui.x_w/2.0;
    t_float yc=ypos+x->x_gui.x_w/2.0;
    t_float rc=x->x_gui.x_w/2.0;
    t_canvas *canvas=glist_getcanvas(glist);

    t_gobj *y = (t_gobj *)x;
    t_object *ob = pd_checkobject(&y->g_pd);

    /* GOP objects are unable to call findrtext triggering consistency check error */
    t_rtext *yyyy = NULL;
    if (!glist->gl_isgraph || glist_istoplevel(glist))
        yyyy = glist_findrtext(canvas, (t_text *)&ob->ob_g);

    /* on GOP we cause segfault as apparently text_gettag() returns bogus data */
    char *nlet_tag;
    if (yyyy) nlet_tag = rtext_gettag(yyyy);
    else nlet_tag = "bogus";

    sys_vgui(".x%lx.c create circle %f %f -r %f -fill #%6.6x -tags {%xBASE %xMKNOB %s}\n",
             canvas,xc,yc,rc,
             x->x_gui.x_bcol, x, x, nlet_tag);
    /*sys_vgui(".x%lx.c create circle %f %f -r %f -stroke \"\" -fill #%6.6x -tags {%xCENTER %xMKNOB}\n",
         canvas,xc,yc,3.5,
         x->x_gui.x_fcol, x, x);*/
    /*sys_vgui(".x%lx.c create ppolygon %d %d %d %d %d %d -fill #%6.6x -tags {%xKNOB %xMKNOB}\n",
             glist_getcanvas(glist),
             (int)xc,ypos,(int)xc-4,(int)yc,(int)xc+4,(int)yc,x->x_gui.x_fcol,x,x);*/
    sys_vgui(".x%lx.c create ppolygon %f %d %f %f -strokewidth 2 -stroke #%6.6x -tags {%xKNOB %xMKNOB %s}\n",
             canvas,xc,ypos,xc,yc,x->x_gui.x_fcol,x,x,nlet_tag);
    mknob_update_knob(x,glist);
    sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
	     -font {{%s} %d bold} -fill #%6.6x -tags {%xLABEL %xMKNOB %s}\n",
Exemple #5
0
void iemgui_label_getrect(t_iemgui x_gui, t_glist *x,
    int *xp1, int *yp1, int *xp2, int *yp2)
{
    //fprintf(stderr,"gop_redraw = %d\n", gop_redraw);
    if (!gop_redraw)
    {
        //fprintf(stderr,"ignoring label\n");
        return;
    }

    t_float width_multiplier;
    int label_length;
    int label_x1;
    int label_y1;
    int label_x2;
    int label_y2;
    int actual_fontsize; //seems tk does its own thing when rendering
    int actual_height;

    if (x->gl_isgraph && !glist_istoplevel(x))
    {
        if (x_gui.x_lab!=s_empty)
        {
            switch(x_gui.x_font_style)
            {
                case 1:  width_multiplier = 0.83333; break;
                case 2:  width_multiplier = 0.735;   break;
                default: width_multiplier = 1.0;     break;
            }
            actual_fontsize = x_gui.x_fontsize;
            actual_height = actual_fontsize;
            //exceptions
            if (x_gui.x_font_style == 0 &&
                (actual_fontsize == 8 || actual_fontsize == 13 ||
                actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 ||
                    (actual_fontsize > 48 && actual_fontsize < 100 &&
                    (actual_fontsize %10 == 4 || actual_fontsize %10 == 9))))
            {
                actual_fontsize += 1;
            }
            else if (x_gui.x_font_style == 1 && actual_fontsize >= 5 &&
                actual_fontsize < 13 && actual_fontsize % 2 == 1)
                actual_fontsize += 1;
            else if (x_gui.x_font_style == 2 && actual_fontsize >= 5 &&
                actual_fontsize % 2 == 1)
                actual_fontsize += 1;
            if (actual_height == 9)
                actual_height += 1;
            //done with exceptions

            width_multiplier = width_multiplier * (actual_fontsize * 0.6);

            label_length = strlen(x_gui.x_lab->s_name);
            label_x1 = *xp1 + x_gui.x_ldx;
            label_y1 = *yp1 + x_gui.x_ldy - actual_height/2;
            label_x2 = label_x1 + (label_length * width_multiplier);
            label_y2 = label_y1 + actual_height*1.1;

            //DEBUG
            //fprintf(stderr,"%f %d %d\n", width_multiplier,
            //    label_length, x_gui.x_font_style);
            //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x);
            //sys_vgui(".x%lx.c create rectangle %d %d %d %d "
            //    "-tags iemguiDEBUG\n",
            //    x, label_x1, label_y1, label_x2, label_y2);
            if (label_x1 < *xp1) *xp1 = label_x1;
            if (label_x2 > *xp2) *xp2 = label_x2;
            if (label_y1 < *yp1) *yp1 = label_y1;
            if (label_y2 > *yp2) *yp2 = label_y2;
            //DEBUG
            //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x);
            //sys_vgui(".x%lx.c create rectangle %d %d %d %d "
            //    "-tags iemguiDEBUG\n", x, *xp1, *yp1, *xp2, *yp2);
        }
    }
}
Exemple #6
0
void canvas_undo_undo(t_canvas *x)
{
    t_undo *udo = canvas_undo_get(x);
    int dspwas;

    if (!udo) return;
    dspwas = canvas_suspend_dsp();
    DEBUG_UNDO(post("%s: %p != %p", __FUNCTION__, udo->u_queue, udo->u_last));
    if (udo->u_queue && udo->u_last != udo->u_queue)
    {
        udo->u_doing = 1;
        canvas_editmode(x, 1);
        glist_noselect(x);
        canvas_undo_set_name(udo->u_last->name);

        if(UNDO_SEQUENCE_END == udo->u_last->type)
        {
            int sequence_depth = 1;
            while((udo->u_last = udo->u_last->prev)
                  && (UNDO_INIT != udo->u_last->type))
            {
                DEBUG_UNDO(post("%s:sequence[%d] %d", __FUNCTION__, sequence_depth, udo->u_last->type));
                switch(udo->u_last->type)
                {
                case UNDO_SEQUENCE_START:
                    sequence_depth--;
                    break;
                case UNDO_SEQUENCE_END:
                    sequence_depth++;
                    break;
                default:
                    canvas_undo_doit(x, udo->u_last, UNDO_UNDO, __FUNCTION__);
                }
                if (sequence_depth < 1)
                    break;
            }
            if (sequence_depth < 0)
                bug("undo sequence missing end");
            else if (sequence_depth > 0)
                bug("undo sequence missing start");
        }

        if(canvas_undo_doit(x, udo->u_last, UNDO_UNDO, __FUNCTION__))
        {
            char *undo_action, *redo_action;
            udo->u_last = udo->u_last->prev;
            undo_action = udo->u_last->name;
            redo_action = udo->u_last->next->name;

            udo->u_doing = 0;
                /* here we call updating of all unpaired hubs and nodes since
                   their regular call will fail in case their position needed
                   to be updated by undo/redo first to reflect the old one */
            if (glist_isvisible(x) && glist_istoplevel(x))
            {
                if (glist_isvisible(x) && glist_istoplevel(x))
                    sys_vgui("pdtk_undomenu .x%lx %s %s\n", x, undo_action, redo_action);
            }
            canvas_dirty(x, canvas_undo_isdirty(x));
        }
    }
    canvas_resume_dsp(dspwas);
}