Commit 158cc991 authored by Albert Gräf's avatar Albert Gräf
Browse files

Revert Ico's nwjs-0.4x patchset.

parent 96b23d10
......@@ -235,6 +235,8 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
{
//fprintf(stderr,"image_select %d\n", state);
t_image *x = (t_image *)z;
gui_vmess("gui_image_toggle_border", "xxi",
glist_getcanvas(glist), x, state);
if (state)
{
if (x->x_glist == glist_getcanvas(glist))
......@@ -260,14 +262,12 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
text_xpix(&x->x_obj, glist) + x->x_width/2,
text_ypix(&x->x_obj, glist) + x->x_height/2, x);
}
gui_vmess("gui_image_toggle_border", "xxi", glist_getcanvas(glist),
x, 1);
}
gui_vmess("gui_gobj_select", "xx", glist_getcanvas(glist), x);
//if (glist->gl_owner && !glist_istoplevel(glist))
//sys_vgui(".x%x.c addtag selected withtag %xS\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c addtag selected withtag %xMT\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c addtag selected withtag %xSEL\n", glist_getcanvas(glist), x);
gui_vmess("gui_gobj_select", "xx", glist_getcanvas(glist), x);
}
else
{
......@@ -276,8 +276,6 @@ static void image_select(t_gobj *z, t_glist *glist, int state)
//if (glist->gl_owner && !glist_istoplevel(glist))
//sys_vgui(".x%lx.c dtag %xS selected\n", glist_getcanvas(glist), x);
//sys_vgui(".x%lx.c dtag %xMT selected\n", glist_getcanvas(glist), x);
gui_vmess("gui_image_toggle_border", "xxi", glist_getcanvas(glist),
x, 0);
gui_vmess("gui_gobj_deselect", "xx", glist_getcanvas(glist), x);
}
}
......@@ -342,7 +340,7 @@ static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, i
if (doit && x->x_click)
outlet_bang(x->x_obj.ob_outlet);
// LATER: figure out how to do click on and click off
// and provide a toggle button behavior instead
// and provide a toggle button behavior insteadS
/*{
x->x_clicked = 1;
outlet_float(x->x_obj.ob_outlet, x->x_clicked);
......
......@@ -20,13 +20,6 @@ body {
font-family: "DejaVu Sans Mono";
}
/* delete the default scrollbars, and let's make our own */
body::-webkit-scrollbar {
width: 0px;
height: 0px;
background: transparent;
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
......@@ -279,8 +272,7 @@ mark.console_find_highlighted {
min-width: 3ch;
position: absolute;
display: table-cell;
padding: 3px 1.5px 3px 1.5px;
margin-left: 1px;
padding: 3px 2px 3px 2px;
/* box-shadow: inset 1px 0px 0px 1px #000; */
color: black; /* text color */
background-color: transparent;
......@@ -290,7 +282,7 @@ mark.console_find_highlighted {
}
#new_object_textentry.obj {
outline: 2px solid #e87216;
outline: 1px solid #e87216;
}
/* We're dynamically creating the svg background data in javascript
......@@ -320,10 +312,9 @@ text {
//cursor: default;
}
/* not sure if this is still needed...
updated the coloring just in case */
/* not sure if this is still needed */
.selected_border {
stroke: #e87216;
stroke: blue;
stroke-dasharray: none;
stroke-width: 1;
}
......@@ -400,12 +391,6 @@ text {
stroke-dasharray: 3 2;
}
/* ico@vt.edu: added selected border coloring
in edit mode only */
#patchsvg.editmode .comment.selected .border {
stroke: #e87216;
}
/* A little hack for special case of [cnv].
All other iemguis have a black border, but
[cnv] sets its selection rectangle to the
......@@ -433,17 +418,14 @@ text {
in plain English:
This lets us highlight an object's border, unless it is inside a gop
canvas.
ico@vt.edu added selection highlight only if we are in editmode
*/
#patchsvg.editmode :not(.gop).selected .border {
:not(.gop).selected .border {
stroke: #e87216;
display: inline;
}
/* text inside selected objects
ico@vt.edu added selection highlight only if we are in editmode */
#patchsvg.editmode :not(.gop).selected text {
/* text inside selected objects */
:not(.gop).selected text {
fill: #e87216;
}
......@@ -489,12 +471,22 @@ text {
for every pixel we move inside an xlet. */
@-webkit-keyframes fizzle {
0% {
stroke-width: 1;
stroke-opacity: 1;
rx: 1;
ry: 1;
}
33% {
stroke-width: 12;
stroke-opacity: 1;
rx: 1;
ry: 1;
}
100% {
66% {
stroke-width: 5;
stroke-opacity: 1;
rx: 1;
ry: 1;
}
}
......@@ -503,19 +495,14 @@ text {
stroke: #e87216;
fill: #e87216;
stroke-width: 5;
-webkit-animation: fizzle 0.2s ease-in 1;
}
.xlet_disabled {
stroke: gray !important;
fill: gray !important;
-webkit-animation: fizzle 0.4s ease-in 1;
}
#canvas_find {
width: 100%;
height: 1em;
padding-top: 2px;
padding-left: 2px;
padding-top: 4px;
padding-left: 8px;
padding-bottom: 8px;
background: silver;
position: fixed;
......@@ -526,18 +513,10 @@ text {
/* Dialog to ask to save the patch before quitting */
#save_before_quit {
background-color: #f3f3f3;
border:1px solid #f3f3f3;
border:1px solid #bbb;
padding: 12px;
margin: 12px;
/*box-shadow: 7px 7px 5px grey;*/
left: 50%;
top: 50%;
width: 40%;
transform: translate(-50%, -50%);
}
dialog::backdrop {
background: rgba(0, 0, 0, 0.5);
box-shadow: 7px 7px 5px grey;
}
/* Search dialog */
......
......@@ -17,9 +17,8 @@
</button>
</div>
<dialog id="save_before_quit">
<h5 style="text-align: center;">
Do you want to save the changes you made before closing the window?
</h5>
<h4>Do you want to save the changes you made before closing the window?
</h4>
<div class="submit_buttons">
<button type="button"
onClick="ok()"
......
......@@ -399,25 +399,16 @@ function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) {
var eval_string = "register_window_id(" +
JSON.stringify(cid) + ", " +
JSON.stringify(attr_array) + ");";
//pdgui.post("x=" + xpos + " y=" + ypos);
var pos;
if (xpos == 0 && ypos == 0) {
pos = "center";
} else {
pos = "null";
}
gui.Window.open(my_file, {
title: my_title,
// ico@vt.edu: position in 0.46.2 overrides x and y below
position: pos,
position: "center",
focus: true,
width: width,
// We add 23 as a kludge to account for the menubar at the top of
// the window. Ideally we would just get rid of the canvas menu
// altogether to simplify things. But we'd have to add some kind of
// widget for the "Put" menu.
// ico@vt.edu: on 0.46.2 this is now 25, go figure...
height: height + 25,
height: height + 23,
x: xpos,
y: ypos
}, function (new_win) {
......
......@@ -4,9 +4,6 @@
"main": "index.html",
"chromium-args": "--proxy-server=http://127.0.0.1 --password-store=basic",
"window": {
"icon": "./purr.png",
"position": "center",
"width": 540,
"height": 440
"icon": "./purr.png"
}
}
......@@ -39,13 +39,11 @@
defaultValue="Search in Canvas"
style="width:10em"/>
</label>
<label><span data-i18n="canvas.find.whole_word"
style="margin-left: 7px; margin-right: -3px;"></span>
<input type="checkbox"
<label><span data-i18n="canvas.find.whole_word"></span>
<input type="checkbox"
id="canvas_find_whole_word"
name="canvas_find_whole_word"
onchange="canvas_find_whole_word(this);"
style="position: relative; top: 2px; margin-right: 5px;"/>
onchange="canvas_find_whole_word(this);"/>
</label>
<button type="button"
id="canvas_find_button"
......@@ -57,9 +55,9 @@
<ol></ol>
</div>
<dialog id="save_before_quit">
<h5 style="text-align: center;"><span data-i18n="canvas.save_dialog.prompt"></span>
<h4><span data-i18n="canvas.save_dialog.prompt"></span>
<span id="save_before_quit_filename"></span>?
</h5>
</h4>
<div class="submit_buttons">
<button type="button"
id="yes_button"
......@@ -78,8 +76,6 @@
</button>
</div>
</dialog>
<div id="hscroll" style="background-color: #00000044; position: fixed; left: 2px; bottom: 2px; border-radius: 0px; width: 10px; height: 5px; visibility: hidden;"></div>
<div id="vscroll" style="background-color: #00000044; position: fixed; right: 2px; top: 2px; border-radius: 0px; width: 5px; height: 10px; visibility: hidden;"></div>
<script type="text/javascript" src="./pd_canvas.js"></script>
</body>
</html>
......@@ -233,13 +233,6 @@ var canvas_events = (function() {
return false;
},
mousedown: function(evt) {
// ico@vt.edu capture middle click for a different type of scroll
// currently disabled due to problem with scrollBy and zoom
/*if (evt.which == 2)
{
evt.stopPropagation();
evt.preventDefault();
}*/
var target_id, resize_type;
if (target_is_scrollbar(evt)) {
return;
......@@ -332,7 +325,8 @@ var canvas_events = (function() {
pdgui.keydown(name, evt);
// prevent the default behavior of scrolling
// on arrow keys in editmode
if (document.querySelector("#patchsvg")) {
if (document.querySelector("#patchsvg")
.classList.contains("editmode")) {
if ([32, 37, 38, 39, 40].indexOf(evt.keyCode) > -1) {
evt.preventDefault();
}
......@@ -527,64 +521,6 @@ var canvas_events = (function() {
}
canvas_events[canvas_events.get_previous_state()]();
},
hscroll_mouseup: function(evt) {
canvas_events[canvas_events.get_previous_state()]();
},
hscroll_mousemove: function(evt) {
if (evt.movementX != 0) {
//console.log("move: " + e.movementX);
var hscroll = document.getElementById("hscroll");
var svg_elem = document.getElementById("patchsvg");
var min_width = document.body.clientWidth + 3;
var width = svg_elem.getAttribute('width');
var xScrollSize;
xScrollSize = hscroll.offsetWidth;
var xTranslate = evt.movementX *
((width - min_width)/(min_width - xScrollSize)) *
(evt.movementX > 0 ? 1 : 0.75);
if (xTranslate > 0 && xTranslate < 1) {
xTranslate = 1;
}
if (xTranslate < 0 && xTranslate > -1) {
xTranslate = -1;
}
//console.log(xTranslate);
window.scrollBy(xTranslate, 0);
}
},
vscroll_mouseup: function(evt) {
canvas_events[canvas_events.get_previous_state()]();
},
vscroll_mousemove: function(evt) {
if (evt.movementY != 0) {
//console.log("move: " + e.movementY);
var vscroll = document.getElementById("vscroll");
var svg_elem = document.getElementById("patchsvg");
var min_height = document.body.clientHeight + 3;
var height = svg_elem.getAttribute('height');
var yScrollSize;
yScrollSize = vscroll.offsetHeight;
var yTranslate = evt.movementY *
((height - min_height)/(min_height - yScrollSize)) *
(evt.movementY > 0 ? 2 : 1.5);
if (yTranslate > 0 && yTranslate < 1) {
yTranslate = 1;
}
if (yTranslate < 0 && yTranslate > -1) {
yTranslate = -1;
}
//console.log(yTranslate);
window.scrollBy(0, yTranslate);
}
},
dropdown_menu_keydown: function(evt) {
var select_elem = document.querySelector("#dropdown_list"),
li;
......@@ -793,16 +729,6 @@ var canvas_events = (function() {
document.addEventListener("mouseup",
events.iemgui_label_mouseup, false);
},
hscroll_drag: function() {
canvas_events.none();
document.addEventListener("mouseup", events.hscroll_mouseup, false);
document.addEventListener("mousemove", events.hscroll_mousemove, false);
},
vscroll_drag: function() {
canvas_events.none();
document.addEventListener("mouseup", events.vscroll_mouseup, false);
document.addEventListener("mousemove", events.vscroll_mousemove, false);
},
text: function() {
canvas_events.none();
......@@ -844,9 +770,6 @@ var canvas_events = (function() {
document.addEventListener("keydown", events.find_keydown, false);
state = "search";
},
update_scrollbars: function() {
pdgui.gui_update_scrollbars(name);
},
register: function(n) {
name = n;
},
......@@ -964,13 +887,6 @@ var canvas_events = (function() {
console.log("tried to save something");
}, false
);
// add listener for the scrollbars
document.getElementById("hscroll").
addEventListener("mousedown", canvas_events.hscroll_drag, false);
document.getElementById("vscroll").
addEventListener("mousedown", canvas_events.vscroll_drag, false);
// Whoa-- huge workaround! Right now we're getting
// the popup menu the way Pd Vanilla does it:
// 1) send a mouse(down) message to Pd
......@@ -1114,16 +1030,15 @@ var canvas_events = (function() {
gui.Window.get().on("maximize", function() {
pdgui.gui_canvas_get_scroll(name);
});
gui.Window.get().on("restore", function() {
gui.Window.get().on("unmaximize", function() {
pdgui.gui_canvas_get_scroll(name);
});
gui.Window.get().on("resize", function() {
pdgui.post("resize");
pdgui.gui_canvas_get_scroll(name);
});
gui.Window.get().on("focus", function() {
nw_window_focus_callback(name);
});
});
gui.Window.get().on("blur", function() {
nw_window_blur_callback(name);
});
......@@ -1132,12 +1047,6 @@ var canvas_events = (function() {
pdgui.pdsend(name, "setbounds", x, y,
x + w.width, y + w.height);
});
// map onscroll event
document.addEventListener("scroll", function() {
pdgui.gui_update_scrollbars(name);
});
// set minimum window size
gui.Window.get().setMinimumSize(150, 100);
}
......@@ -1605,7 +1514,6 @@ function nw_create_patch_window_menus(gui, w, name) {
click: function() {
var win = gui.Window.get();
win.toggleFullscreen();
pdgui.gui_canvas_get_scroll(name);
}
});
......
This diff is collapsed.
......@@ -1553,10 +1553,10 @@ void garray_redraw(t_garray *x)
*/
sys_queuegui(&x->x_gobj, x->x_glist, garray_doredraw);
/* 1-24-2015 Ico: the approach below, however causes painfully slow and
inefficient redraw when we use tabwrite which writes one point per
array and requests redraw after each point is changed. Thus it is
deprecated in favor of the approach above */
/* 1-24-2015 Ico: this however causes painfully slow and inefficient red
when we use tabwrite which writes one point per array and requests
redraw after each point is changed. Thus it is deprecated in favor of
of the approach above */
//garray_doredraw(&x->x_gobj, x->x_glist);
}
......@@ -1950,12 +1950,6 @@ static void garray_print(t_garray *x)
x->x_realname->s_name, array->a_templatesym->s_name, array->a_n);
}
/* ico@vt.edu: used for scalar to detect type and thereby adjust visual offset */
int garray_get_style(t_garray *x)
{
return(x->x_style);
}
void g_array_setup(void)
{
garray_class = class_new(gensym("array"), 0, (t_method)garray_free,
......
......@@ -704,8 +704,6 @@ t_symbol *canvas_makebindsym(t_symbol *s)
return (gensym(buf));
}
int garray_getname(t_garray *x, t_symbol **namep);
void canvas_args_to_string(char *namebuf, t_canvas *x)
{
t_canvasenvironment *env = canvas_getenv(x);
......@@ -715,37 +713,16 @@ void canvas_args_to_string(char *namebuf, t_canvas *x)
strcpy(namebuf, " (");
for (i = 0; i < env->ce_argc; i++)
{
if (strlen(namebuf) > MAXPDSTRING / 2 - 5)
if (strlen(namebuf) > MAXPDSTRING/2 - 5)
break;
if (i != 0)
strcat(namebuf, " ");
atom_string(&env->ce_argv[i], namebuf + strlen(namebuf),
MAXPDSTRING / 2);
atom_string(&env->ce_argv[i], namebuf + strlen(namebuf),
MAXPDSTRING/2);
}
strcat(namebuf, ")");
}
else
{
namebuf[0] = 0;
t_gobj *g = NULL;
t_symbol *arrayname;
int found = 0;
for (g = x->gl_list; g; g = g->g_next)
{
if (pd_class(&g->g_pd) == garray_class)
{
garray_getname((t_garray *)g, &arrayname);
if (found)
{
strcat(namebuf, " ");
}
strcat(namebuf, arrayname->s_name);
found++;
//post("found=%d %s %s", found, arrayname->s_name, namebuf);
}
}
}
else namebuf[0] = 0;
}
void canvas_reflecttitle(t_canvas *x)
......@@ -1337,8 +1314,8 @@ static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
< 4 ||
sscanf(topgeom->s_name, "%dx%d+%d+%d", &tw, &th, &txpix, &typix) < 4)
bug("canvas_relocate");
/* for some reason this is initially called with cw=ch=1 so
we just suppress that here. */
/* for some reason this is initially called with cw=ch=1 so
we just suppress that here. */
if (cw > 5 && ch > 5)
canvas_dosetbounds(x, txpix, typix,
txpix + cw, typix + ch);
......@@ -1348,44 +1325,24 @@ static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom,
t_array *a = NULL;
int num_elem = 0;
//int found_garray = 0;
for (g = x->gl_list; g; g = g->g_next)
{
//fprintf(stderr, "searching\n");
//post("searching");
//for subpatch garrays
if (pd_class(&g->g_pd) == garray_class)
{
//fprintf(stderr,"found ya\n");
//post("found ya");
ga = (t_garray *)g;
if (ga)
{
a = garray_getarray(ga);
num_elem = a->a_n;
garray_fittograph(ga, num_elem, 1);
//found_garray = 1;
}
}
}
canvas_checkconfig(x);
// ico@vt.edu:
// Here we update only scrollbars to avoid race condition
// caused by doing gui_canvas_get_scroll which in turn
// calls canvas_relocate to ensure garrays in subpatches
// are properly updated when those windows are resized.
// given that the scroll update will happen likely faster
// than the return value from the backend, we do this to
// get rid of the stale scrollbars, e.g. when making the
// window smaller (at first the scrollbars are there because
// the garray has not been redrawn yet, and then we update
// scrollbars once again here below.
//if (found_garray == 1) {
//post("found garray");
gui_vmess("do_getscroll", "xi", x, 0);
//}
}
void canvas_popabstraction(t_canvas *x)
......@@ -2249,7 +2206,9 @@ static void canvas_f(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
}
// if we are part of a restore message
// of a subpatch in the form "#X restore..., f 123456789+;"
if (!x->gl_list || !strcmp(last_typedmess->s_name, "restore"))
if (pd_class(last_typedmess_pd) == canvas_class &&
(t_canvas *)last_typedmess_pd == x &&
last_typedmess == gensym("restore"))
{
if (x->gl_owner && !x->gl_isgraph)
{
......@@ -2440,7 +2399,7 @@ void canvasgop__motionhook(t_scalehandle *sh, t_floatarg mouse_x,
that is being used to draw the gop red rect move anchor atm. So
rather than muck around with that code, we just set a pointer to
whatever our toplevel is here: */
t_glist *owner = glist_getcanvas(x);
t_glist *owner = canvas_getrootfor(x);
/* Just unvis the object, then vis it once we've done our
mutation and checks */
gobj_vis((t_gobj *)x, owner, 0);
......@@ -2462,9 +2421,7 @@ void canvasgop__motionhook(t_scalehandle *sh, t_floatarg mouse_x,
//fprintf(stderr,"%d %d %d %d\n", tmpx1, tmpy1, tmpx2, tmpy2);
if (!x->gl_hidetext)
{
/* ico@vt.edu: we add pixels to match minimum space
on the right side of the text to that of the left side */
tmp_x_final = tmpx2 - tmpx1 + 2;
tmp_x_final = tmpx2 - tmpx1;
tmp_y_final = tmpy2 - tmpy1;
}
else
......
This diff is collapsed.
......@@ -722,112 +722,38 @@ t_float glist_pixelstoy(t_glist *x, t_float ypix)
}
}
/* ico@vt.edu: used by the scalar_vis to adjust visual offset
based on the graph drawing style, affects bar graph */
extern int garray_get_style(t_garray *x);
/* convert an x coordinate value to an x pixel location in window */
t_float glist_xtopixels(t_glist *x, t_float xval)
{
// ico@vt.edu: used to deal with the bar graph
t_float plot_offset = 0;
t_gobj *g = x->gl_list;