changeset 1768:c946ead4baf6

restore fade adjusters Ignore-this: f356a5f2a1fe9fad2d0e578cf2898fd0
author drewp@bigasterisk.com
date Fri, 01 Jun 2018 02:34:32 +0000
parents 1df3b2c7f283
children 59be536746eb
files light9/web/timeline/adjustable.coffee light9/web/timeline/timeline.coffee
diffstat 2 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/timeline/adjustable.coffee	Fri Jun 01 02:09:38 2018 +0000
+++ b/light9/web/timeline/adjustable.coffee	Fri Jun 01 02:34:32 2018 +0000
@@ -140,7 +140,7 @@
                               @config.ctx)
 
 class window.AdjustableFade extends Adjustable
-  constructor: (@yForV, @i0, @i1, @note, offset, ctx) ->
+  constructor: (@yForV, @zoomInX, @i0, @i1, @note, offset, ctx) ->
     super()
     @config = {
       getSuggestedTargetOffset: -> offset
@@ -150,12 +150,11 @@
     @ctor2()
 
   getTarget: ->
-    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
-    $V([@note.zoomInX(mid.e(1)), @yForV(mid.e(2))])
+    mid = @note.midPoint(@i0, @i1)
+    $V([@zoomInX(mid.e(1)), @yForV(mid.e(2))])
 
   _getValue: ->
-    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
-    mid.e(1)
+    @note.midPoint(@i0, @i1).e(1)
 
   continueDrag: (pos) ->
     # pos is vec2 of pixels relative to the drag start
@@ -163,7 +162,7 @@
     graph = @note.graph
     U = (x) -> graph.Uri(x)
 
-    goalCenterSec = @note.zoomInX.invert(@initialTarget.e(1) + pos.e(1))
+    goalCenterSec = @zoomInX.invert(@initialTarget.e(1) + pos.e(1))
 
     diamSec = @note.worldPts[@i1].e(1) - @note.worldPts[@i0].e(1)
     newSec0 = goalCenterSec - diamSec / 2
--- a/light9/web/timeline/timeline.coffee	Fri Jun 01 02:09:38 2018 +0000
+++ b/light9/web/timeline/timeline.coffee	Fri Jun 01 02:34:32 2018 +0000
@@ -489,17 +489,22 @@
         return @project.getCurvePoints(curve, originTime)
     throw new Error("curve #{@uri.value} has no attr #{curveAttr.value}")
 
+  midPoint: (i0, i1) ->
+    p0 = @worldPts[i0]
+    p1 = @worldPts[i1]
+    p0.x(.5).add(p1.x(.5))
+    
   draw: ->
     if not @parentElem.isActiveNote(@uri)
       # stale redraw call
       return
     U = (x) => @graph.Uri(x)
-    [pointUris, worldPts] = @getCurvePoints(@uri, U(':strength'))
+    [pointUris, @worldPts] = @getCurvePoints(@uri, U(':strength'))
     effect = @graph.uriValue(@uri, U(':effectClass'))
 
     yForV = (v) => @rowBotY + (@rowTopY - @rowBotY) * v
     dependOn = [@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2(), @viewState.width()]
-    screenPts = (new PIXI.Point(@viewState.zoomInX(pt.e(1)), yForV(pt.e(2))) for pt in worldPts)
+    screenPts = (new PIXI.Point(@viewState.zoomInX(pt.e(1)), yForV(pt.e(2))) for pt in @worldPts)
 
     @container.removeChildren()
     @graphics = new PIXI.Graphics({nativeLines: false})
@@ -521,8 +526,8 @@
 
     @_addMouseBindings()
 
-    curveWidthCalc = () => @project.curveWidth(worldPts)
-    @_updateAdjusters(screenPts, worldPts, curveWidthCalc, yForV, @song)
+    curveWidthCalc = () => @project.curveWidth(@worldPts)
+    @_updateAdjusters(screenPts, @worldPts, curveWidthCalc, yForV, @viewState.zoomInX, @song)
     @_updateInlineAttrs(screenPts)
     @parentElem.noteDirty()
 
@@ -575,14 +580,14 @@
 
     @_updateDisplay()
 
-  _updateAdjusters: (screenPts, worldPts, curveWidthCalc, yForV, ctx) ->
+  _updateAdjusters: (screenPts, worldPts, curveWidthCalc, yForV, zoomInX, ctx) ->
     # todo: allow offset even on more narrow notes
     if screenPts[screenPts.length - 1].x - screenPts[0].x < 100 or screenPts[0].x > @parentElem.offsetWidth or screenPts[screenPts.length - 1].x < 0
       @clearAdjusters()
     else
       @_makeOffsetAdjuster(yForV, curveWidthCalc, ctx)
       @_makeCurvePointAdjusters(yForV, worldPts, ctx)
-      @_makeFadeAdjusters(yForV, ctx, worldPts)
+      @_makeFadeAdjusters(yForV, zoomInX, ctx, worldPts)
 
   _updateInlineAttrs: (screenPts) ->
     w = 280
@@ -656,16 +661,16 @@
       })
       adj
 
-  _makeFadeAdjusters: (yForV, ctx, worldPts) ->
+  _makeFadeAdjusters: (yForV, zoomInX, ctx, worldPts) ->
     U = (x) => @graph.Uri(x)
-    @_makeFadeAdjuster(yForV, ctx, @uri.value + '/fadeIn', 0, 1, $V([-50, -10]))
+    @_makeFadeAdjuster(yForV, zoomInX, ctx, @uri.value + '/fadeIn', 0, 1, $V([-50, -10]))
     n = worldPts.length
-    @_makeFadeAdjuster(yForV, ctx, @uri.value + '/fadeOut', n - 2, n - 1, $V([50, -10]))
+    @_makeFadeAdjuster(yForV, zoomInX, ctx, @uri.value + '/fadeOut', n - 2, n - 1, $V([50, -10]))
 
-  _makeFadeAdjuster: (yForV, ctx, adjId, i0, i1, offset) ->
-    return # not ready- AdjustableFade looks in Note object
+  _makeFadeAdjuster: (yForV, zoomInX, ctx, adjId, i0, i1, offset) ->
     @adjusterIds.add(adjId)
-    @setAdjuster adjId, => new AdjustableFade(yForV, i0, i1, @, offset, ctx)
+    @setAdjuster adjId, =>
+      new AdjustableFade(yForV, zoomInX, i0, i1, @, offset, ctx)
 
   _suggestedOffset: (pt) ->
     if pt.e(2) > .5