Changeset - b7023c28dd4f
[Not reviewed]
default
0 3 0
Drew Perttula - 9 years ago 2016-06-06 06:45:01
drewp@bigasterisk.com
rm demo adjusters. build first real adjuster on originTime of note
Ignore-this: 22f1b870b3f742aa5dc47d9427ba3847
3 files changed with 35 insertions and 59 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline-elements.html
Show inline comments
 
@@ -47,25 +47,28 @@
 
                           show="{{show}}"
 
                           song="{{song}}"></light9-timeline-audio>
 
    <light9-timeline-time-zoomed id="zoomed"
 
                                 graph="{{graph}}"
 
                                 song="{{song}}"
 
                                 show="{{show}}"
 
                                 zoom="{{viewState.zoomSpec}}"
 
                                 zoom-in-x="{{zoomInX}}">
 
    </light9-timeline-time-zoomed>
 
    <light9-timeline-diagram-layer id="dia"></light9-timeline-diagram-layer>
 
    <light9-timeline-adjusters id="adjusters"
 
                               dia="{{dia}}"
 
                               adjs="{{adjs}}">
 
                               graph="{{graph}}"
 
                               song="{{song}}"
 
                               parent-adjs="{{adjs}}"
 
                               zoom-in-x="{{zoomInX}}">
 
    </light9-timeline-adjusters>
 
  </template>
 
 
 
</dom-module>
 

	
 
<!-- the whole section that pans/zooms in time (most of the editor) -->
 
<dom-module id="light9-timeline-time-zoomed">
 
  <template>
 
    <style>
 
     :host {
 
         display: flex;
 
         height: 100%;
light9/web/timeline.coffee
Show inline comments
 
@@ -47,25 +47,25 @@ Polymer
 
      ).extend({rateLimit: 5})
 

	
 
    ko.computed( =>
 
        # zoomInX changing doesn't retrigger this, so I'll do it here
 
        ko.toJS(@viewState.zoomSpec)
 
        
 
        @$.dia.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight,
 
                         @$.zoomed.$.time.offsetTop,
 
                         @$.zoomed.$.time.offsetHeight,
 
                         @fullZoomX, @zoomInX, @viewState.cursor)
 
      )
 

	
 
    @adjs = @makeZoomAdjs().concat(@persistDemo())
 
    @adjs = @makeZoomAdjs()
 

	
 
    @trackMouse()
 
    @bindKeys()
 
    @bindWheelZoom()
 

	
 
  trackMouse: ->
 
    # not just for show- we use the mouse pos sometimes
 
    for evName in ['mousemove', 'touchmove']
 
      @addEventListener evName, (ev) =>
 
        ev.preventDefault()
 

	
 
        # todo: consolidate with _editorCoordinates version
 
@@ -121,49 +121,24 @@ Polymer
 
    shortcut.add "Shift+Escape", =>
 
      @animatedZoom(@songTime - 2, @viewState.zoomSpec.duration(), zoomAnimSec)
 
    shortcut.add "Escape", =>
 
      zs = @viewState.zoomSpec
 
      visSeconds = zs.t2() - zs.t1()
 
      margin = visSeconds * .4
 
      # buggy: really needs t1/t2 to limit their ranges
 
      if @songTime < zs.t1() or @songTime > zs.t2() - visSeconds * .6
 
        newCenter = @songTime + margin
 
        @animatedZoom(newCenter - visSeconds / 2,
 
                      newCenter + visSeconds / 2, zoomAnimSec)
 

	
 
  persistDemo: ->
 
    ctx = @graph.Uri(@song)
 
    adjs = []
 
    for n in [0..7]
 
      subj = @graph.Uri(':demoResource'+n)
 
      adjs.push(new AdjustableFloatObject({
 
        graph: @graph
 
        subj: subj
 
        pred: @graph.Uri(':startTime')
 
        ctx: ctx
 
        getTargetTransform: (value) => $V([@zoomInX(value), 600])
 
        getValueForPos: (pos) => @zoomInX.invert(pos.e(1))
 
        getSuggestedTargetOffset: () => $V([0, -80])
 
      }))
 
      adjs.push(new AdjustableFloatObject({
 
        graph: @graph
 
        subj: subj
 
        pred: @graph.Uri(':endTime')
 
        ctx: ctx
 
        getTargetTransform: (value) => $V([@zoomInX(value), 600])
 
        getValueForPos: (pos) => @zoomInX.invert(pos.e(1))
 
        getSuggestedTargetOffset: () => $V([0, -80])
 
      }))
 
    return adjs
 

	
 
  makeZoomAdjs: ->
 
    yMid = @$.audio.offsetTop + @$.audio.offsetHeight / 2
 
    dur = @viewState.zoomSpec.duration
 
    
 
    valForPos = (pos) =>
 
        x = pos.e(1)
 
        t = @fullZoomX.invert(x)
 
    left = new AdjustableFloatObservable({
 
      observable: @viewState.zoomSpec.t1,
 
      getTarget: () =>
 
        $V([@fullZoomX(@viewState.zoomSpec.t1()), yMid])
 
      getSuggestedTargetOffset: () => $V([-50, 0])
 
@@ -222,32 +197,30 @@ Polymer
 
  behaviors: [ Polymer.IronResizableBehavior ]
 
  listeners: 'iron-resize': 'update'
 
  properties:
 
    graph: { type: Object, notify: true }
 
    uri: { type: String, notify: true }
 
    zoomInX: { type: Object, notify: true, observer: 'update' }
 
  observers: [
 
    'onUri(graph, uri)'
 
    ]
 
  ready: ->
 

	
 
  onUri: ->
 
    @graph.subscribe(@uri, null, null, @update.bind(@))
 
    @graph.runHandler(@update.bind(@))
 
    
 
  update: ->
 
    # update our note DOM and SVG elements based on the graph
 
    U = (x) -> @graph.Uri(x)
 
    return if !@zoomInX
 
    try
 

	
 
      worldPts = [] # (song time, value)
 

	
 
      originTime = @graph.floatValue(@uri, U(':originTime'))
 
      for curve in @graph.objects(@uri, U(':curve'))
 
        if @graph.uriValue(curve, U(':attr')) == U(':strength')
 
          
 
          for pt in @graph.objects(curve, U(':point'))
 

	
 
            worldPts.push($V([
 
              originTime + @graph.floatValue(pt, U(':time')),
 
              @graph.floatValue(pt, U(':value'))
 
              ]))
 
@@ -255,26 +228,50 @@ Polymer
 

	
 
      screenPos = (pt) =>
 
        $V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight])
 

	
 
      setNote(@uri, (screenPos(pt) for pt in worldPts))
 

	
 
    catch e
 
      log('during resize, ', e)
 

	
 
