Changeset - 3c8c9a1deece
[Not reviewed]
default
0 2 0
Drew Perttula - 8 years ago 2017-05-29 23:32:30
drewp@bigasterisk.com
drag LightSample into timeline to make a new effect
Ignore-this: d27d547ab00fa7c695f8e1d3313a4dcf
2 files changed with 41 insertions and 10 deletions:
0 comments (0 inline, 0 general)
light9/web/paint/paint-elements.coffee
Show inline comments
 
@@ -149,7 +149,7 @@ Polymer
 
        {attr: 'color', val: '#ffe897'},
 
    ]
 
  onSubj: (graph, @subj) ->
 
    graph.runHandler(@loadAttrs.bind(@), 'loadAttrs #{subj}')
 
    graph.runHandler(@loadAttrs.bind(@), "loadAttrs #{@subj}")
 
  loadAttrs: ->
 
    U = (x) -> @graph.Uri(x)
 
    @attrs = []
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -276,19 +276,50 @@ Polymer
 

	
 
  attached: ->
 
    root = @closest('light9-timeline-editor')
 
    setupDrop @, @$.rows, root, (effect, pos) =>
 
      U = (x) -> @graph.Uri(x)
 
    setupDrop(@, @$.rows, root, @onDrop.bind(@))
 

	
 
  onDrop: (effect, pos) ->
 
    U = (x) -> @graph.Uri(x)
 

	
 
      # we could probably accept some initial overrides right on the
 
      # effect uri, maybe as query params
 
      
 
      if not @graph.contains(effect, RDF + 'type', U(':Effect'))
 
    # we could probably accept some initial overrides right on the
 
    # effect uri, maybe as query params
 

	
 
    if not @graph.contains(effect, RDF + 'type', U(':Effect'))
 
      if @graph.contains(effect, RDF + 'type', U(':LightSample'))
 
        effect = @makeEffect(effect)
 
      else
 
        log("drop #{effect} is not an effect")
 
        return
 

	
 
    dropTime = @zoomInX.invert(pos.e(1))
 
    @makeNewNote(effect, dropTime)
 

	
 
  makeEffect: (uri) ->
 
    U = (x) -> @graph.Uri(x)
 
    effect = U(uri + '/effect')
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: effect}
 
    
 
    quads = [
 
      quad(effect, U('rdf:type'), U(':Effect')),
 
      quad(effect, U(':copiedFrom'), uri),
 
      quad(effect, U('rdfs:label'), @graph.Literal('')),
 
      quad(effect, U(':publishAttr'), U(':strength')),
 
      ]
 

	
 
    fromSettings = @graph.objects(uri, U(':setting'))
 

	
 
    toSettings = @graph.nextNumberedResources(effect + '_set', fromSettings.length)
 
      
 
      dropTime = @zoomInX.invert(pos.e(1))
 
      @makeNewNote(effect, dropTime)
 
      
 
    for fs in fromSettings
 
      ts = toSettings.pop()
 
      # full copies of these since I may have to delete captures
 
      quads.push(quad(effect, U(':setting'), ts))
 
      quads.push(quad(ts, U(':deviceAttr'), @graph.uriValue(fs, U(':deviceAttr'))))
 
      quads.push(quad(ts, U(':value'), @graph.uriValue(fs, U(':value'))))
 

	
 
    @graph.applyAndSendPatch({delQuads: [], addQuads: quads})
 
    return effect
 
        
 
  makeNewNote: (effect, dropTime) ->
 
    U = (x) -> @graph.Uri(x)
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song}
0 comments (0 inline, 0 general)