Changeset - 48e4e25f37a3
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 7 years ago 2018-06-03 04:51:43
drewp@bigasterisk.com
starting BrickLayout. WIP
Ignore-this: 4c6ff2700352e5f28fab6f9a7a5f5a3e
1 file changed with 10 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -267,36 +267,43 @@ coffeeElementSetup(class TimelineEditor 
 

	
 
    @setAdjuster('zoom-pan', => new AdjustableFloatObservable({
 
      observable: panObs
 
      emptyBox: true
 
      # fullzoom is not right- the sides shouldn't be able to go
 
      # offscreen
 
      getTarget: () => $V([@viewState.fullZoomX(panObs()), yMid()])
 
      getSuggestedTargetOffset: () => $V([0, 0])
 
      getValueForPos: valForPos
 
    }))
 
)
 

	
 
nr=0
 

	
 
class BrickLayout
 
  constructor: (@viewState, @numRows) ->
 
    @noteRow = {} # uristr: row, t0, t1
 
  addNote: (n) ->
 
    @noteRow[n.uri.value] = {row: nr%6, t0: 0, t1: 0}
 
    nr++
 
    @noteRow[n.uri.value] = {row: 0, t0: 0, t1: 0}
 
    
 
  setNoteSpan: (n, t0, t1) ->
 
    @noteRow[n.uri.value].t0 = t0
 
    @noteRow[n.uri.value].t1 = t1
 
    @_recompute()
 
  delNote: (n) ->
 
    delete @noteRow[n.uri.value]
 
  _recompute: ->
 
    notesByWidth = _.sortBy([{dur: row.t1 - row.t0 + row.t0 * .0001, uri: u} for u, row of @noteRow], 'dur')
 
    notesByWidth.reverse()
 
    for n in notesByWidth
 
      @noteRow[n.uri].row = 0
 
    
 
  rowBottom: (row) -> @viewState.rowsY() + 20 + 150 * row + 140
 
  yForVFor: (n) ->
 
    row = @noteRow[n.uri.value].row
 
    rowBottom = @rowBottom(row)
 
    rowTop = rowBottom - 140
 
    (v) => rowBottom + (rowTop - rowBottom) * v      
 

	
 
# 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.
 
coffeeElementSetup(class TimeZoomed extends Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element)
 
  @is: 'light9-timeline-time-zoomed'
0 comments (0 inline, 0 general)