Commit 3e79ec43 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'master' into straight-lines-for-vanilla

parents 9caaf438 e8e05380
......@@ -415,9 +415,16 @@ select {
</select>
<br/>
<label data-i18n="[title]prefs.gui.grid.show_grid_tt">
<input type="checkbox" id="show_grid" name="show_grid">
<input type="checkbox" id="show_grid" name="show_grid"
onchange="grid_toggle(this.checked)">
<span data-i18n="prefs.gui.grid.show_grid"></span>
</label>
<select id="grid_size">
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
<br/>
<label data-i18n="[title]prefs.gui.zoom.save_zoom_tt">
<input type="checkbox" id="save_zoom" name="save_zoom">
......@@ -783,6 +790,7 @@ function apply(save_prefs) {
pdgui.pdsend("pd gui-prefs",
get_gui_preset(),
get_bool_elem("show_grid"),
document.getElementById("grid_size").value,
get_bool_elem("save_zoom"),
get_bool_elem("browser_doc"),
get_bool_elem("browser_path"),
......@@ -796,7 +804,8 @@ function apply(save_prefs) {
get_bool_elem("browser_path")
);
// Update the grid on all open windows.
pdgui.update_grid(get_bool_elem("show_grid"));
pdgui.update_grid(get_bool_elem("show_grid"),
document.getElementById("grid_size").value);
// Send the startup config data to Pd
pdgui.pdsend.apply(null, ["pd path-dialog", startup_use_stdpath, startup_verbose].concat(get_path_array()));
......@@ -1035,13 +1044,18 @@ function midi_prefs_callback(attrs) {
pdgui.resize_window(pd_object_callback);
}
function grid_toggle(checked) {
document.getElementById("grid_size").disabled = !checked;
document.getElementById("show_grid").checked = checked;
}
function autopatch_yoffset_toggle(checked) {
document.getElementById("autopatch_yoffset_value").disabled = !checked;
document.getElementById("autopatch_yoffset").checked = checked;
}
function gui_prefs_callback(name, show_grid, save_zoom, browser_doc, browser_path,
browser_init, autopatch_yoffset) {
function gui_prefs_callback(name, show_grid, grid_size, save_zoom, browser_doc,
browser_path, browser_init, autopatch_yoffset) {
var s = document.getElementById("gui_preset");
// ag: scan the css subdir for user-defined styles
......@@ -1071,6 +1085,8 @@ function gui_prefs_callback(name, show_grid, save_zoom, browser_doc, browser_pat
}
}
document.getElementById("show_grid").checked = !!show_grid;
document.getElementById("grid_size").value = grid_size;
grid_toggle(!!show_grid);
document.getElementById("save_zoom").checked = !!save_zoom;
document.getElementById("browser_doc").checked = !!browser_doc;
document.getElementById("browser_path").checked = !!browser_path;
......
......@@ -432,8 +432,8 @@
"footgun": "Fusspistole"
},
"grid": {
"show_grid": "Gitter-Hintergrund im Edit-Modus",
"show_grid_tt": "Gitter-Hintergrund im Edit-Modus anzeigen"
"show_grid": "Am Gitter ausrichten (experimentell)",
"show_grid_tt": "Ausrichten am Gitter im Edit-Modus"
},
"zoom": {
"save_zoom": "Speichern/Laden der Vergrößerung im Patch",
......
......@@ -432,8 +432,8 @@
"footgun": "Footgun"
},
"grid": {
"show_grid": "grid background in edit mode",
"show_grid_tt": "Show the grid background in edit mode"
"show_grid": "snap to grid (experimental)",
"show_grid_tt": "Snap to the grid in edit mode"
},
"zoom": {
"save_zoom": "save/load zoom level with patch",
......
......@@ -432,8 +432,8 @@
"footgun": "Footgun"
},
"grid": {
"show_grid": "Fond de grille en mode Édition",
"show_grid_tt": "Afficher l'arrière-plan de la grille en mode Édition"
"show_grid": "Aligner sur la grille (expérimental)",
"show_grid_tt": "Accrocher à la grille en mode Édition"
},
"zoom": {
"save_zoom": "Sauver/Charger niveau zoom avec patch",
......
......@@ -53,23 +53,39 @@ var canvas_events = (function() {
textbox = function () {
return document.getElementById("new_object_textentry");
},
add_events = function(context, events) {
// convenience routine for adding a bunch of events at once
current_events = {}, // keep track of our current listeners
edit_events = function(elem, events, action, init) {
// convenience routine for adding an object full of
// event: callback pairs
var e;
for (e in events) {
if (events.hasOwnProperty(e)) {
context["addEventListener"](e, events[e], false);
elem[action + "EventListener"](e, events[e], false);
if (action === "remove") {
// remove the key
delete current_events[e];
}
else if (!init) {
// We shouldn't ever be overwriting an existing
// event. So send a warning if we already exist
if (current_events[e]) {
pdgui.post("Consistency check failed for " +
"event " + e + " of element " + elem);
}
current_events[e] = events[e];
}
}
}
},
remove_events = function(context, events) {
// convenience routine for removing a bunch of events at once
var e;
for (e in events) {
if (events.hasOwnProperty(e)) {
context["addEventListener"](e, events[e], false);
}
}
init_events = function(elem, events) {
edit_events(elem, events, "add", true);
},
add_events = function(elem, events) {
// add
edit_events(elem, events, "add", false);
},
remove_events = function(elem, events) {
edit_events(elem, events, "remove", false);
},
find_scalar_draggable = function (elem) {
var ret = elem;
......@@ -655,70 +671,6 @@ var canvas_events = (function() {
}
canvas_events[canvas_events.get_previous_state()]();
},
hscroll_mouseup: function(evt) {
document.getElementById("hscroll").style
.setProperty("background-color", "rgba(0, 0, 0, 0.267)");
document.getElementById("patchsvg").style.cursor = "default";
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) {
document.getElementById("vscroll").style
.setProperty("background-color", "rgba(0, 0, 0, 0.267)");
document.getElementById("patchsvg").style.cursor = "default";
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;
......@@ -897,26 +849,8 @@ var canvas_events = (function() {
previous_state = state;
}
state = "none";
for (prop in events) {
if (events.hasOwnProperty(prop)) {
evt_name = prop.split("_");
evt_name = evt_name[evt_name.length - 1];
document.removeEventListener(evt_name, events[prop], false);
// ag: Also get rid of the touch event handlers, which are
// bound to the same handlers as the corresponding mouse
// events.
if (evt_name == "mousemove") {
document.removeEventListener("touchmove",
events[prop], false);
} else if (evt_name == "mousedown") {
document.removeEventListener("touchstart",
events[prop], false);
} else if (evt_name == "mouseup") {
document.removeEventListener("touchend",
events[prop], false);
}
}
}
// remove whatever we currently have bound in current_events object
remove_events(document, current_events);
},
normal: function() {
canvas_events.none();
......@@ -962,26 +896,82 @@ var canvas_events = (function() {
"touchend": events.iemgui_label_mouseup
});
},
hscroll_drag: function() {
hscroll_drag: function(e) {
e.preventDefault(); // prevent drag-and-drop- events
canvas_events.none();
document.getElementById("hscroll").style
.cssText += "background-color: rgba(0, 0, 0, 0.5) !important";
document.getElementById("patchsvg").style.cursor =
"-webkit-grabbing";
add_events(document, {
"mouseup": events.hscroll_mouseup,
"mousemove": events.hscroll_mousemove
"mouseup": function(evt) {
document.getElementById("hscroll").style
.setProperty("background-color", "rgba(0, 0, 0, 0.267)");
document.getElementById("patchsvg").style.cursor = "default";
canvas_events[canvas_events.get_previous_state()]();
},
"mousemove": function(evt) {
pdgui.post("moving the thingy");
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_drag: function() {
vscroll_drag: function(e) {
e.preventDefault(); // prevent drag-and-drop events
canvas_events.none();
document.getElementById("vscroll").style
.cssText += "background-color: rgba(0, 0, 0, 0.5) !important";
document.getElementById("patchsvg").style.cursor =
"-webkit-grabbing";
add_events(document, {
"mouseup": events.vscroll_mouseup,
"mousemove": events.vscroll_mousemove
"mouseup": function(evt) {
document.getElementById("vscroll").style
.setProperty("background-color", "rgba(0, 0, 0, 0.267)");
document.getElementById("patchsvg").style.cursor = "default";
canvas_events[canvas_events.get_previous_state()]();
},
"mousemove": function(evt) {
pdgui.post("hello");
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);
}
}
});
},
text: function() {
......@@ -1164,7 +1154,7 @@ var canvas_events = (function() {
document.getElementById("vscroll").
addEventListener("mousedown", canvas_events.vscroll_drag, false);
add_events(document, {
init_events(document, {
"contextmenu": function(evt) {
// Whoa-- huge workaround! Right now we're getting
// the popup menu the way Pd Vanilla does it:
......@@ -1291,7 +1281,7 @@ var canvas_events = (function() {
);
// disable drag and drop for the time being
add_events(window, {
init_events(window, {
"dragover": function (evt) {
evt.preventDefault();
},
......
......@@ -1374,36 +1374,146 @@ function menu_send(name) {
}
}
/*
ico@vt.edu 20200907: added svg tiled background to reflect edit mode and
integrated it into the canvas_set_editmode below.
// Set the grid background position to adjust for the viewBox of the svg.
// We do this separately and before setting the background so we can call this
// when the scroll view needs to be adjusted.
function get_grid_coords(cid, svg_elem) {
var vbox = svg_elem.getAttribute("viewBox").split(" "),
dx = 0, dy = 0;
// First two values of viewBox are x-origin and y-origin. Pd allows
// negative coordinates-- for example, the user can drag an object at
// (0, 0) 12 pixels to the left to arrive at (-12, 0). To accommodate this
// with the svg backend, we would adjust the x-origin to be -12 so that
// the user can view it (possibly by scrolling). These adjustments are
// all handled with gui_canvas_get_scroll.
//
// For the background image css property, everything is based on
// CSS DOM positioning. CSS doesn't really know anything about the SVG
// viewport-- it only knows that an SVG element is of a certain size and
// (in our case) has its top-left corner at the top-left corner of the
// window. So when we change the viewBox to have negative origin indices,
// we have to adjust the origin of the grid in the opposite direction
// For example, if our new x-origin for the svg viewBox is -12, we make
// the x-origin for the background image "12px". This adjustment positions
// the grid *as if* if extended 12 more pixels to the left of its
// container.
if (vbox[0] < 0) {
dx = 0 - vbox[0];
}
if (vbox[1] < 0) {
dy = 0 - vbox[1];
}
return { x: dx, y: dy };
}
function create_svg_lock(cid) {
var zoom = patchwin[cid].zoomLevel,
size;
// adjust for zoom level
size = 1 / Math.pow(1.2, zoom) * 24;
return "url('data:image/svg+xml;utf8," +
encodeURIComponent(['<svg xmlns="http://www.w3.org/2000/svg"',
['width="', size, 'px"'].join(""),
['height="', size, 'px"'].join(""),
'viewBox="0 0 486.866 486.866"',
'>',
'<path fill="#bbb" d="',
'M393.904,214.852h-8.891v-72.198c0-76.962-61.075-141.253',
'-137.411-142.625c-2.084-0.038-6.254-0.038-8.338,0',
'C162.927,1.4,101.853,65.691,101.853,142.653v1.603c0,16.182,',
'13.118,29.3,29.3,29.3c16.182,0,29.299-13.118,29.299-29.3',
'v-1.603',
'c0-45.845,37.257-83.752,82.98-83.752s82.981,37.907,82.981,',
'83.752v72.198H92.963c-13.702,0-24.878,14.139-24.878,',
'31.602v208.701',
'c0,17.44,11.176,31.712,24.878,31.712h300.941c13.703,0,',
'24.878-14.271,24.878-31.712V246.452',
'C418.783,228.989,407.607,214.852,393.904,214.852z M271.627,',
'350.591v63.062c0,7.222-6.046,13.332-13.273,13.332h-29.841',
'c-7.228,0-13.273-6.11-13.273-13.332v-63.062c-7.009-6.9-11.09',
'-16.44-11.09-26.993c0-19.999,15.459-37.185,35.115-37.977',
'c2.083-0.085,6.255-0.085,8.337,0c19.656,0.792,35.115,17.978,',
'35.115,37.977C282.717,334.149,278.637,343.69,271.627,350.591z',
'"/>',
'</svg>',
"')",
].join(" "));
}
// Background for edit mode. Currently, we use a grid if snap-to-grid
// functionality is turned on in the GUI preferences. If not, we just use
// the same grid with a lower opacity. That way the edit mode is always
// visually distinct from run mode.
var create_editmode_bg = function(cid, svg_elem) {
var data, cell_data_str, opacity_str, grid, size, pos;
grid = showgrid[cid];
size = gridsize[cid];
pos = get_grid_coords(cid, svg_elem);
// if snap-to-grid isn't turned on, just use cell size of 10 and make the
// grid partially transparent
size = grid ? size : 10;
opacity_str = '"' + (grid ? 1 : 0.4) + '"';
cell_data_str = ['"', "M", size, 0, "L", 0, 0, 0, size, '"'].join(" ");
data = ['<svg xmlns="http://www.w3.org/2000/svg" ',
'width="1000" height="1000" ',
'opacity=', opacity_str, '>',
'<defs>',
'<pattern id="cell" patternUnits="userSpaceOnUse" ',
'width="', size, '" height="', size, '">',
'<path fill="none" stroke="#ddd" stroke-width="1" ',
'd=', cell_data_str,'/>',
'</pattern>',
'<pattern id="grid" patternUnits="userSpaceOnUse" ',
'width="100" height="100" x="', pos.x, '" y="', pos.y, '">',
'<rect width="500" height="500" fill="url(#cell)" />',
'<path fill="none" stroke="#bbb" stroke-width="1" ',
'd="M 500 0 L 0 0 0 500"/>',
'</pattern>',
'</defs>',
'<rect width="1000" height="1000" fill="url(#grid)" />',
'</svg>'
].join(" ");
// make sure to encode the data so we obey all the rules with our data URL
return "url('data:image/svg+xml;utf8," + encodeURIComponent(data) + "')";
}
LATER: consider adding an interim version that reflects only the ctrl button press
*/
var gui_editmode_svg_background = "url(\"data:image/svg+xml,%3Csvg " +
"xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 " +
" 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity" +
"='0.4'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1" +
"v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-" +
"1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9" +
"H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9" +
"V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v" +
"1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h" +
"9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-1" +
"0 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9" +
"h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-" +
"10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9" +
"h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9" +
"v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h" +
"9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h" +
"9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-1" +
"0 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-" +
"9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm1" +
"0 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9" +
"h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9" +
"h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0" +
"h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3Cpath d" +
"='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\")";
function set_bg(cid, data_url, bg_pos, repeat) {
var style = patchwin[cid].window.document.body.style;
style.setProperty("background-image", data_url);
style.setProperty("background-position", bg_pos);
style.setProperty("background-repeat", repeat);
}
function set_editmode_bg(cid, svg_elem, state)
{
var offset, zoom;
if (!state) {
set_bg(cid, "none", "0% 0%", "repeat");
} else if (showgrid[cid]) {
// Show a grid in editmode if we're snapping to grid
set_bg(cid, create_editmode_bg(cid, svg_elem), "0% 0%", "repeat");
} else {
// Otherwise show a little lock in the top right corner of the patch
// adjusting for zoom level
zoom = patchwin[cid].zoomLevel;
offset = 1 / Math.pow(1.2, zoom) * 5;
offset = offset + "px";
set_bg(cid, create_svg_lock(cid),
["right", offset, "top", offset].join(" "),
"no-repeat");
}
}
function update_svg_background(cid, svg_elem) {
var bg = patchwin[cid].window.document.body.style
.getPropertyValue("background-image");
// Quick hack-- we just check whether the background has been drawn. If
// it has we assume we're in editmode.
if (bg !== "none") {
set_editmode_bg(cid, svg_elem, 1);
}
}
// requires nw.js API (Menuitem)
function canvas_set_editmode(cid, state) {
......@@ -1411,15 +1521,13 @@ function canvas_set_editmode(cid, state) {
w.set_editmode_checkbox(state !== 0 ? true : false);
if (state !== 0) {
patchsvg.classList.add("editmode");
if (showgrid[cid]) {
//post("editmode:" + gui_editmode_svg_background);
patchwin[cid].window.document.body.style.setProperty
("background-image", gui_editmode_svg_background);
}
// For now, we just change the opacity of the background grid
// depending on whether snap-to-grid is turned on. This way
// edit mode is always visually distinct.
set_editmode_bg(cid, patchsvg, true);
} else {
patchsvg.classList.remove("editmode");
patchwin[cid].window.document.body.style.setProperty("background-image",
"none");
set_editmode_bg(cid, patchsvg, false);
}
});
}
......@@ -1437,21 +1545,19 @@ function canvas_query_editmode(cid) {
exports.canvas_query_editmode = canvas_query_editmode;
function update_grid(grid) {
function update_grid(grid, grid_size_value) {
// Update the grid background of all canvas windows when the corresponding
// option in the gui prefs changes.
var bg = grid != 0 ? gui_editmode_svg_background : "none";
for (var cid in patchwin) {
showgrid[cid] = grid !== 0;
gridsize[cid] = grid_size_value;
gui(cid).get_elem("patchsvg", function(patchsvg, w) {
var editmode = patchsvg.classList.contains("editmode");
if (editmode) {
patchwin[cid].window.document.body.style.setProperty
("background-image", bg);
set_editmode_bg(cid, patchsvg, true);
}
});
}
// Also update the showgrid flags.
set_showgrid(grid);
}
exports.update_grid = update_grid;
......@@ -1713,6 +1819,7 @@ var scroll = {},
font = {},
doscroll = {},
showgrid = {},
gridsize = {},
last_loaded, // last loaded canvas
last_focused, // last focused canvas (doesn't include Pd window or dialogs)
loading = {},
......@@ -1723,12 +1830,6 @@ var scroll = {},
var patchwin = {}; // object filled with cid: [Window object] pairs
var dialogwin = {}; // object filled with did: [Window object] pairs
var set_showgrid = function(grid) {
for (var cid in showgrid) {
showgrid[cid] = grid;