Commit 82f11d02 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'aggraef/purr-data-comment-border'

parents 56b46be1 3b326993
......@@ -270,6 +270,15 @@ text {
stroke: #7569d7;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #7569d7;
stroke-dasharray: 8 4;
}
/* A little hack for special case of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -381,6 +381,15 @@ text {
stroke: #ccc;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #aaa;
stroke-dasharray: 8 4;
}
/* A little hack for special case of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -261,6 +261,15 @@ text {
stroke: #c1c1c1;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #aaa;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -282,6 +282,15 @@ text {
stroke: #3e3e3e;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #5f5f5f;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -277,6 +277,15 @@ text {
stroke: #93a1a1;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #94b2b2;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -277,6 +277,15 @@ text {
stroke: #586e75;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #475d64;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -273,6 +273,15 @@ text {
stroke: #0b560b;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #0b560b;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -267,6 +267,15 @@ text {
stroke: #666666;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: #777;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -261,6 +261,15 @@ text {
stroke: black;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: black;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -278,6 +278,15 @@ text {
stroke: white;
}
.comment .border {
fill: none;
}
#patchsvg.editmode .comment .border {
stroke: white;
stroke-dasharray: 8 4;
}
/* A little hack for special canvas of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......
......@@ -1964,15 +1964,15 @@ function gui_gobj_new(cid, tag, type, xpos, ypos, is_toplevel) {
return g;
}
function gui_text_draw_border(cid, tag, bgcolor, isbroken, x1, y1, x2, y2) {
function gui_text_draw_border(cid, tag, bgcolor, isbroken, width, height) {
gui(cid).get_gobj(tag)
.append(function(frag) {
// isbroken means either
// a) the object couldn't create or
// b) the box is empty
var rect = create_item(cid, "rect", {
width: x2 - x1,
height: y2 - y1,
width: width,
height: height,
//"shape-rendering": "crispEdges",
class: "border"
});
......@@ -2410,7 +2410,7 @@ function gui_text_set (cid, tag, text) {
});
}
function gui_text_redraw_border(cid, tag, x1, y1, x2, y2) {
function gui_text_redraw_border(cid, tag, width, height) {
// Hm, need to figure out how to refactor to get rid of
// configure_item call...
gui(cid).get_gobj(tag, function(e) {
......@@ -2418,8 +2418,8 @@ function gui_text_redraw_border(cid, tag, x1, y1, x2, y2) {
i;
for (i = 0; i < b.length; b++) {
configure_item(b[i], {
width: x2 - x1,
height: y2 - y1
width: width,
height: height
});
}
});
......
......@@ -428,7 +428,7 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
properties changed we'll adjust our layer position
to ensure that ordering is honored */
t_canvas *canvas = glist_getcanvas(x->x_glist);
t_gobj *y = (t_gobj *)x->x_glist;
//t_gobj *y = (t_gobj *)x->x_glist;
// this crashes when the label goes invisible and then
// needs to be made visible again, so for the time being
// we use the brute force redraw below for both the
......@@ -437,7 +437,6 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
//gobj_vis(y, canvas, 1);
// reorder it visually
glist_redraw(canvas);
}
}
//fprintf(stderr,"draw move x->x_w=%d\n", x->x_w);
......@@ -692,7 +691,8 @@ extern t_class *my_canvas_class;
// in 18 cases only, because canvas does not fit the pattern below.
// canvas has no label handle and has a motion handle
// but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally)
void scalehandle_draw_select(t_scalehandle *h, int px, int py) {
void scalehandle_draw_select(t_scalehandle *h, int px, int py)
{
char tagbuf[MAXPDSTRING];
t_object *x = h->h_master;
t_canvas *canvas=glist_getcanvas(h->h_glist);
......@@ -710,7 +710,8 @@ void scalehandle_draw_select(t_scalehandle *h, int px, int py) {
}
}
void scalehandle_draw_select2(t_iemgui *x) {
void scalehandle_draw_select2(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist);
t_class *c = pd_class((t_pd *)x);
int sx,sy;
......@@ -735,29 +736,35 @@ void scalehandle_draw_select2(t_iemgui *x) {
scalehandle_draw_select(x->x_lhandle,x->x_ldx,x->x_ldy);
}
void scalehandle_draw_erase(t_scalehandle *h) {
t_canvas *canvas = glist_getcanvas(h->h_glist);
void scalehandle_draw_erase(t_scalehandle *h)
{
//t_canvas *canvas = glist_getcanvas(h->h_glist);
if (!h->h_vis) return;
gui_vmess("gui_iemgui_label_show_drag_handle", "xxiiii",
h->h_glist, h->h_master, 0, 0, 0, h->h_scale);
h->h_vis = 0;
}
void scalehandle_draw_erase2(t_iemgui *x) {
void scalehandle_draw_erase2(t_iemgui *x)
{
t_scalehandle *sh = (t_scalehandle *)(x->x_handle);
t_scalehandle *lh = (t_scalehandle *)(x->x_lhandle);
if (sh->h_vis) scalehandle_draw_erase(sh);
if (lh->h_vis) scalehandle_draw_erase(lh);
}
void scalehandle_draw(t_iemgui *x) {
if (x->x_glist == glist_getcanvas(x->x_glist)) {
void scalehandle_draw(t_iemgui *x)
{
if (x->x_glist == glist_getcanvas(x->x_glist))
{
if (x->x_selected == x->x_glist) scalehandle_draw_select2(x);
else scalehandle_draw_erase2(x);
}
}
t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickhandlefn chf, t_motionhandlefn mhf) {
t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale,
t_clickhandlefn chf, t_motionhandlefn mhf)
{
t_scalehandle *h = (t_scalehandle *)pd_new(scalehandle_class);
char buf[19]; // 3 + max size of %lx
h->h_master = x;
......@@ -784,7 +791,8 @@ t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickha
return h;
}
void scalehandle_free(t_scalehandle *h) {
void scalehandle_free(t_scalehandle *h)
{
if (!h->h_scale || pd_class((t_pd *)(h->h_master)) == my_canvas_class)
{ /* only binding label handles and my_canvas resize handle */
pd_unbind((t_pd *)h, h->h_bindsym);
......@@ -792,16 +800,18 @@ void scalehandle_free(t_scalehandle *h) {
pd_free((t_pd *)h);
}
void properties_set_field_int(long props, const char *gui_field, int value) {
void properties_set_field_int(long props, const char *gui_field, int value)
{
char tagbuf[MAXPDSTRING];
sprintf(tagbuf, ".gfxstub%lx", props);
gui_vmess("gui_dialog_set_field", "ssi",
tagbuf,
gui_field,
value);
};
}
void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) {
void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y)
{
if (h->h_dragon && !h->h_scale)
{
t_iemgui *x = (t_iemgui *)(h->h_master);
......@@ -823,8 +833,8 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) {
if (glist_isvisible(x->x_glist))
{
int xpos=text_xpix(&x->x_obj, x->x_glist);
int ypos=text_ypix(&x->x_obj, x->x_glist);
//int xpos=text_xpix(&x->x_obj, x->x_glist);
//int ypos=text_ypix(&x->x_obj, x->x_glist);
//iemgui_getrect_legacy_label(x, &xpos, &ypos);
t_canvas *canvas=glist_getcanvas(x->x_glist);
gui_vmess("gui_iemgui_label_coords", "xxii",
......@@ -836,12 +846,13 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) {
}
}
void scalehandle_click_label(t_scalehandle *h) {
void scalehandle_click_label(t_scalehandle *h)
{
t_iemgui *x = (t_iemgui *)h->h_master;
if (glist_isvisible(x->x_glist))
{
//sys_vgui("lower %s\n", h->h_pathname);
t_scalehandle *othersh = x->x_handle;
//t_scalehandle *othersh = x->x_handle;
//sys_vgui("lower .x%lx.h%lx\n",
// (t_int)glist_getcanvas(x->x_glist), (t_int)othersh);
}
......@@ -965,10 +976,11 @@ void iemgui_label_draw_new(t_iemgui *x) {
x->x_fontsize);
}
void iemgui_label_draw_move(t_iemgui *x) {
void iemgui_label_draw_move(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist);
int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x;
int y1=text_ypix(&x->x_obj, x->x_glist)+x->legacy_y;
//int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x;
//int y1=text_ypix(&x->x_obj, x->x_glist)+x->legacy_y;
//iemgui_getrect_legacy_label(x, &x1, &y1);
//sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
// canvas, x, x1+x->x_ldx, y1+x->x_ldy);
......@@ -977,7 +989,7 @@ void iemgui_label_draw_move(t_iemgui *x) {
Ivica's legacy logic isn't affecting us. Quick fix below by
just adding the legacy offsets... */
gui_vmess("gui_iemgui_label_coords", "xxii",
glist_getcanvas(x->x_glist),
canvas,
x,
x->x_ldx + x->legacy_x,
x->x_ldy + x->legacy_y);
......@@ -1180,12 +1192,13 @@ void iemgui_base_draw_new(t_iemgui *x) {
sprintf(colorbuf, "#%6.6x", x->x_bcol);
gui_vmess("gui_gobj_new", "xxsiii", canvas, x,
"iemgui", x1, y1, glist_istoplevel(x->x_glist));
gui_vmess("gui_text_draw_border", "xxsiiiii",
gui_vmess("gui_text_draw_border", "xxsiii",
canvas,
x,
colorbuf,
0,
x1, y1, x2, y2);
x2 - x1,
y2 - y1);
sprintf(colorbuf, "#%6.6x", x->x_bcol);
gui_vmess("gui_iemgui_base_color", "xxs",
canvas, x, colorbuf);
......
......@@ -286,7 +286,6 @@ static int garray_get_largest_array(t_garray *x)
t_gobj *g;
t_array *a;
t_garray *tmp;
int an = 0;
// checks if there is a PLOTSTYLE_POLY vs others
// longest array uses has_*, total_* gives total number
......@@ -442,7 +441,6 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
int n = fsize, zonset, ztype, saveit;
t_symbol *zarraytype;
t_garray *x;
t_pd *x2;
t_template *template, *ztemplate;
t_symbol *templatesym;
int flags = fflags;
......@@ -1081,14 +1079,14 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
/* if it has more than 2000 points, just check 1000 of them. */
int incr = (array->a_n <= 2000 ? 1 : array->a_n / 1000);
t_float pxpix1 = 0.0, pxpix2 = 0.0, pypix = 0.0, pwpix = 0.0,
dx, dy, dy2, dy3;
dy, dy2, dy3;
for (i = 0; i < array->a_n; i += incr)
{
array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
xonset, yonset, wonset, i, xloc, yloc, xinc,
xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix, 1);
//fprintf(stderr," array_getcoordinate %d: pxpix1:%f pxpix2:%f pypix:%f pwpix:%f dx:%f dy:%f elemsize:%d yonset:%d wonset:%d xonset:%d xloc:%f yloc:%f xinc:%f\n", i, pxpix1, pxpix2, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, xloc, yloc, xinc);
// increased following on 20140830 to 8 and updated array_getcoordinate
// increased following on 20140830 to 8 and updated
// array_getcoordinate
// so that the smallest hitbox is always at least 8x8--check with
// all_about_arrays.pd inside custom scalars in an array
if (pwpix < 8)
......@@ -1101,34 +1099,13 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
best = i;
break;
}
/*
if (pwpix < 4)
pwpix = 4;
dx = pxpix1 - xpix;
if (dx < 0) dx = -dx;
if (dx > pxpix2-pxpix1) //this is the arbitrary radius away from the actual object's center, originally 8
continue;
dy = pypix - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
if (wonset >= 0)
{
dy = (pypix + pwpix) - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
dy = (pypix - pwpix) - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
}
//fprintf(stderr," 1st %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, i);*/
}
//fprintf(stderr," best = %f\n", best);
if (best == -1 && (array_joc == 0)) //this is the arbitrary radius away from the actual object's center, originally 8
/* this is the arbitrary radius away from the actual object's
center, originally 8 */
if (best == -1 && (array_joc == 0))
{
//fprintf(stderr," best > 8\n");
//fprintf(stderr,"best > 8\n");
if (scalarvis != 0)
{
//fprintf(stderr," array_doclick_element\n");
......@@ -1143,176 +1120,156 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
return (0);
}
}
//best += 0.001; /* add truncation error margin */
//for (i = 0; i < array->a_n; i += incr)
//{
//array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
// xonset, yonset, wonset, i, xloc, yloc, xinc,
// xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix, 1);
//dx = pxpix1 - xpix;
//if (dx < 0) dx = -dx;
dy = pypix - ypix;
if (dy < 0) dy = -dy;
if (wonset >= 0)
dy = pypix - ypix;
if (dy < 0) dy = -dy;
if (wonset >= 0)
{
dy2 = (pypix + pwpix) - ypix;
if (dy2 < 0) dy2 = -dy2;
dy3 = (pypix - pwpix) - ypix;
if (dy3 < 0) dy3 = -dy3;
if (yonset < 0)
dy = 100;
}
else dy2 = dy3 = 100;
#if 0 // this doesn't seem to be used anywhere -ag
int dx;
int hit = 0;
if(array_joc)
{
hit = (xpix >= pxpix1) && (xpix < pxpix2);
}
else
hit = dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best;
#endif
if (dy < dy2 && dy < dy3)
{
array_motion_fatten = 0;
//fprintf(stderr,"A\n");
}
else if (dy2 < dy3)
{
array_motion_fatten = -1;
//fprintf(stderr,"B\n");
}
else if (!array_joc)
{
array_motion_fatten = 1;
//fprintf(stderr,"C\n");
}
if (doit || (glob_lmclick && array_joc))
{
char *elem = (char *)array->a_vec;
array_motion_elemsize = elemsize;
array_motion_glist = glist;
array_motion_scalar = sc;
array_motion_array = ap;
array_motion_template = elemtemplate;
array_motion_xperpix = glist_dpixtodx(glist, 1);
array_motion_yperpix = glist_dpixtody(glist, 1);
if (alt) /* delete a point */
{
dy2 = (pypix + pwpix) - ypix;
if (dy2 < 0) dy2 = -dy2;
dy3 = (pypix - pwpix) - ypix;
if (dy3 < 0) dy3 = -dy3;
if (yonset < 0)
dy = 100;
if (array->a_n <= 1)
return (0);
memmove((char *)(array->a_vec) + elemsize * i,
(char *)(array->a_vec) + elemsize * (i+1),
(array->a_n - 1 - i) * elemsize);
//array_resize_and_redraw(array, glist, array->a_n - 1);
garray_resize(array_garray, array->a_n - 1);
canvas_setcursor(glist_getcanvas(glist), 0);
return (0);
}
else dy2 = dy3 = 100;
//fprintf(stderr," 2nd %f %f %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, dy2, dy3, elemsize, yonset, wonset, xonset, i);
//if (dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best)
//{
//fprintf(stderr, "dy=%f dy2=%f dy3=%f\n", dy, dy2, dy3);
/* from array-rev */
#if 0 // this doesn't seem to be used anywhere -ag
int hit = 0;
if(array_joc)
else if (shift)
{
hit = (xpix >= pxpix1) && (xpix < pxpix2);
/* add a point (after the clicked-on one) */
//fprintf(stderr,"add a point\n");
//array_resize_and_redraw(array, glist, array->a_n + 1);
elem = (char *)array->a_vec;
memmove(elem + elemsize * (i+1),
elem + elemsize * i,
(array->a_n - i - 1) * elemsize);
i++;
garray_resize(array_garray, array->a_n + 1);
canvas_setcursor(glist_getcanvas(glist), 0);
}
if (xonset >= 0)
{
//fprintf(stderr, " xonset >=0\n");
array_motion_xfield = xfield;
array_motion_xcumulative =
fielddesc_getcoord(xfield, array_motion_template,
(t_word *)(elem + i * elemsize), 1);
array_motion_wp = (t_word *)(elem + i * elemsize);
if (shift)
array_motion_npoints = array->a_n - i;
else array_motion_npoints = 1;
}
else
hit = dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best;
#endif
/* end array-rev */
if (dy < dy2 && dy < dy3)
{
array_motion_fatten = 0;
//fprintf(stderr,"A\n");
}
else if (dy2 < dy3)
{
array_motion_fatten = -1;
//fprintf(stderr,"B\n");
}
else if (!array_joc)
{
array_motion_fatten = 1;
//fprintf(stderr,"C\n");
}
if (doit || (glob_lmclick && array_joc))
{
char *elem = (char *)array->a_vec;
array_motion_elemsize = elemsize;
array_motion_glist = glist;
array_motion_scalar = sc;
array_motion_array = ap;
array_motion_template = elemtemplate;
array_motion_xperpix = glist_dpixtodx(glist, 1);
array_motion_yperpix = glist_dpixtody(glist, 1);
if (alt) /* delete a point */
{
if (array->a_n <= 1)
return (0);
memmove((char *)(array->a_vec) + elemsize * i,
(char *)(array->a_vec) + elemsize * (i+1),
(array->a_n - 1 - i) * elemsize);
//array_resize_and_redraw(array, glist, array->a_n - 1);
garray_resize(array_garray, array->a_n - 1);
canvas_setcursor(glist_getcanvas(glist), 0);
return (0);
}
else if (shift)
{
/* add a point (after the clicked-on one) */
//fprintf(stderr,"add a point\n");
//array_resize_and_redraw(array, glist, array->a_n + 1);