Skip to content

Commit 9f41fa7

Browse files
committed
Add continuous redraw on drag setting
Fixes #22
1 parent 4be1f40 commit 9f41fa7

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

InteractiveHtmlBom/ibom.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
html, body {
22
margin: 0px;
33
height: 100%;
4-
font-family: "Helvetica Neue", Helvetica, Verdana, sans-serif;
4+
font-family: Verdana, sans-serif;
55
}
66

77
button {
@@ -256,13 +256,18 @@ mark.highlight {
256256
background-color: #eee;
257257
}
258258

259-
.checkbox-label {
259+
.menu-label {
260260
display: inline-block;
261261
padding: 8px;
262262
border: 1px solid #ccc;
263+
border-top: 0;
263264
width: calc(100% - 18px);
264265
}
265266

267+
.menu-label-top {
268+
border-top: 1px solid #ccc;
269+
}
270+
266271
#dbg {
267272
display: none;
268273
}

InteractiveHtmlBom/ibom.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
<div class="hideonprint menu" style="float: right; margin: 10px; top: 8px;">
3636
<button class="menubtn"></button>
3737
<div class="menu-content">
38-
<label class="checkbox-label">
39-
<input id="silkscreenCheckbox" type="checkbox" name="silkscreen"
40-
value="silkscreen" checked onchange="silkscreenVisible(this.checked)">
38+
<label class="menu-label menu-label-top">
39+
<input id="silkscreenCheckbox" type="checkbox" checked onchange="silkscreenVisible(this.checked)">
4140
Show silkscreen
4241
</label>
42+
<label class="menu-label">
43+
<input id="dragCheckbox" type="checkbox" checked onchange="setRedrawOnDrag(this.checked)">
44+
Continuous redraw on drag
45+
</label>
4346
</div>
4447
</div>
4548
<div class="button-container hideonprint"

InteractiveHtmlBom/ibom.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ window.onload = function(e) {
310310
document.getElementById("silkscreenCheckbox").checked = false;
311311
silkscreenVisible(false);
312312
}
313+
if (readStorage("redrawOnDrag") === "false") {
314+
document.getElementById("dragCheckbox").checked = false;
315+
setRedrawOnDrag(false);
316+
}
313317
}
314318

315319
window.onresize = resizeAll;

InteractiveHtmlBom/render.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* PCB rendering code */
22

3+
var redrawOnDrag = true;
4+
35
function deg2rad(deg) {
46
return deg * Math.PI / 180;
57
}
@@ -52,7 +54,7 @@ function drawtext(ctx, scalefactor, text, color, flip) {
5254

5355
function drawedge(ctx, scalefactor, edge, color) {
5456
ctx.strokeStyle = color;
55-
ctx.lineWidth = Math.max(2, edge.width) / scalefactor;
57+
ctx.lineWidth = Math.max(1 / scalefactor, edge.width);
5658
ctx.lineCap = "round";
5759
if (edge.type == "segment") {
5860
ctx.beginPath();
@@ -349,8 +351,8 @@ function handleMouseUp(e, layerdict) {
349351
layerdict.transform.panx = 0;
350352
layerdict.transform.pany = 0;
351353
layerdict.transform.zoom = 1;
352-
redrawCanvas(layerdict);
353354
}
355+
redrawCanvas(layerdict);
354356
}
355357

356358
function handleMouseMove(e, layerdict) {
@@ -365,7 +367,9 @@ function handleMouseMove(e, layerdict) {
365367
layerdict.transform.pany += 2 * dy / layerdict.transform.zoom;
366368
layerdict.transform.mousestartx = e.offsetX;
367369
layerdict.transform.mousestarty = e.offsetY;
368-
redrawCanvas(layerdict);
370+
if (redrawOnDrag) {
371+
redrawCanvas(layerdict);
372+
}
369373
}
370374

371375
function handleMouseWheel(e, layerdict) {
@@ -408,6 +412,11 @@ function addMouseHandlers(div, layerdict) {
408412
}
409413
}
410414

415+
function setRedrawOnDrag(value) {
416+
redrawOnDrag = value;
417+
writeStorage("redrawOnDrag", value);
418+
}
419+
411420
function initRender() {
412421
allcanvas = {
413422
front: {

0 commit comments

Comments
 (0)