Commit 76f25790 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

nlet highlighting and filtering multiple msgs to pd window

parent e8f6eb0d
......@@ -38,11 +38,26 @@ text {
stroke-dasharray: 3 2;
}
.xlet {
stroke: black;
.xlet_control {
stroke: red;
fill: gray;
stroke-width: 1;
shape-rendering: optimizeSpeed;
}
.xlet_signal {
stroke: green;
fill: green;
stroke-width: 1;
}
.xlet_iemgui {
stroke: black;
fill: black;
stroke-width: 1;
}
.xlet_selected {
stroke: purple !important;
}
//.xlet:hover {
......
......@@ -157,18 +157,30 @@ function set_audioapi(val) {
pd_whichapi = val;
}
var last_string = "";
var last_child = {};
var duplicate = 0;
function gui_post(string, color) {
if (color === undefined) { color = "black" };
var myp = pd_window.document.getElementById('p1');
var text;
var span = pd_window.document.createElement("span");
span.style.color = color;
var text = pd_window.document.createTextNode(string + "\n");
span.appendChild(text);
myp.appendChild(span);
var printout = pd_window.document.getElementById("bottom");
printout.scrollTop = printout.scrollHeight;
// printout.scrollTo(0, pd_window.document.body.scrollHeight);
if (last_string === string) {
last_child.textContent = "[" + (duplicate + 2) + "] " + last_string;
duplicate++;
} else {
if (color === undefined) { color = "black" };
var myp = pd_window.document.getElementById('p1');
var text;
var span = pd_window.document.createElement("span");
span.style.color = color;
var text = pd_window.document.createTextNode(string + "\n");
span.appendChild(text);
myp.appendChild(span);
var printout = pd_window.document.getElementById("bottom");
printout.scrollTop = printout.scrollHeight;
last_string = string;
last_child = span;
duplicate = 0;
}
}
exports.gui_post = gui_post;
......@@ -1857,16 +1869,30 @@ function gui_text_drawborder(cid, tag, isbroken, x1, y1, x2, y2) {
g.appendChild(rect);
}
function gui_canvas_drawio(cid, parenttag, tag, x1, y1, x2, y2, basex, basey) {
var g = get_gobj(cid, parenttag);
// probably need to add an id for xlets below
function gui_canvas_drawio(cid, parenttag, tag, x1, y1, x2, y2, basex, basey, type, i, is_signal, is_iemgui) {
var xlet_class, xlet_id, g = get_gobj(cid, parenttag);
if (is_iemgui) {
xlet_class = 'xlet_iemgui';
// We have an inconsistency here. We're setting the tag using
// string concatenation below, but the "tag" for iemguis arrives
// to us pre-concatenated. We need to remove that formatting in c, and
// in general try to simplify tag creation on the c side as much
// as possible.
xlet_id = tag;
} else if (is_signal) {
xlet_class = 'xlet_signal';
xlet_id = tag + type + i;
} else {
xlet_class = 'xlet_control';
xlet_id = tag + type + i;
}
var rect = create_item(cid, 'rect', {
width: x2 - x1,
height: y2 - y1,
x: x1 - basex,
y: y1 - basey,
id: tag,
class: 'xlet'
id: xlet_id,
class: xlet_class,
});
g.appendChild(rect);
gui_post("the tag for this XLET is " + tag);
......@@ -1878,6 +1904,32 @@ function gui_eraseio(cid, tag) {
xlet.parentNode.removeChild(xlet);
}
function gui_configure_io(cid, tag, is_iemgui, is_signal, width) {
var xlet = get_item(cid, tag);
configure_item(xlet, {
'stroke-width': width,
// fill: 'red'
// fill: filter ? 'orange' : (is_signal ? 'red' : 'green')
});
if (is_iemgui) {
xlet.classList.add('xlet_iemgui');
} else if (is_signal) {
xlet.classList.add('xlet_signal');
} else {
xlet.classList.add('xlet_control');
}
// remove xlet_selected tag
xlet.classList.remove('xlet_selected');
// iemgui: black
// sig: red
// control: green
}
function gui_highlight_io(cid, tag) {
var xlet = get_item(cid, tag);
xlet.classList.add('xlet_selected');
}
function gui_message_drawborder(cid,tag,width,height) {
var g = get_gobj(cid, tag);
var p_array = [0,0,
......@@ -1992,8 +2044,11 @@ function gui_text_new(canvasname, myname, type, isselected, x, y, text, font) {
// at the top-right corner of the text's bbox. SVG uses the baseline.
// There's probably a programmatic way to do this, but for now-- fudge factors
// based on the DejaVu Sans Mono font. :)
x: 1,
y: 13,
x: x,
y: y + 10,
// Turns out we can't do 'hanging' baseline
// because it's borked when scaled. Bummer...
// 'dominant-baseline': 'hanging',
'shape-rendering': 'optimizeSpeed',
'font-size': font + 'px',
id: myname + 'text'
......
......@@ -102,3 +102,5 @@ Everything else:
* in pdproperties.html, use an object to store all the prop/value pairs that
got sent. That way we don't have to use all those awful tricks to
conditionally fill the slots
* fix font shits (can't use 'hanging' base-line dominant because it doesn't
scale correctly)
......@@ -1048,9 +1048,10 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
char tagbuf[MAXPDSTRING];
sprintf(parenttagbuf, "x%lx", (long unsigned int)x);
sprintf(tagbuf, "%so%d", iem_get_tag(canvas, x), i);
gui_vmess("gui_canvas_drawio", "sssiiiiii", canvas_string(canvas),
gui_vmess("gui_canvas_drawio", "sssiiiiiisiii", canvas_string(canvas),
parenttagbuf, tagbuf,
x1+i*k, y2-1, x1+i*k + IOWIDTH, y2, x1, y1);
x1+i*k, y2-1, x1+i*k + IOWIDTH, y2, x1, y1, "o", i,
0, 1);
}
if(!a && b)
for (i=0; i<n; i++)
......@@ -1080,9 +1081,10 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
char tagbuf[MAXPDSTRING];
sprintf(parenttagbuf, "x%lx", (long unsigned int)x);
sprintf(tagbuf, "%si%d", iem_get_tag(canvas, x), i);
gui_vmess("gui_canvas_drawio", "sssiiiiii", canvas_string(canvas),
gui_vmess("gui_canvas_drawio", "sssiiiiiisiii", canvas_string(canvas),
parenttagbuf, tagbuf,
x1+i*k, y1, x1+i*k + IOWIDTH, y1+1, x1, y1);
x1+i*k, y1, x1+i*k + IOWIDTH, y1+1, x1, y1, "i", i,
0, 1);
}
if(!a && b)
for (i=0; i<n; i++)
......
......@@ -248,6 +248,7 @@ void canvas_makefilename(t_canvas *x, char *file, char *result, int resultsize)
//fprintf(stderr,"resulting file = <%s>\n", result);
}
// Generic tag format to use for the gui
char *canvas_string(t_canvas *x)
{
static char s[MAXPDSTRING];
......
......@@ -142,15 +142,23 @@ static void tooltip_erase (t_canvas *x) {
}
static void canvas_nlet_conf (t_canvas *x, int type) {
int filter = type=='o' ? last_outlet_filter : last_inlet_filter;
int isiemgui = type=='o' ? last_outlet_filter : last_inlet_filter;
int issignal = type=='o' ? outlet_issignal : inlet_issignal;
sys_vgui(".x%x.c itemconfigure %s -stroke %s -fill %s -strokewidth 1\n", x,
type=='o' ? x->gl_editor->canvas_cnct_outlet_tag : x->gl_editor->canvas_cnct_inlet_tag,
(filter ? "$pd_colors(iemgui_nlet)" :
(issignal ? "$pd_colors(signal_cord)" : "$pd_colors(control_cord)")),
(issignal ? "$pd_colors(signal_nlet)" : "$pd_colors(control_nlet)"));
//sys_vgui(".x%x.c itemconfigure %s -stroke %s -fill %s -strokewidth 1\n", x,
// type=='o' ? x->gl_editor->canvas_cnct_outlet_tag : x->gl_editor->canvas_cnct_inlet_tag,
// (isiemgui ? "$pd_colors(iemgui_nlet)" :
// (issignal ? "$pd_colors(signal_cord)" : "$pd_colors(control_cord)")),
// (issignal ? "$pd_colors(signal_nlet)" : "$pd_colors(control_nlet)"));
/* this is rather confusing, but the canvas_cnct_[xlet]_tag already
includes the type and index concatenated to the end. */
gui_vmess("gui_configure_io", "ssiii",
canvas_string(x), type == 'o' ? x->gl_editor->canvas_cnct_outlet_tag :
x->gl_editor->canvas_cnct_inlet_tag,
isiemgui, issignal, 1);
}
/* this doesn't seem to be used anywhere */
/*static void canvas_nlet_conf2 (t_canvas *x, int cond) { // because of one exception...
int issignal = inlet_issignal;
sys_vgui(".x%x.c itemconfigure %s -stroke %s -fill %s -strokewidth 1\n", x,
......@@ -3304,7 +3312,8 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
x->gl_editor->e_onmotion = MA_CONNECT;
x->gl_editor->e_xwas = xpos;
x->gl_editor->e_ywas = ypos;
sys_vgui(
//sys_vgui(
/*".x%lx.c create polyline %d %d %d %d "
"-stroke %s -strokewidth %s -tags x\n",
x, xpos, ypos, xpos, ypos,
......@@ -3314,21 +3323,22 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
(issignal ?
"$pd_colors(signal_cord_width)" :
"$pd_colors(control_cord_width)"));*/
// bezier is too slow for the time being
".x%lx.c create path "
"\"M %d %d Q %d %d %d %d Q %d %d %d %d\" "
"-stroke %s -strokewidth %s "
"-tags {x all_cords %s}\n",
x, xpos, ypos,
xpos, ypos, xpos, ypos,
xpos, ypos, xpos, ypos,
(issignal ?
"$pd_colors(signal_cord)" :
"$pd_colors(control_cord)"),
(issignal ?
"$pd_colors(signal_cord_width)" :
"$pd_colors(control_cord_width)"),
(issignal ? "signal" : "control"));
// ".x%lx.c create path "
// "\"M %d %d Q %d %d %d %d Q %d %d %d %d\" "
// "-stroke %s -strokewidth %s "
// "-tags {x all_cords %s}\n",
//x, xpos, ypos,
//xpos, ypos, xpos, ypos,
//xpos, ypos, xpos, ypos,
//(issignal ?
// "$pd_colors(signal_cord)" :
// "$pd_colors(control_cord)"),
//(issignal ?
// "$pd_colors(signal_cord_width)" :
// "$pd_colors(control_cord_width)"),
//(issignal ? "signal" : "control"));
gui_vmess("gui_canvas_line", "ssiiiiiiiiii",
canvas_string(x), "newcord",
xpos, ypos, xpos, ypos, xpos, ypos, xpos, ypos, xpos, ypos);
......@@ -3347,11 +3357,16 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
(t_text *)&ob->ob_g);
sprintf(x->gl_editor->canvas_cnct_outlet_tag,
"%so%d", rtext_gettag(yr), closest);
sys_vgui(".x%x.c itemconfigure %s "
"-stroke $select_nlet_color "
"-strokewidth $highlight_width\n",
x,
x->gl_editor->canvas_cnct_outlet_tag);
//sys_vgui(".x%x.c itemconfigure %s "
// "-stroke $select_nlet_color "
// "-strokewidth $highlight_width\n",
// x,
// x->gl_editor->canvas_cnct_outlet_tag);
gui_vmess("gui_highlight_io", "ss",
canvas_string(x),
x->gl_editor->canvas_cnct_outlet_tag);
//sys_vgui(".x%x.c raise %s\n",
// x,
// x->gl_editor->canvas_cnct_outlet_tag);
......@@ -3405,9 +3420,14 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
gobj_filter_highlight_behavior((t_text *)&ob->ob_g);
sprintf(x->gl_editor->canvas_cnct_inlet_tag,
"%si%d", rtext_gettag(yr), closest);
sys_vgui(".x%x.c itemconfigure %s "
"-strokewidth $highlight_width\n",
x, x->gl_editor->canvas_cnct_inlet_tag);
//sys_vgui(".x%x.c itemconfigure %s "
// "-strokewidth $highlight_width\n",
// x, x->gl_editor->canvas_cnct_inlet_tag);
gui_vmess("gui_highlight_io", "ss",
canvas_string(x),
x->gl_editor->canvas_cnct_inlet_tag);
//sys_vgui(".x%x.c raise %s\n",
// x,
// x->gl_editor->canvas_cnct_inlet_tag);
......@@ -3630,9 +3650,9 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
//buf->u_redo = (t_undo_sel *)canvas_undo_set_selection(x);
//canvas_undo_add(x, 11, "selection", buf);
}
sys_vgui(".x%lx.c create prect %d %d %d %d -tags x "
"-stroke $pd_colors(selection_rectangle)\n",
x, xpos, ypos, xpos, ypos);
//sys_vgui(".x%lx.c create prect %d %d %d %d -tags x "
// "-stroke $pd_colors(selection_rectangle)\n",
// x, xpos, ypos, xpos, ypos);
gui_vmess("gui_create_selection_rectangle", "siiii", canvas_string(x),
xpos, ypos, xpos, ypos);
x->gl_editor->e_xwas = xpos;
......@@ -3762,16 +3782,16 @@ void canvas_drawconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2,
"$pd_colors(control_cord_width)"),
tag);*/
//bezier curves FTW
sys_vgui(".x%lx.c create path \"M %d %d Q %d %d %d %d Q %d %d %d %d\" "
"-stroke %s -strokewidth %s -tags {l%lx all_cords %s}\n",
x, lx1, ly1,
lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
lx2, ly2 - yoff, lx2, ly2,
(issignal ? "$pd_colors(signal_cord)" : "$pd_colors(control_cord)"),
(issignal ?
"$pd_colors(signal_cord_width)" :
"$pd_colors(control_cord_width)"),
tag, (issignal ? "signal" : "control"));
//sys_vgui(".x%lx.c create path \"M %d %d Q %d %d %d %d Q %d %d %d %d\" "
// "-stroke %s -strokewidth %s -tags {l%lx all_cords %s}\n",
// x, lx1, ly1,
// lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
// lx2, ly2 - yoff, lx2, ly2,
// (issignal ? "$pd_colors(signal_cord)" : "$pd_colors(control_cord)"),
// (issignal ?
// "$pd_colors(signal_cord_width)" :
// "$pd_colors(control_cord_width)"),
// tag, (issignal ? "signal" : "control"));
sprintf(tagbuf, "l%lx", (long unsigned int)tag);
gui_vmess("gui_canvas_line", "ssiiiiiiiiii",
canvas_string(x), tagbuf, lx1, ly1, lx1, ly1 + yoff,
......@@ -3813,11 +3833,11 @@ void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2,
//sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n",
// x, tag, lx1, ly1, lx2, ly2);
//bezier curves FTW
sys_vgui(".x%lx.c coords l%lx "
"\"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n",
x, tag, lx1, ly1,
lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
lx2, ly2 - yoff, lx2, ly2);
//sys_vgui(".x%lx.c coords l%lx "
// "\"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n",
// x, tag, lx1, ly1,
// lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
// lx2, ly2 - yoff, lx2, ly2);
sprintf(cord_tag, "l%lx", (long unsigned int)tag);
gui_vmess("gui_canvas_updateline", "ssiiiii", canvas_string(x), cord_tag,
lx1, ly1, lx2, ly2, yoff);
......@@ -3828,10 +3848,10 @@ void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2,
{
//sys_vgui(".x%lx.c coords x %d %d %d %d\n", x, lx1, ly1, lx2, ly2);
//bezier curves FTW
sys_vgui(".x%lx.c coords x \"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n",
x, lx1, ly1,
lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
lx2, ly2 - yoff, lx2, ly2);
//sys_vgui(".x%lx.c coords x \"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n",
// x, lx1, ly1,
// lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy,
// lx2, ly2 - yoff, lx2, ly2);
gui_vmess("gui_canvas_updateline", "ssiiiii", canvas_string(x), "newcord",
lx1, ly1, lx2, ly2, yoff);
// lx1, ly1, lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy, lx2, ly2 - yoff,
......@@ -4497,10 +4517,15 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
"%si%d",
rtext_gettag(y),
closest2);
sys_vgui(".x%x.c itemconfigure %s "
"-stroke $select_nlet_color "
"-strokewidth $highlight_width\n",
x, x->gl_editor->canvas_cnct_inlet_tag);
//sys_vgui(".x%x.c itemconfigure %s "
// "-stroke $select_nlet_color "
// "-strokewidth $highlight_width\n",
// x, x->gl_editor->canvas_cnct_inlet_tag);
gui_vmess("gui_highlight_io", "ss",
canvas_string(x),
x->gl_editor->canvas_cnct_inlet_tag);
//sys_vgui(".x%x.c raise %s\n",
// x,
// x->gl_editor->canvas_cnct_inlet_tag);
......
......@@ -362,11 +362,13 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
dispx + LMARGIN, dispy + TMARGIN,
outchars_b, tempbuf, sys_hostfontsize(font),
(glist_isselected(x->x_glist, ((t_gobj*)x->x_text)) ? "$pd_colors(selection)" : "$pd_colors(text)"));
gui_vmess("gui_text_new", "sssiffsi",
gui_vmess("gui_text_new", "sssiiisi",
canvas_string(canvas), x->x_tag, rtext_gettype(x)->s_name,
glist_isselected(x->x_glist, ((t_gobj*)x->x_text)),
dispx + LMARGIN,
dispy + TMARGIN,
LMARGIN,
TMARGIN,
// dispx + LMARGIN,
// dispy + TMARGIN,
tempbuf,
sys_hostfontsize(font));
......
......@@ -1898,19 +1898,24 @@ void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
{
//fprintf(stderr,"glist_drawiofor o firsttime\n");
issignal = obj_issignaloutlet(ob,i);
sys_vgui(".x%lx.c create prect %d %d %d %d \
-fill %s -stroke %s -tags {%so%d %lx outlet %s %s}\n",
glist_getcanvas(glist), onset, y2 - 2, onset + IOWIDTH, y2,
(issignal ? "$pd_colors(signal_nlet)" :
"$pd_colors(control_nlet)"),
(issignal ? "$pd_colors(signal_cord)" :
"$pd_colors(control_cord)"),
tag, i, tag,
(issignal ? "signal" : "control"),
(selected ? "selected" : ""));
gui_vmess("gui_canvas_drawio", "sssiiiiii",
//sys_vgui(".x%lx.c create prect %d %d %d %d \
// -fill %s -stroke %s -tags {%so%d %lx outlet %s %s}\n",
// glist_getcanvas(glist), onset, y2 - 2, onset + IOWIDTH, y2,
// (issignal ? "$pd_colors(signal_nlet)" :
// "$pd_colors(control_nlet)"),
// (issignal ? "$pd_colors(signal_cord)" :
// "$pd_colors(control_cord)"),
// tag, i, tag,
// (issignal ? "signal" : "control"),
// (selected ? "selected" : ""));
/* need to send issignal and is_iemgui here... */
gui_vmess("gui_canvas_drawio", "sssiiiiiisiii",
canvas_string(glist_getcanvas(glist)), rtext_gettag(y), tag,
onset, y2 - 2, onset + IOWIDTH, y2, x1, y1);
onset, y2 - 2, onset + IOWIDTH, y2, x1, y1, "o", i,
issignal, 0);
}
else
{
......@@ -1936,20 +1941,21 @@ void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
{
//fprintf(stderr,"glist_drawiofor i firsttime\n");
issignal = obj_issignalinlet(ob,i);
sys_vgui(".x%lx.c create prect %d %d %d %d \
-fill %s -stroke %s -tags {%si%d %lx inlet %s %s}\n",
glist_getcanvas(glist), onset, y1,
onset + IOWIDTH, y1 + EXTRAPIX,
(issignal ? "$pd_colors(signal_nlet)" :
"$pd_colors(control_nlet)"),
(issignal ? "$pd_colors(signal_cord)" :
"$pd_colors(control_cord)"),
tag, i, tag,
(issignal ? "signal" : "control"),
(selected ? "selected" : ""));
gui_vmess("gui_canvas_drawio", "sssiiiiii",
//sys_vgui(".x%lx.c create prect %d %d %d %d \
// -fill %s -stroke %s -tags {%si%d %lx inlet %s %s}\n",
// glist_getcanvas(glist), onset, y1,
// onset + IOWIDTH, y1 + EXTRAPIX,
// (issignal ? "$pd_colors(signal_nlet)" :
// "$pd_colors(control_nlet)"),
// (issignal ? "$pd_colors(signal_cord)" :
// "$pd_colors(control_cord)"),
// tag, i, tag,
// (issignal ? "signal" : "control"),
// (selected ? "selected" : ""));
gui_vmess("gui_canvas_drawio", "sssiiiiiisiii",
canvas_string(glist_getcanvas(glist)), rtext_gettag(y), tag,
onset, y1, onset + IOWIDTH, y1 + EXTRAPIX, x1, y1);
onset, y1, onset + IOWIDTH, y1 + EXTRAPIX, x1, y1, "i", i,
issignal, 0);
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment