Changeset - fbe417cb765c
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 7 years ago 2018-05-10 07:12:39
drewp@bigasterisk.com
fix or workaround js errors on timeline. view zooming broken. adjusters not drawing
Ignore-this: f3d990bc9e312efb3625ac439d89c561
2 files changed with 48 insertions and 33 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjusters.coffee
Show inline comments
 
@@ -52,7 +52,8 @@ class AdjustersCanvas extends Polymer.El
 
        @adjs[adjId] = adj
 
        adj.id = adjId
 

	
 
    @debounce('adj redraw', @redraw.bind(@))
 
    #@debounce('adj redraw', @redraw.bind(@))
 
    setTimeout((() => @redraw()), 2)
 

	
 
    window.debug_adjsCount = Object.keys(@adjs).length
 

	
 
@@ -71,9 +72,11 @@ class AdjustersCanvas extends Polymer.El
 
    @redraw()
 

	
 
  redraw: (adjs) ->
 
    @debounce('redraw', @_throttledRedraw.bind(@))
 
    @_throttledRedraw(adjs)
 
    #@debounce('redraw', @_throttledRedraw.bind(@))
 

	
 
  _throttledRedraw: () ->
 
    return unless @ctx?
 
    console.time('adjs redraw')
 
    @_layoutCenters()
 
    
 
@@ -155,3 +158,5 @@ class AdjustersCanvas extends Polymer.El
 
    # l/r arrows
 
    # mouse arrow cursor upon hover, and accent the hovered adjuster
 
    # connector
 

	
 
customElements.define(AdjustersCanvas.is, AdjustersCanvas)
 
\ No newline at end of file
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -118,20 +118,13 @@ class TimelineEditor extends Polymer.Ele
 
    'setSong(playerSong, followPlayerSong)',
 
    'onGraph(graph)',
 
    ]
 
  _onIronResize: ->
 
    @width(@offsetWidth)
 
  _onSongTime: (t) ->
 
    #@viewState.cursor.t(t)
 
  _onSongDuration: (d) ->
 
    d = 700 if d < 1 # bug is that asco isn't giving duration, but 0 makes the scale corrupt
 
    #@viewState.zoomSpec.duration(d)
 
  setSong: (s) ->
 
    @song = @playerSong if @followPlayerSong
 
  onGraph: (graph) ->
 
    @project = new Project(graph)
 
    
 
  connectedCallback: ->
 
    super.connectedCallback()
 
    ko.options.deferUpdates = true;
 

	
 
    @dia = @$.dia
 

	
 
    @selection = {hover: ko.observable(null), selected: ko.observable([])}
 

	
 
    window.debug_zoomOrLayoutChangedCount = 0
 
@@ -146,17 +139,50 @@ class TimelineEditor extends Polymer.Ele
 
        t: ko.observable(20)
 
      mouse:
 
        pos: ko.observable($V([0,0]))
 
    window.viewState = @viewState
 
    @fullZoomX = d3.scaleLinear()
 
    @zoomInX = d3.scaleLinear()
 
    @setAdjuster = (adjId, makeAdjustable) =>
 
      @$.adjustersCanvas.setAdjuster(adjId, makeAdjustable)
 
      ac = @$.adjustersCanvas
 
      setTimeout((()=>ac.setAdjuster(adjId, makeAdjustable)),10)
 

	
 
    setTimeout =>
 
      ko.computed(@zoomOrLayoutChanged.bind(@))
 
      ko.computed(@songTimeChanged.bind(@))
 

	
 
      @trackMouse()
 
      @bindKeys()
 
      @bindWheelZoom(@dia)
 
      setTimeout => # depends on child node being ready
 
          @forwardMouseEventsToAdjustersCanvas()
 
        , 400
 

	
 
      @makeZoomAdjs()
 

	
 
      zoomed = @$.zoomed
 
      setupDrop(@$.dia.shadowRoot.querySelector('svg'),
 
                zoomed.$.rows, @, zoomed.onDrop.bind(zoomed))
 

	
 
    setInterval(@updateDebugSummary.bind(@), 100)
 
    , 500
 

	
 
    #if anchor == loadtest
 
    #  add note and delete it repeatedly
 
    #  disconnect the graph, make many notes, drag a point over many steps, measure lag somewhere
 

	
 
  _onIronResize: ->
 
    @width(@offsetWidth)
 
  _onSongTime: (t) ->
 
    #@viewState.cursor.t(t)
 
  _onSongDuration: (d) ->
 
    d = 700 if d < 1 # bug is that asco isn't giving duration, but 0 makes the scale corrupt
 
    #@viewState.zoomSpec.duration(d)
 
    
 
  setSong: (s) ->
 
    @song = @playerSong if @followPlayerSong
 
  onGraph: (graph) ->
 
    @project = new Project(graph)
 

	
 
  updateDebugSummary: ->
 
    elemCount = (tag) -> document.getElementsByTagName(tag).length
 
    @debug = "#{window.debug_zoomOrLayoutChangedCount} layout change,
 
