Changeset - 9f7e31bf3f0c
[Not reviewed]
default
0 3 0
Drew Perttula - 8 years ago 2017-06-10 08:38:39
drewp@bigasterisk.com
new fade adjusters
Ignore-this: aa37b28e07ac053ae58f083e160b009c
3 files changed with 62 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/edit-choice.html
Show inline comments
 
@@ -12,9 +12,10 @@
 
         background: rgba(126, 52, 245, 0.0784313725490196);
 
     }
 
     a {
 
         color: #5555e0;
 
         color: #8e8eff;
 
         padding: 3px;
 
         display: inline-block;
 
         font-size: 145%;
 
     }
 
    
 
     
light9/web/timeline/adjustable.coffee
Show inline comments
 
@@ -123,7 +123,6 @@ class window.AdjustableFloatObject exten
 
    throw new Error('multi subscribe not implemented') if @_onChange
 
    @_onChange = onChange
 

	
 
    
 
  continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start
 
    super(pos)
 
@@ -132,3 +131,50 @@ class window.AdjustableFloatObject exten
 
    @config.graph.patchObject(@config.subj, @config.pred,
 
                              @config.graph.LiteralRoundedFloat(newValue),
 
                              @config.ctx)
 
                              
 
class window.AdjustableFade extends Adjustable
 
  constructor: (@yForV, @i0, @i1, @note, offset) ->
 
    @config = {
 
      getSuggestedTargetOffset: -> offset
 
      getTarget: @getTarget.bind(@)
 
    }
 
    super(@config)
 

	
 
  getTarget: ->
 
    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
 
    $V([@note.zoomInX(mid.e(1)), @yForV(mid.e(2))])
 

	
 
  _getValue: ->
 
    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
 
    mid.e(1)
 

	
 
   continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start
 
    super(pos)
 
    graph = @note.graph
 
    U = (x) => graph.Uri(x)
 

	
 
    goalCenterSec = @note.zoomInX.invert(@initialTarget.e(1) + pos.e(1))
 

	
 
    diamSec = @note.worldPts[@i1].e(1) - @note.worldPts[@i0].e(1)
 
    newSec0 = goalCenterSec - diamSec / 2
 
    newSec1 = goalCenterSec + diamSec / 2
 

	
 
    originSec = graph.floatValue(@note.uri, U(':originTime'))
 

	
 
    ctx = @note.song
 
    p0 = @_makePatch(graph, @i0, newSec0, originSec, ctx)
 
    p1 = @_makePatch(graph, @i1, newSec1, originSec, ctx)
 

	
 
    graph.applyAndSendPatch(@_addPatches(p0, p1))
 

	
 
  _makePatch: (graph, idx, newSec, originSec, ctx) ->
 
    graph.getObjectPatch(@note.worldPts[idx].uri,
 
                         graph.Uri(':time'),
 
                         graph.LiteralRoundedFloat(newSec - originSec), ctx)
 

	
 
  _addPatches: (p0, p1) ->
 
    {
 
      addQuads: p0.addQuads.concat(p1.addQuads),
 
      delQuads: p0.delQuads.concat(p1.delQuads)
 
    }
 
\ No newline at end of file
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -275,6 +275,9 @@ Polymer
 
      }))
 
      
 

	
 
# plan: in here, turn all the notes into simple js objects with all
 
# their timing data and whatever's needed for adjusters. From that, do
 
# the brick layout. update only changing adjusters.
 
Polymer
 
  is: 'light9-timeline-time-zoomed'
 
  behaviors: [ Polymer.IronResizableBehavior ]
 
@@ -511,6 +514,7 @@ Polymer
 
    else
 
      @_makeOffsetAdjuster(yForV, curveWidthCalc)
 
      @_makeCurvePointAdjusters(yForV, @worldPts)
 
      @_makeFadeAdjusters(yForV)
 

	
 
  _updateInlineAttrs: (screenPts) ->
 
    leftX = Math.max(2, screenPts[Math.min(1, screenPts.length - 1)].e(1) + 5)
 
@@ -597,6 +601,15 @@ Polymer
 
      })
 
      adj
 
    
 
  _makeFadeAdjusters: (yForV) ->
 
    @_makeFadeAdjuster(yForV, @uri + '/fadeIn', 0, 1, $V([-50, -10]))
 
    n = @worldPts.length
 
    @_makeFadeAdjuster(yForV, @uri + '/fadeOut', n - 2, n - 1, $V([50, -10]))
 

	
 
  _makeFadeAdjuster: (yForV, adjId, i0, i1, offset) ->
 
    @adjusterIds[adjId] = true
 
    @setAdjuster adjId, => new AdjustableFade(yForV, i0, i1, @, offset)
 
    
 
  _suggestedOffset: (pt) ->
 
    if pt.e(2) > .5
 
      $V([0, 30])
 
@@ -969,7 +982,6 @@ Polymer
 
    @_updateNotePathClasses(uri, elem)
 

	
 
  _addNoteListeners: (elem, uri) ->
 
    log("new note listeneers", uri)
 
    elem.addEventListener 'mouseenter', =>
 
      @selection.hover(uri)
 
    elem.addEventListener 'mousedown', (ev) =>
0 comments (0 inline, 0 general)