Polymer
 
  is: "light9-timeline-adjusters"
 
  properties:
 
    adjs: { type: Array },
 
    adjs: { type: Array }, # our computed list
 
    parentAdjs: { type: Array }, # incoming requests
 
    graph: { type: Object, notify: true }
 
    song: { type: String, notify: true }
 
    zoomInX: { type: Object, notify: true }
 
    dia: { type: Object }
 
  observers: [
 
    'update(parentAdjs, graph, song, dia)'
 
    'onGraph(graph, song)'
 
    ]
 
  onGraph: (graph, song, zoomInX) ->
 
    graph.runHandler(@update.bind(@))
 
  update: (parentAdjs, graph, song, dia) ->
 
    U = (x) -> @graph.Uri(x)
 
    @adjs = @parentAdjs.slice()
 
    for note in @graph.objects(@song, U(':note'))
 
      @push('adjs', new AdjustableFloatObject({
 
        graph: @graph
 
        subj: note
 
        pred: @graph.Uri(':originTime')
 
        ctx: @graph.Uri(@song)
 
        getTargetTransform: (value) => $V([@zoomInX(value), 600])
 
        getValueForPos: (pos) => @zoomInX.invert(pos.e(1))
 
        getSuggestedTargetOffset: () => $V([0, -80])
 
      }))
 
    
 
  updateAllCoords: ->
 
    for elem in @querySelectorAll('light9-timeline-adjuster')
 
      elem.updateDisplay()
 
    
 

	
 
_adjusterSerial = 0
 

	
 
Polymer
 
  is: 'light9-timeline-adjuster'
 
  properties:
 
    adj:
 
      type: Object
show/dance2016/song1.n3
Show inline comments
 
@prefix ns1: <http://light9.bigasterisk.com/> .
 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
 
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 

	
 
ns1:demoResource0 ns1:endTime 120.3 ;
 
    ns1:startTime 3.421 .
 

	
 
ns1:demoResource1 ns1:endTime 16 ;
 
    ns1:startTime 6.791 .
 

	
 
ns1:demoResource2 ns1:endTime 60 ;
 
    ns1:startTime 38 .
 

	
 
ns1:demoResource3 ns1:endTime 62.149 ;
 
    ns1:startTime 56 .
 

	
 
ns1:demoResource4 ns1:endTime 78.599 ;
 
    ns1:startTime 73 .
 

	
 
ns1:demoResource5 ns1:endTime 105 ;
 
    ns1:startTime 87.573 .
 

	
 
ns1:demoResource6 ns1:endTime 113.942 ;
 
    ns1:startTime 109.328 .
 

	
 
ns1:demoResource7 ns1:endTime 140.711 ;
 
    ns1:startTime 130.447 .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1> ns1:note <http://light9.bigasterisk.com/show/dance2016/song1/n1> .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1> a ns1:Note ;
 
    ns1:curve <http://light9.bigasterisk.com/show/dance2016/song1/n1c1> ;
 
    ns1:originTime 5 .
 
    ns1:originTime 29.932 .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1> a ns1:Curve ;
 
    ns1:attr ns1:strength ;
 
    ns1:point <http://light9.bigasterisk.com/show/dance2016/song1/n1c1p0>,
 
        <http://light9.bigasterisk.com/show/dance2016/song1/n1c1p1>,
 
        <http://light9.bigasterisk.com/show/dance2016/song1/n1c1p2>,
 
        <http://light9.bigasterisk.com/show/dance2016/song1/n1c1p3> .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p0> ns1:time 0.00 ;
 
    ns1:value 0 .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p1> ns1:time 0.02 ;
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p1> ns1:time 12.08 ;
 
    ns1:value 1 .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p2> ns1:time 0.10 ;
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p2> ns1:time 15.10 ;
 
    ns1:value 1 .
 

	
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p3> ns1:time 0.65 ;
 
<http://light9.bigasterisk.com/show/dance2016/song1/n1c1p3> ns1:time 23.65 ;
 
    ns1:value 0 .
 

	
0 comments (0 inline, 0 general)