Mercurial > code > home > repos > light9
changeset 1502:045044899860
optimize point drags by making most points do an abbreviated update. this workaround goes away once SyncedGraph does specific updating
Ignore-this: 54c8ade3731be72e5713dd4ee4ef7257
author | drewp@bigasterisk.com |
---|---|
date | Thu, 16 Jun 2016 06:14:23 +0000 |
parents | c45787e306ae |
children | b91e8f26650e |
files | light9/web/timeline/timeline.coffee |
diffstat | 1 files changed, 20 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/timeline/timeline.coffee Thu Jun 16 06:13:24 2016 +0000 +++ b/light9/web/timeline/timeline.coffee Thu Jun 16 06:14:23 2016 +0000 @@ -364,13 +364,14 @@ getCurvePoints = (graph, curve, xOffset) -> worldPts = [] - for pt in graph.objects(curve, graph.Uri(':point')) + uris = graph.objects(curve, graph.Uri(':point')) + for pt in uris v = $V([xOffset + graph.floatValue(pt, graph.Uri(':time')), graph.floatValue(pt, graph.Uri(':value'))]) v.uri = pt worldPts.push(v) worldPts.sort((a,b) -> a.e(1) > b.e(1)) - return worldPts + return [uris, worldPts] Polymer is: 'light9-timeline-note' @@ -408,19 +409,22 @@ if patch.addQuads.length == patch.delQuads.length == 1 add = patch.addQuads[0] del = patch.delQuads[0] - if add.predicate == del.predicate == @graph.Uri(':time') - if add.subject != @uri and del.subject != @uri - log("i'm #{@uri}, cant be affected by #{ko.toJSON(patch)}") + if (add.predicate == del.predicate == @graph.Uri(':time') and + add.subject == del.subject) + timeEditFor = add.subject + if @worldPts and timeEditFor not in @pointUris return false return true update: (patch) -> - # not working yet - #if @patchCouldAffectMe(patch) - # return + if not @patchCouldAffectMe(patch) + # as autodep still fires all handlers on all patches, we just + # need any single dep to cause another callback. (without this, + # we would no longer be registered at all) + @graph.subjects(@uri, @uri, @uri) + return if @isDetached? - log('skipping update', @uri) return # update our note DOM and SVG elements based on the graph U = (x) -> @graph.Uri(x) @@ -435,15 +439,15 @@ updateStrengthCurveEtc: (originTime, curve, yForV, effect) -> U = (x) -> @graph.Uri(x) - worldPts = getCurvePoints(@graph, curve, originTime) # (song time, value) + [@pointUris, @worldPts] = getCurvePoints(@graph, curve, originTime) # (song time, value) curveWidth = => - tMin = @graph.floatValue(worldPts[0].uri, U(':time')) - tMax = @graph.floatValue(worldPts[3].uri, U(':time')) + tMin = @graph.floatValue(@worldPts[0].uri, U(':time')) + tMax = @graph.floatValue(@worldPts[3].uri, U(':time')) tMax - tMin - screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight]) for pt in worldPts) - @dia.setNote(@uri, screenPts, label) + screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight]) for pt in @worldPts) + @dia.setNote(@uri, screenPts, effect) leftX = Math.max(2, screenPts[1].e(1) + 5) rightX = screenPts[2].e(1) - 5 @@ -462,7 +466,7 @@ # also kill their connectors return - @makeCurveAdjusters(curveWidth, yForV, worldPts) + @makeCurveAdjusters(curveWidth, yForV, @worldPts) makeCurveAdjusters: (curveWidth, yForV, worldPts) -> U = (x) -> @graph.Uri(x) @@ -528,7 +532,6 @@ ] onColorScale: -> U = (x) -> @graph.Uri(x) - log('onColorScale', @colorScale, @colorScaleFromGraph, @existingColorScaleSetting) if @colorScale == @colorScaleFromGraph return @@ -747,6 +750,7 @@ anyPointsInView: (pts) -> for pt in pts + # wrong: if pt.e(1) > -100 && pt.e(1) < 2500 return true return false