diff --git a/bootstrap.js b/bootstrap.js index 3afb9bb4f513a1d10d4eac95d1f187c00f2a08b3..dfebedb6e89b0f0217fcf48c40839952df54832d 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -57,11 +57,13 @@ window.onload = () => { view.refresh().then(() => { // if you make links work properly (directionfull) // you can just pin view outputs to the left, collected, - // and the rest should sort itself out + // and the rest should sort itself out view.defs[0].floaters[0].fixTo(700,200) view.defs[1].unwrap() view.defs[1].floaters[0].fixTo(400, 100) view.defs[1].floaters[1].fixTo(800, 300) + // xtra + view.patchset.mergePatch('nttport') }) }, 100) }).catch((err) => { diff --git a/hunks/view.js b/hunks/view.js index 8873f806a067606692a39d6160e26726bd2214c4..316e866ad434b9307c547777c50a451ba772261e 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -196,6 +196,16 @@ function View() { } } + // drawing tool + + this.drawViewPeriodic = () => { + for(let df of defs){ + if(df.type === 'view' && df.name !== 'tlview'){ + $(df.deg.native).children('.view').addClass('offwhite') + } + } + } + // to zoom, this.dom.addEventListener('wheel', (evt) => { if (!$(evt.target).is('.view') && !$(evt.target).is('#floater')) { @@ -318,6 +328,8 @@ function View() { linkDef.wrapon(viewDef) // and ... trouble ... viewDef.unwrap() + // a toplevel kick, + this.drawViewPeriodic() // now, linkDef.reciprocalView.refresh() }) @@ -326,11 +338,7 @@ function View() { }).catch((err) => { console.log('err during link expansion', err) }) - } - - /* the force loop */ - - this.floop = new Floop(this) + } // end expand recipe } // end makeTopLevel @@ -449,6 +457,8 @@ function View() { /* ----------------------- REDRAWING ------------------------- */ /* --------------------------- ---------------------------- */ + this.floop = new Floop(this) + this.drawLinks = () => { // drawing from scratch every time ! could be faster, probably bzt.clear(this.plane) diff --git a/style.css b/style.css index ac8ea5347f2bae68a467c7f6c3364c239e3086fe..bec17c6ac4f957ac0f289890148973eedb82e8ac 100644 --- a/style.css +++ b/style.css @@ -48,10 +48,18 @@ body { background: #d6d6d6; /*background-image:url("background.png");*/ /*background-origin: content-box;*/ - background-image: - linear-gradient(rgba(255, 255, 255, .2) 2px, transparent 2px), - linear-gradient(90deg, rgba(255, 255, 255, .2) 2px, transparent 2px); - background-size: 100px 100px; + background-image: + linear-gradient(rgba(255, 255, 255, .2) 2px, transparent 2px), + linear-gradient(90deg, rgba(255, 255, 255, .2) 2px, transparent 2px); + background-size: 100px 100px; +} + +.view .offwhite{ + background: #c1c1c1; + background-image: + linear-gradient(rgba(255, 255, 255, .2) 2px, transparent 2px), + linear-gradient(90deg, rgba(255, 255, 255, .2) 2px, transparent 2px); + background-size: 100px 100px; } .msgbox { diff --git a/view/vdef.js b/view/vdef.js index 546f0d912a316b7246c7a71c2a5c4a157a08c4c4..ff85b2dc40e6b85a39a063138684f79574b99022 100644 --- a/view/vdef.js +++ b/view/vdef.js @@ -257,59 +257,16 @@ function HunkDefinition(spec, view, dt, debug) { // the link's 1st floater, let flt = this.floaters[0] flt.grouptype = 'wrapped' + // flt.take au manuel flt.bag.push(vbagitem) flt.typeset.push('native') + vbagitem.de.onResizeCustomCallback = flt.onElementResize // can just do recalc now? flt.onChange() // and also, vflt.onChange() } -/* - // re-wrap the element, - this.deg.native = $('<div>').addClass('nativewrap').get(0) - // wrapper includes this title bar, - $(this.deg.native).append($(`<div>${this.name}'s html element</div>`).addClass('nativeheader').addClass('header')) - // and the hunk's element goes in that wrapper. - // awkward phrasing here, viewDef.hunk.dom === de as it stands - $(this.deg.native).append(viewDef.hunk.dom) - // but we'll pin it to another floater, - // ... continue - let flt = this.floaters[0] - // set as, - flt.grouptype = 'wrapped' - flt.take(this.deg.native, this) - // and theeeen - viewDef.cleanNative() - } - - this.cleanNative = () => { - if (this.type !== 'view' || this.name === 'tlview') throw new Error('will not release non-view native') - let ntflt = this.floaters.find((cnd) => { - return cnd.typeset.includes('native') - }) - if (ntflt) { - // console.log('floater containing native', ntflt) - // splice the element out - let fltelem = ntflt.bag.findIndex((cnd) => { - return cnd.type === 'native' - }) - if (fltelem !== -1) { - // there's still a container to wash up - $(ntflt.bag[fltelem].de).remove() - // splice it out, - ntflt.bag.splice(fltelem, 1) - // this wants an update, - ntflt.onChange() - } else { - console.error('no native element found in floater ???') - } - } else { - console.error('no native floater found when trying to release') - } - } -*/ - this.edgecase = () => { // put inputs / outputs at edges of view body // put core below inputs, at left diff --git a/view/vdom.js b/view/vdom.js index 075b52a71fc06c932a702acef648136640f31a3f..17161dadf351cc0c8de402c226e28161d1c5c273 100644 --- a/view/vdom.js +++ b/view/vdom.js @@ -115,7 +115,7 @@ function DomTools(View) { this.writeTransform(handle, {x: w, y: h}) // make elem.requestResize = (x, y) => { - console.log('request resize', x, y, 'on', elem) + //console.log('request resize', x, y, 'on', elem) $(elem).css('width',`${x}px`).css('height', `${y}px`) this.writeTransform(handle, {x: x, y: y}) elem.onResizeCustomCallback() diff --git a/view/vfloater.js b/view/vfloater.js index 0d3aa353436387d0d62e10ca0f2125149358e6ed..f43a7ff9156a5e3575140d0112a0f894c7c05142 100644 --- a/view/vfloater.js +++ b/view/vfloater.js @@ -124,7 +124,7 @@ function Floater(view, grouptype) { item.type = 'native' // at the gitgo, set this to our current width... // this width thing is happening because you're rewriting the - // so ... not a take, a swap ? !!! FFUUUUU + // so ... not a take, a swap ? !!! FFUUUUU // native element's wrapper ... this.calculateSizes() if (this.w < 200) { @@ -336,8 +336,8 @@ function Floater(view, grouptype) { this.moveTo = (x, y, backdoor) => { // but still probably want to check our offsets, if (this.isFixed && !backdoor) { - x = this.x - y = this.y + this.x = this.fx + this.y = this.fy } // to just draw new position, run with no args if (x === undefined) { @@ -347,10 +347,20 @@ function Floater(view, grouptype) { this.x = x this.y = y } + // check bounds, + if(!view.isTopLevel){ + // bummer to do so many times ! + this.calculateSizes() + let bounds = view.getCurrentBounds() + this.x = Math.min(bounds.x2 - this.w/2, this.x) // set lower bound, + this.x = Math.max(bounds.x1 + this.w/2, this.x) // upper bound + this.y = Math.min(bounds.y2 - this.h/2, this.y) // set lower bound, + this.y = Math.max(bounds.y1 + this.h/2, this.y) // upper bound + } // do work writePosition(this.ownElement, x - 16.5, y - 20) for (let item of this.bag) { - writePosition(item.de, x + item.offsetX, y + item.offsetY) + writePosition(item.de, this.x + item.offsetX, this.y + item.offsetY) } // here ? view.drawLinks() diff --git a/view/vfloop.js b/view/vfloop.js index 2f01369ca163e1a4b23d1853d8704206282c9967..e033545c76e03f411b5fb2d279c6a835dbe05cee 100644 --- a/view/vfloop.js +++ b/view/vfloop.js @@ -9,8 +9,9 @@ function Floop(View) { let links = [] let onTick = () => { + // bounds // let's also draw some svgs into the plane, to debug ... - for(let nd of nodes){ + for (let nd of nodes) { nd.moveTo() } view.drawLinks() @@ -24,7 +25,7 @@ function Floop(View) { // a bit confusion, floop.reset !== floop.sim.restart() this.reset = () => { console.log('FLOOP RESET') - if(this.sim) this.sim.stop() + if (this.sim) this.sim.stop() // a new sim, nodes.length = 0 links.length = 0 @@ -32,7 +33,7 @@ function Floop(View) { // NODEHUNTR 1K1 for (let df in view.defs) { let def = view.defs[df] - for(let fl in view.defs[df].floaters){ + for (let fl in view.defs[df].floaters) { // ok, have def indice df, and floater indice fl let floater = def.floaters[fl] // we are going to flatten this, basically, so we want to track, @@ -54,11 +55,11 @@ function Floop(View) { let otps = node.bag.find((cand) => { return cand.type === 'outputs' }) - if(otps){ + if (otps) { //console.log('got `em') // small reacharound & walkabout, - for(let op of otps.def.outputs){ - for(let cn of op.connections){ + for (let op of otps.def.outputs) { + for (let cn of op.connections) { // cn is an input, we need to find a reciprocal, // there won't *really* be that many floaters, max 4 or so, // so this is almost acceptable @@ -66,16 +67,15 @@ function Floop(View) { // 'l1' and 'l2' tags are labels for these loops, so that I can break both // by saying 'break l1' l1: - for(let flt of cn.parent.floaters){ - l2: - for(let item of flt.bag){ - if(item.type === 'inputs'){ - recip = flt - break l1 + for (let flt of cn.parent.floaters) { + l2: for (let item of flt.bag) { + if (item.type === 'inputs') { + recip = flt + break l1 + } } } - } - if(recip){ + if (recip) { links.push({ source: parseInt(nd), // the node that the link is from ... target: recip.simIndex