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
 
@@ -276,18 +276,25 @@ coffeeElementSetup(class TimelineEditor 
 
    }))
 
)
 

	
 
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
0 comments (0 inline, 0 general)