Skip to content
Snippets Groups Projects
Commit aa00d258 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

first attempt to get pddplink to work with the new GUI

parent a48a451a
No related branches found
No related tags found
No related merge requests found
...@@ -98,18 +98,23 @@ static void pddplink_select(t_gobj *z, t_glist *glist, int state) ...@@ -98,18 +98,23 @@ static void pddplink_select(t_gobj *z, t_glist *glist, int state)
rtext_select(y, state); rtext_select(y, state);
if (glist_isvisible(glist) && glist->gl_havewindow) if (glist_isvisible(glist) && glist->gl_havewindow)
{ {
if (state) { if (state) {
sys_vgui(".x%lx.c itemconfigure %s -fill $::pd_colors(selection)\n", sys_vgui(".x%lx.c itemconfigure %s -fill $::pd_colors(selection)\n",
glist, rtext_gettag(y)); glist, rtext_gettag(y));
sys_vgui(".x%lx.c addtag selected withtag %s\n", sys_vgui(".x%lx.c addtag selected withtag %s\n",
glist, rtext_gettag(y)); glist, rtext_gettag(y));
} gui_vmess("gui_gobj_select", "xs",
else { glist, rtext_gettag(y));
sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n", }
glist, rtext_gettag(y), x->x_vistext); else
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)glist_getcanvas(glist)); {
sys_vgui(".x%lx.c dtag %s selected\n", glist, rtext_gettag(y)); sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n",
} glist, rtext_gettag(y), x->x_vistext);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)glist_getcanvas(glist));
sys_vgui(".x%lx.c dtag %s selected\n", glist, rtext_gettag(y));
gui_vmess("gui_gobj_deselect", "xs",
glist, rtext_gettag(y));
}
} }
} }
...@@ -119,6 +124,31 @@ static void pddplink_activate(t_gobj *z, t_glist *glist, int state) ...@@ -119,6 +124,31 @@ static void pddplink_activate(t_gobj *z, t_glist *glist, int state)
t_rtext *y = glist_findrtext(glist, (t_text *)x); t_rtext *y = glist_findrtext(glist, (t_text *)x);
rtext_activate(y, state); rtext_activate(y, state);
x->x_rtextactive = state; x->x_rtextactive = state;
if (!state) {
/* Big workaround for pddplink without the -box option...
After this call, Pd calls text_setto to see if it needs to
instantiate the object. For nearly all t_text objects, the
object doesn't get rebuilt if the text inside the box remains
the same. Instead, it just calls rtext_senditup which (eventually)
sends a message to the GUI to simply supply new text for the
current object. (It shouldn't do this if the text hasn't actually
changed, but that's another story...).
Anyway, since pddplink has this weird widget behavior, the text
displayed is different than the text we typed in the box-- hence
the x->x_vistext member here. So if we happened to edit the box
without changing the text, rtext_senditup would update the link
to be "pddplink foo" instead of just "foo".
To prevent this, we just zero out the object's te_binbuf to ensure
that text_setto re-instantiates. That ensures the correct text is
printed for the link */
t_binbuf *b = binbuf_new();
t_binbuf *old = x->x_ob.te_binbuf;
x->x_ob.te_binbuf = b;
binbuf_free(old);
}
} }
static void pddplink_vis(t_gobj *z, t_glist *glist, int vis) static void pddplink_vis(t_gobj *z, t_glist *glist, int vis)
...@@ -130,15 +160,31 @@ static void pddplink_vis(t_gobj *z, t_glist *glist, int vis) ...@@ -130,15 +160,31 @@ static void pddplink_vis(t_gobj *z, t_glist *glist, int vis)
if ((glist->gl_havewindow || x->x_isgopvisible) if ((glist->gl_havewindow || x->x_isgopvisible)
&& (y = glist_findrtext(glist, (t_text *)x))) && (y = glist_findrtext(glist, (t_text *)x)))
{ {
rtext_draw(y);
sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n", glist_getcanvas(glist), rtext_gettag(y), x->x_vistext); sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n", glist_getcanvas(glist), rtext_gettag(y), x->x_vistext);
gui_vmess("gui_text_create_gobj", "xssiii",
glist_getcanvas(glist),
rtext_gettag(y),
"link",
text_xpix(&x->x_ob, glist_getcanvas(glist)),
text_ypix(&x->x_ob, glist_getcanvas(glist)),
glist_istoplevel(glist));
rtext_draw(y);
gui_vmess("gui_text_set", "xss",
glist_getcanvas(glist),
rtext_gettag(y),
x->x_vistext);
} }
} }
else else
{ {
if ((glist->gl_havewindow || x->x_isgopvisible) if ((glist->gl_havewindow || x->x_isgopvisible)
&& (y = glist_findrtext(glist, (t_text *)x))) && (y = glist_findrtext(glist, (t_text *)x)))
rtext_erase(y); {
//rtext_erase(y);
gui_vmess("gui_gobj_erase", "xs",
glist_getcanvas(glist),
rtext_gettag(y));
}
} }
} }
...@@ -294,12 +340,14 @@ static char *pddplink_optext(int *sizep, int ac, t_atom *av) ...@@ -294,12 +340,14 @@ static char *pddplink_optext(int *sizep, int ac, t_atom *av)
static void pddplink_free(t_pddplink *x) static void pddplink_free(t_pddplink *x)
{ {
post("freeing the thing...");
if (x->x_vistext) if (x->x_vistext)
freebytes(x->x_vistext, x->x_vissize); freebytes(x->x_vistext, x->x_vissize);
} }
static void *pddplink_new(t_symbol *s, int ac, t_atom *av) static void *pddplink_new(t_symbol *s, int ac, t_atom *av)
{ {
post("creating a new link");
t_pddplink xgen, *x; t_pddplink xgen, *x;
int skip; int skip;
xgen.x_isboxed = 0; xgen.x_isboxed = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment