diff --git a/app/assets/html/test1.html b/app/assets/html/test1.html index bdc1f2a..0af2a24 100644 --- a/app/assets/html/test1.html +++ b/app/assets/html/test1.html @@ -84,7 +84,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/assets/html/test2.html b/app/assets/html/test2.html index d1f61ef..9732f54 100644 --- a/app/assets/html/test2.html +++ b/app/assets/html/test2.html @@ -84,7 +84,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/assets/html/test3.html b/app/assets/html/test3.html index bb6f3c4..24f9c59 100644 --- a/app/assets/html/test3.html +++ b/app/assets/html/test3.html @@ -84,7 +84,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/assets/html/test4.5.html b/app/assets/html/test4.5.html index 5626c3c..adb9835 100644 --- a/app/assets/html/test4.5.html +++ b/app/assets/html/test4.5.html @@ -76,22 +76,22 @@ - + Auto-place Horizontal Auto-place Vertical Center - First + First Last - Auto + Parent - Ortho + Ortho Straight - Bezier + Bezier - tension + tension diff --git a/app/assets/html/test4.html b/app/assets/html/test4.html index f633b10..0c0cbd1 100644 --- a/app/assets/html/test4.html +++ b/app/assets/html/test4.html @@ -84,7 +84,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/assets/html/test5.html b/app/assets/html/test5.html index 01036ee..b42a13a 100644 --- a/app/assets/html/test5.html +++ b/app/assets/html/test5.html @@ -84,7 +84,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/assets/html/test6.html b/app/assets/html/test6.html index 015e846..d8b16d6 100644 --- a/app/assets/html/test6.html +++ b/app/assets/html/test6.html @@ -86,7 +86,7 @@ Center First Last - Auto + Parent Ortho diff --git a/app/thirdparty/buildoz/bzGraflow.js b/app/thirdparty/buildoz/bzGraflow.js index 73e6d61..551d653 100644 --- a/app/thirdparty/buildoz/bzGraflow.js +++ b/app/thirdparty/buildoz/bzGraflow.js @@ -728,35 +728,57 @@ class BZgraflow extends Buildoz{ // Finally place everything if(orientation=='horizontal'){ const fakeNodeHeight = 10 + const parentsY = {} let x = gapx for(const [idx, layer] of layers.entries()){ let wMax = this.getMaxWidth(layer) let y = 0 switch(align){ - case'center': + case 'center': y = ((maxHeight - layerHeights[idx]) / 2) + gapy break - case'first': + case 'first': y = gapy break - case'last': + case 'last': y = maxHeight - layerHeights[idx] + gapy break - case 'auto': - //TODO + case 'parent': // y will be absolutely positioned by the parent(s) but have fallback for 1st layer y = ((maxHeight - layerHeights[idx]) / 2) + gapy break } for(const nid of layer){ + let placedY if(!nid.startsWith('longLinkPlaceHolder_')) { const bb = this.stagedNodes[nid].getBoundingClientRect() - this.moveNode(nid, x, y, orientation, tween, null, token) - y += gapy + (this.stagedNodes[nid].offsetHeight || bb.height) + const nodeHeight = this.stagedNodes[nid].offsetHeight || bb.height + if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) { + y = Math.max(parentsY[parents[nid][0]], y) //TODO handle multiple parents with avg + console.log('parent', nid, parents[nid], parentsY[parents[nid][0]]) + } + placedY = y + this.moveNode(nid, x, y, orientation, tween, null, token) + if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) { + parentsY[parents[nid][0]] += gapy + nodeHeight + } else { + y += gapy + nodeHeight + } + y = Math.max(y, placedY + gapy + nodeHeight) } else { + if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) { + y = Math.max(parentsY[parents[nid][0]], y) + } + placedY = y this.addFakeNode(nid, x, y, wMax*0.75, fakeNodeHeight) this.moveNode(nid, x, y, orientation, tween, null, token) - y += gapy + fakeNodeHeight + if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) { + parentsY[parents[nid][0]] += gapy + fakeNodeHeight + } else { + y += gapy + fakeNodeHeight + } + y = Math.max(y, placedY + gapy + fakeNodeHeight) } + parentsY[nid] = placedY } x += wMax + gapx } @@ -765,7 +787,21 @@ class BZgraflow extends Buildoz{ let y = gapy for(const [idx, layer] of layers.entries()){ let hMax = this.getMaxHeight(layer) - let x = ((maxWidth - layerWidths[idx]) / 2) + gapx + let x = 0 + switch(align){ + case 'center': + x = ((maxWidth - layerWidths[idx]) / 2) + gapx + break + case 'first': + x = gapx + break + case 'last': + x = maxWidth - layerWidths[idx] + gapx + break + case 'parent': // x will be absolutely positioned by the parent(s) + //TODO + break + } for(const nid of layer){ if(!nid.startsWith('longLinkPlaceHolder_')){ const bb = this.stagedNodes[nid].getBoundingClientRect()