@@ -167,23 +193,6 @@ class TimelineEditor extends Polymer.Ele
 
     #{window.debug_adjUpdateDisplay} adjuster updateDisplay calls,
 
    "
 
    
 
  attached: ->
 
    super()
 
    @dia = @$.dia
 
    ko.computed(@zoomOrLayoutChanged.bind(@))
 
    ko.computed(@songTimeChanged.bind(@))
 

	
 
    @trackMouse()
 
    @bindKeys()
 
    @bindWheelZoom(@dia)
 
    @forwardMouseEventsToAdjustersCanvas()
 

	
 
    @makeZoomAdjs()
 

	
 
    zoomed = @$.zoomed
 
    setupDrop(@$.dia.querySelector('svg'), zoomed.$.rows, @, zoomed.onDrop.bind(zoomed))
 

	
 

	
 
  zoomOrLayoutChanged: ->
 
    log('zoomOrLayoutChanged')
 
    # not for cursor updates
 
@@ -206,6 +215,7 @@ class TimelineEditor extends Polymer.Ele
 
    @zoomInX = zoomInX
 

	
 
    # todo: these run a lot of work purely for a time change
 
    if @$.zoomed?.$?.audio?
 
    @dia.setTimeAxis(@width(), @$.zoomed.$.audio.offsetTop, @zoomInX)
 
    @$.adjustersCanvas.updateAllCoords()
 

	
 
@@ -214,6 +224,7 @@ class TimelineEditor extends Polymer.Ele
 
    setTimeout(@songTimeChanged.bind(@), 1)
 

	
 
  songTimeChanged: ->
 
    return unless @$.zoomed?.$?.time?
 
    @$.cursorCanvas.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight,
 
                              @$.zoomed.$.time.offsetTop,
 
                              @$.zoomed.$.time.offsetHeight,
 
@@ -257,6 +268,7 @@ class TimelineEditor extends Polymer.Ele
 

	
 
      zs.t1(center - left * scale)
 
      zs.t2(center + right * scale)
 
      log('view to', ko.toJSON(@viewState))
 

	
 
  forwardMouseEventsToAdjustersCanvas: ->
 
    ac = @$.adjustersCanvas
 
@@ -410,7 +422,6 @@ class TimeZoomed extends Polymer.Element
 
      #should only make new ones
 
      # 
 
      child = new Note(@graph, @selection, @dia, uri, @setAdjuster, @song, @zoomInX)
 
      log('note ',uri)
 
      originTime = @graph.floatValue(uri, U(':originTime'))
 
      effect = @graph.uriValue(uri, U(':effectClass'))
 
      for curve in @graph.objects(uri, U(':curve'))
 
@@ -421,7 +432,6 @@ class TimeZoomed extends Polymer.Element
 

	
 
          h = 150 #@offsetHeight
 
          screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * h]) for pt in @worldPts)
 

	
 
          graphics.beginFill(0xFF3300);
 
          graphics.lineStyle(4, 0xffd900, 1)
 

	
0 comments (0 inline, 0 general)