Mercurial > code > home > repos > light9
changeset 1649:b48b0d9812cf
pass ctx to more handlers to show that they need it
Ignore-this: 6cede95405430f375b1e068e44a604d
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sat, 10 Jun 2017 10:24:53 +0000 |
parents | ffa3b81c6d95 |
children | fb9e84646320 |
files | light9/web/timeline/adjustable.coffee light9/web/timeline/timeline.coffee |
diffstat | 2 files changed, 21 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/timeline/adjustable.coffee Sat Jun 10 10:23:48 2017 +0000 +++ b/light9/web/timeline/adjustable.coffee Sat Jun 10 10:24:53 2017 +0000 @@ -133,10 +133,11 @@ @config.ctx) class window.AdjustableFade extends Adjustable - constructor: (@yForV, @i0, @i1, @note, offset) -> + constructor: (@yForV, @i0, @i1, @note, offset, ctx) -> @config = { getSuggestedTargetOffset: -> offset getTarget: @getTarget.bind(@) + ctx: ctx } super(@config) @@ -162,9 +163,8 @@ originSec = graph.floatValue(@note.uri, U(':originTime')) - ctx = @note.song - p0 = @_makePatch(graph, @i0, newSec0, originSec, ctx) - p1 = @_makePatch(graph, @i1, newSec1, originSec, ctx) + p0 = @_makePatch(graph, @i0, newSec0, originSec, @config.ctx) + p1 = @_makePatch(graph, @i1, newSec1, originSec, @config.ctx) graph.applyAndSendPatch(@_addPatches(p0, p1))
--- a/light9/web/timeline/timeline.coffee Sat Jun 10 10:23:48 2017 +0000 +++ b/light9/web/timeline/timeline.coffee Sat Jun 10 10:24:53 2017 +0000 @@ -443,9 +443,10 @@ zoomInX: { type: Object, notify: true } setAdjuster: {type: Function, notify: true } inlineRect: { type: Object, notify: true } + song: { type: String, notify: true } observers: [ - 'onUri(graph, dia, uri, zoomInX, setAdjuster)' - 'update(graph, dia, uri, zoomInX, setAdjuster)' + 'onUri(graph, dia, uri, zoomInX, setAdjuster, song)' + 'update(graph, dia, uri, zoomInX, setAdjuster, song)' ] ready: -> @adjusterIds = {} # id : true @@ -505,16 +506,16 @@ screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight]) for pt in @worldPts) @dia.setNote(@uri, screenPts, effect) - @_updateAdjusters(screenPts, curveWidthCalc, yForV) + @_updateAdjusters(screenPts, curveWidthCalc, yForV, U(@song)) @_updateInlineAttrs(screenPts) - _updateAdjusters: (screenPts, curveWidthCalc, yForV) -> + _updateAdjusters: (screenPts, curveWidthCalc, yForV, ctx) -> if screenPts[screenPts.length - 1].e(1) - screenPts[0].e(1) < 100 @clearAdjusters() else - @_makeOffsetAdjuster(yForV, curveWidthCalc) - @_makeCurvePointAdjusters(yForV, @worldPts) - @_makeFadeAdjusters(yForV) + @_makeOffsetAdjuster(yForV, curveWidthCalc, ctx) + @_makeCurvePointAdjusters(yForV, @worldPts, ctx) + @_makeFadeAdjusters(yForV, ctx) _updateInlineAttrs: (screenPts) -> leftX = Math.max(2, screenPts[Math.min(1, screenPts.length - 1)].e(1) + 5) @@ -555,7 +556,7 @@ for pointNum in [0...worldPts.length] @_makePointAdjuster(yForV, worldPts, pointNum) - _makePointAdjuster: (yForV, worldPts, pointNum) -> + _makePointAdjuster: (yForV, worldPts, pointNum, ctx) -> U = (x) => @graph.Uri(x) adjId = @uri + '/p' + pointNum @@ -565,7 +566,7 @@ graph: @graph subj: worldPts[pointNum].uri pred: U(':time') - ctx: U(@song) + ctx: ctx getTargetPosForValue: (value) => $V([@zoomInX(value), yForV(worldPts[pointNum].e(2))]) getValueForPos: (pos) => @@ -580,7 +581,7 @@ ) adj - _makeOffsetAdjuster: (yForV, curveWidthCalc) -> + _makeOffsetAdjuster: (yForV, curveWidthCalc, ctx) -> U = (x) => @graph.Uri(x) adjId = @uri + '/offset' @@ -590,7 +591,7 @@ graph: @graph subj: @uri pred: U(':originTime') - ctx: U(@song) + ctx: ctx getDisplayValue: (v, dv) => "o=#{dv}" getTargetPosForValue: (value) => # display bug: should be working from pt[0].t, not from origin @@ -601,14 +602,14 @@ }) adj - _makeFadeAdjusters: (yForV) -> - @_makeFadeAdjuster(yForV, @uri + '/fadeIn', 0, 1, $V([-50, -10])) + _makeFadeAdjusters: (yForV, ctx) -> + @_makeFadeAdjuster(yForV, ctx, @uri + '/fadeIn', 0, 1, $V([-50, -10])) n = @worldPts.length - @_makeFadeAdjuster(yForV, @uri + '/fadeOut', n - 2, n - 1, $V([50, -10])) + @_makeFadeAdjuster(yForV, ctx, @uri + '/fadeOut', n - 2, n - 1, $V([50, -10])) - _makeFadeAdjuster: (yForV, adjId, i0, i1, offset) -> + _makeFadeAdjuster: (yForV, ctx, adjId, i0, i1, offset) -> @adjusterIds[adjId] = true - @setAdjuster adjId, => new AdjustableFade(yForV, i0, i1, @, offset) + @setAdjuster adjId, => new AdjustableFade(yForV, i0, i1, @, offset, ctx) _suggestedOffset: (pt) -> if pt.e(2) > .5