Changeset - aec09f94c030
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 7 years ago 2018-05-31 20:48:43
drewp@bigasterisk.com
fix notes drawing themselves after they should be gone
Ignore-this: 8ce4b8b194dbc13836d22535de92294d
1 file changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -357,22 +357,29 @@ coffeeElementSetup(class TimeZoomed exte
 
      noteNum = noteNum + 1
 

	
 
    toRemove.forEach @_delNote.bind(@)
 

	
 
    @renderer.render(@stage)
 

	
 
  isActiveNote: (note) ->
 
    return @noteByUriStr.has(note.value)
 

	
 
  _addNote: (uri, noteNum) ->
 
    U = (x) => @graph.Uri(x)
 

	
 
    
 
    con = new PIXI.Container()
 
    con.interactive=true
 
    @stage.addChild(con)
 
    
 
    row = noteNum % 6
 
    rowTop = @viewState.rowsY() + 20 + 150 * row
 
    note = new Note(@, con, @project, @graph, @selection, uri, @setAdjuster, U(@song), @viewState, rowTop, rowTop + 140)
 
    # this must come before the first Note.draw
 
    @noteByUriStr.set(uri.value, note)
 
    note.initWatchers()
 

	
 
  _delNote: (uriStr) ->
 
    n = @noteByUriStr.get(uriStr)
 
    @stage.removeChild(n.container)
 
    n.destroy()
 
    @noteByUriStr.delete(uriStr)
 
@@ -433,12 +440,14 @@ coffeeElementSetup(class TimeAxis extend
 

	
 
# Maintains a pixi object, some adjusters, and inlineattrs corresponding to a note
 
# in the graph.
 
class Note
 
  constructor: (@parentElem, @container, @project, @graph, @selection, @uri, @setAdjuster, @song, @viewState, @rowTopY, @rowBotY) ->
 
    @adjusterIds = new Set() # id string
 

	
 
  initWatchers: ->
 
    @graph.runHandler(@draw.bind(@), "note draw #{@uri.value}")
 
    ko.computed @draw.bind(@)
 

	
 
  destroy: ->
 
    log('destroy', @uri.value)
 
    @isDetached = true
 
@@ -457,12 +466,15 @@ class Note
 
    for curve in @graph.objects(subj, U(':curve'))
 
      if @graph.uriValue(curve, U(':attr')).equals(curveAttr)
 
        return @project.getCurvePoints(curve, originTime)
 
    throw new Error("curve #{@uri.value} has no attr #{curveAttr.value}")
 

	
 
  draw: ->
 
    if not @parentElem.isActiveNote(@uri)
 
      # stale redraw call
 
      return
 
    U = (x) => @graph.Uri(x)
 
    [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()]
0 comments (0 inline, 0 general)