Skip to content

Commit 7a648b7

Browse files
committed
Fixes about tree placement on canvas + styling
1 parent 317cb11 commit 7a648b7

2 files changed

Lines changed: 25 additions & 42 deletions

File tree

index.html

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
1616
}
1717

18+
a { color: #0d6efd; }
19+
a:visited { color: #0d6efd; }
20+
a:hover { color: #0a58ca; }
21+
1822
#top-bar {
1923
position: fixed;
2024
width: 100%;
@@ -26,9 +30,6 @@
2630
}
2731

2832
button {
29-
/*
30-
background: #0d6efd;
31-
*/
3233
background: #FFA500;
3334
color: #212529;
3435
border: 1px solid #212529;
@@ -38,16 +39,6 @@
3839
background: #6610f2;
3940
color: white;
4041
}
41-
/*
42-
button.ok {
43-
background: #00CC84;
44-
color: black;
45-
}
46-
button.cancel {
47-
background: #dc3545;
48-
color: white;
49-
}
50-
*/
5142
button#help {
5243
background: #c29cff;
5344
color: black;
@@ -341,16 +332,15 @@
341332
}
342333
th, td { padding: 0.5em 1em 0.5em 1em; }
343334

335+
/* thanks to https://stackoverflow.com/a/8160532/2016295 */
344336
.latex sub, .latex sup {
345337
text-transform: uppercase;
346338
}
347-
348339
.latex sub {
349340
vertical-align: -0.5ex;
350341
margin-left: -0.1667em;
351342
margin-right: -0.125em;
352343
}
353-
354344
.latex sup {
355345
font-size: 0.80em;
356346
vertical-align: 0.15em;

src/app.js

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ canvas.setHeight(window.innerHeight)
88
let incompleteColor = '#FFA500'
99
let successColor = '#4cd625'
1010
let failureColor = '#dc3545'
11+
let foldColor = 'lightgray'
1112
let goodColor = 'black'
1213

1314
const isLearnMode = () => document.getElementById('mode').checked
@@ -24,14 +25,6 @@ const unsetLoading = () => {
2425
document.getElementById("loading").style = "display: none"
2526
document.getElementById("loadingMsg").style = "display: none"
2627
}
27-
const promptTrim = (s) => {
28-
let x = prompt(s)
29-
if (x === null) {
30-
return null
31-
} else {
32-
return x.trim()
33-
}
34-
}
3528

3629
// Panning with ALT + drag
3730
canvas.on('mouse:down', function (opt) {
@@ -185,13 +178,13 @@ const refreshList = () => {
185178
let status = entry.proof.status()
186179
let result = ``
187180
if (status instanceof Unprovable) {
188-
result = `<span class="resultBad">✖</span>`
181+
result = `<span class="resultBad" title="A part of this proof has failed">✖</span>`
189182
} else if (status instanceof Incomplete) {
190-
result = `<span class="resultIncomplete">✎</span>`
183+
result = `<span class="resultIncomplete" title="Incomplete proof">✎</span>`
191184
} else if (status instanceof CompleteWithZ3) {
192-
result = `<span class="resultOk">✓*</span>`
185+
result = `<span class="resultOk" title="Complete proof, using Z3">✓*</span>`
193186
} else if (status instanceof Complete) {
194-
result = `<span class="resultOk">✓</span>`
187+
result = `<span class="resultOk" title="Complete proof">✓</span>`
195188
}
196189

197190
ol.innerHTML += `<li value="${i}" class="${entry.selected ? 'selected' : ''}">
@@ -207,8 +200,8 @@ const refreshList = () => {
207200
})
208201
}
209202

210-
const addProof = (pf) => {
211-
proofs.push({ proof: pf, x1: null, x2: null, y: null, incompletes: [] })
203+
const addProof = (pf, x1 = null, x2 = null, y = null) => {
204+
proofs.push({ proof: pf, x1: x1, x2: x2, y: y, incompletes: [] })
212205
pf.draw()
213206
refreshList()
214207
}
@@ -339,6 +332,9 @@ const help = () => {
339332
</p>
340333
<p>
341334
You can click on the <span style="color: ${incompleteColor}">orange</span> scissors button (✄) to <strong>detach</strong> a proof, i.e. to create a separate proof tree with the current branch and changing the original one into an incomplete one. You can also <strong>attach</strong> a separate proof on another one by <strong>dragging</strong> the subtree and <strong>dropping</strong> on the main one.
335+
</p>
336+
<p>
337+
For rules with premises, you can click on the <span style="background: ${foldColor}">gray</span> hide button (⃠) to hide the premises of a proof rule, which shows each premise as an ellipses. Clicking the same button again will reveal the premises. You can use this feature to clean up your workspace while working on large proofs.
342338
</p>
343339
<p>
344340
As you work on the proof, you can click on the buttons on the left bar to either copy the <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span> output for a given proof, or to save that proof onto your computer as a file. You can later reload the proof file into the proof assistant by clicking the "Load proof file" button on the top bar.
@@ -694,6 +690,7 @@ ProofTree.prototype.image = function (root) {
694690
deleteLabel.on('mousedown', async (e) => {
695691
const msg = `Are you sure you want to <strong>unapply</strong> the ${this.unicodeName} rule
696692
for the conclusion <br>${this.conclusion.unicode()}<br> and the rules applied after/above?`
693+
console.log(this);
697694
if(await modalConfirm(msg)) {
698695
this.toDelete = true
699696
refreshAll()
@@ -704,6 +701,7 @@ ProofTree.prototype.image = function (root) {
704701
const msg = `Are you sure you want to <strong>detach</strong> the proof at the ${this.unicodeName} rule
705702
for the conclusion <br>${this.conclusion.unicode()} ?<br>
706703
This will unapply the ${this.unicodeName} rule in the current proof tree, and also will create an extra proof tree with the ${this.unicodeName} rule at the bottom, followed by the rest of this branch of the proof tree.`
704+
console.log(this);
707705
if(await modalConfirm(msg)) {
708706
let deepCopy = eval(this.reconstructor())
709707
addProof(deepCopy)
@@ -717,9 +715,9 @@ ProofTree.prototype.image = function (root) {
717715
foldLabel = new fabric.Text(n, {
718716
fontFamily: 'Helvetica',
719717
fontSize: 11,
720-
stroke: this.folded ? 'lightgray' : 'black',
718+
stroke: this.folded ? foldColor : 'black',
721719
hoverCursor: 'pointer',
722-
backgroundColor: this.folded ? 'black' : 'lightgray'
720+
backgroundColor: this.folded ? 'black' : foldColor
723721
})
724722
foldLabel.on('mousedown', async (e) => {
725723
this.folded = !this.folded
@@ -755,17 +753,6 @@ ProofTree.prototype.image = function (root) {
755753
group.hasControls = false
756754
group.set({ borderColor: 'black' })
757755
group.root = root
758-
if (this == root) {
759-
group.on('moved', e => {
760-
proofs.forEach((entry, i) => {
761-
if (root == entry.proof) {
762-
proofs[i].x1 = e.target.aCoords.bl.x
763-
proofs[i].x2 = e.target.aCoords.br.x
764-
proofs[i].y = e.target.aCoords.bl.y
765-
}
766-
})
767-
})
768-
}
769756

770757
if(isIncomplete) {
771758
proofs.forEach((entry, i) => {
@@ -777,6 +764,12 @@ ProofTree.prototype.image = function (root) {
777764
return group
778765
}
779766

767+
canvas.on('object:modified', e => {
768+
let i = proofs.findIndex(entry => e.target.root == entry.proof)
769+
proofs[i].x1 = e.target.aCoords.bl.x
770+
proofs[i].x2 = e.target.aCoords.br.x
771+
proofs[i].y = e.target.aCoords.bl.y
772+
})
780773

781774
ProofTree.prototype.draw = function () {
782775
proofs.forEach((entry, i) => { if (this == entry.proof) proofs[i].incompletes = [] })

0 commit comments

Comments
 (0)