Commit 9b6fcabf authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

normalize lock size/offset

parent c64decd8
...@@ -1437,11 +1437,15 @@ function get_grid_coords(cid, svg_elem) { ...@@ -1437,11 +1437,15 @@ function get_grid_coords(cid, svg_elem) {
return { x: dx, y: dy }; return { x: dx, y: dy };
} }
function create_svg_lock() { 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," + return "url('data:image/svg+xml;utf8," +
encodeURIComponent(['<svg xmlns="http://www.w3.org/2000/svg"', encodeURIComponent(['<svg xmlns="http://www.w3.org/2000/svg"',
'width="24px"', ['width="', size, 'px"'].join(""),
'height="24px"', ['height="', size, 'px"'].join(""),
'viewBox="0 0 486.866 486.866"', 'viewBox="0 0 486.866 486.866"',
'>', '>',
'<path fill="#bbb" d="', '<path fill="#bbb" d="',
...@@ -1514,6 +1518,7 @@ function set_bg(cid, data_url, bg_pos, repeat) { ...@@ -1514,6 +1518,7 @@ function set_bg(cid, data_url, bg_pos, repeat) {
function set_editmode_bg(cid, svg_elem, state) function set_editmode_bg(cid, svg_elem, state)
{ {
var offset, zoom;
if (!state) { if (!state) {
set_bg(cid, "none", "0% 0%", "repeat"); set_bg(cid, "none", "0% 0%", "repeat");
} else if (showgrid[cid]) { } else if (showgrid[cid]) {
...@@ -1521,7 +1526,13 @@ function set_editmode_bg(cid, svg_elem, state) ...@@ -1521,7 +1526,13 @@ function set_editmode_bg(cid, svg_elem, state)
set_bg(cid, create_editmode_bg(cid, svg_elem), "0% 0%", "repeat"); set_bg(cid, create_editmode_bg(cid, svg_elem), "0% 0%", "repeat");
} else { } else {
// Otherwise show a little lock in the top right corner of the patch // Otherwise show a little lock in the top right corner of the patch
set_bg(cid, create_svg_lock(), "right 5px top 5px", "no-repeat"); // 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");
} }
} }
...@@ -1571,12 +1582,12 @@ function update_grid(grid, grid_size_value) { ...@@ -1571,12 +1582,12 @@ function update_grid(grid, grid_size_value) {
for (var cid in patchwin) { for (var cid in patchwin) {
showgrid[cid] = grid !== 0; showgrid[cid] = grid !== 0;
gridsize[cid] = grid_size_value; gridsize[cid] = grid_size_value;
gui(cid).get_elem("patchsvg", function(patchsvg, w) { gui(cid).get_elem("patchsvg", function(patchsvg, w) {
var editmode = patchsvg.classList.contains("editmode"); var editmode = patchsvg.classList.contains("editmode");
if (editmode) { if (editmode) {
set_editmode_bg(cid, patchsvg, true); set_editmode_bg(cid, patchsvg, true);
} }
}); });
} }
} }
......
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