Changeset - 17f56584e253
[Not reviewed]
default
0 3 0
Drew Perttula - 7 years ago 2018-05-19 07:25:01
drewp@bigasterisk.com
fix types so graph writing works again.
Ignore-this: 8691cc024983e1d581d1a16202c92870
3 files changed with 22 insertions and 40 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -165,6 +165,8 @@ class window.SyncedGraph
 
    @prefixFuncs = N3.Util.prefixes(@prefixes)
 
        
 
  Uri: (curie) ->
 
    if not curie?
 
      throw new Error("no uri")
 
    if curie.match(/^http/)
 
      return N3.DataFactory.namedNode(curie)
 
    part = curie.split(':')
 
@@ -175,7 +177,7 @@ class window.SyncedGraph
 

	
 
  LiteralRoundedFloat: (f) ->
 
    N3.DataFactory.literal(d3.format(".3f")(f),
 
                          "http://www.w3.org/2001/XMLSchema#double")
 
                          @Uri("http://www.w3.org/2001/XMLSchema#double"))
 

	
 
  Quad: (s, p, o, g) -> N3.DataFactory.quad(s, p, o, g)
 

	
 
@@ -215,7 +217,7 @@ class window.SyncedGraph
 
      for q in qs
 
        if not q.equals
 
          throw new Error("doesn't look like a proper Quad")
 
        if not q.graph?
 
        if not q.subject.id or not q.graph.id?
 
          throw new Error("corrupt patch: #{JSON.stringify(q)}")
 
    
 
  _applyPatch: (patch) ->
 
@@ -334,6 +336,8 @@ class window.SyncedGraph
 
    return @graph.getQuads(s, p, o).length > 0
 

	
 
  nextNumberedResources: (base, howMany) ->
 
    # base is NamedNode or string
 
    base = base.id if base.id
 
    results = []
 
    # we could cache [base,lastSerial]
 
    for serial in [0..1000]
light9/web/timeline/timeline-elements.html
Show inline comments
 
@@ -220,30 +220,6 @@
 
  </template>
 
</dom-module>
 

	
 
<!-- One trapezoid note shape in a row.
 
     This element has the right Y coords.
 
     We compute X coords from the zoom setting.
 
     diagram-layer draws the note body. -->
 
<dom-module id="light9-timeline-note">
 
  <template>
 
    <style>
 
     :host {
 
         display: block;
 
         background: green;
 
         /* outline: 2px solid red; */
 
     }
 
    </style>
 
    <light9-timeline-note-inline-attrs rect="{{inlineRect}}"
 
                                       graph="{{graph}}"
 
                                       selection="{{selection}}"
 
                                       song="{{song}}"
 
                                       uri="{{uri}}"
 
                                       effect="{{effect}}"
 
    >
 
    </light9-timeline-note-inline-attrs>
 
  </template>
 
</dom-module>
 

	
 
<!-- All the adjusters you can edit or select. Tells a light9-adjusters-canvas how to draw them. Probabaly doesn't need to be an element.
 
     This element manages their layout and suppresion.
 
     Owns the selection.
 
@@ -256,7 +232,6 @@
 
     :host {
 
         pointer-events: none; /* restored on the individual adjusters */
 
     }
 

	
 
    </style>
 
  </template>
 
</dom-module>
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -40,9 +40,9 @@ class Project
 
    U = (x) => @graph.Uri(x)
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song}
 
      
 
    newNote = @graph.nextNumberedResource("#{@song}/n")
 
    newCurve = @graph.nextNumberedResource("#{newNote}c")
 
    points = @graph.nextNumberedResources("#{newCurve}p", 4)
 
    newNote = @graph.nextNumberedResource("#{@song.value}/n")
 
    newCurve = @graph.nextNumberedResource("#{newNote.value}c")
 
    points = @graph.nextNumberedResources("#{newCurve.value}p", 4)
 

	
 
    curveQuads = [
 
        quad(@song, U(':note'), newNote)
 
@@ -104,7 +104,7 @@ coffeeElementSetup(class TimelineEditor 
 
    playerSong: {type: String, notify: true}
 
    followPlayerSong: {type: Boolean, notify: true, value: true}
 
    song: {type: String, notify: true}
 
    show: {value: 'http://light9.bigasterisk.com/show/dance2017'}
 
    show: {type: String, notify: true}
 
    songTime: {type: Number, notify: true}
 
    songDuration: {type: Number, notify: true}
 
    songPlaying: {type: Boolean, notify: true}
 
@@ -124,9 +124,7 @@ coffeeElementSetup(class TimelineEditor 
 
  ready: ->
 
    super.ready()
 
    
 
    ko.options.deferUpdates = true;
 
    
 
    @dia = @$.dia
 
    ko.options.deferUpdates = true
 
     
 
    @selection = {hover: ko.observable(null), selected: ko.observable([])}
 

	
 
@@ -170,6 +168,7 @@ coffeeElementSetup(class TimelineEditor 
 
    
 
  _onGraph: (graph) ->
 
    @project = new Project(graph)
 
    @show = 'http://light9.bigasterisk.com/show/dance2017'
 

	
 
  _onSetAdjuster: () ->
 
    @makeZoomAdjs()
 
@@ -188,6 +187,7 @@ coffeeElementSetup(class TimelineEditor 
 
    vs = @viewState
 
    dependOn = [vs.zoomSpec.t1(), vs.zoomSpec.t2(), vs.width()]
 

	
 
    # shouldn't need this- deps should get it
 
    @$.zoomed.gatherNotes() if @$.zoomed?.gatherNotes?
 
  
 
    # todo: these run a lot of work purely for a time change
 
@@ -232,7 +232,7 @@ coffeeElementSetup(class TimelineEditor 
 
      @$.adjustersCanvas.updateAllCoords()
 
    shortcut.add 'Delete', =>
 
      for note in @selection.selected()
 
        @project.deleteNote(@song, note, @selection)
 
        @project.deleteNote(@graph.Uri(@song), note, @selection)
 

	
 
  makeZoomAdjs: ->
 
    yMid = => @$.audio.offsetTop + @$.audio.offsetHeight / 2
 
@@ -309,7 +309,7 @@ coffeeElementSetup(class TimeZoomed exte
 
    @addEventListener('iron-resize', @_onResize.bind(@))
 
    Polymer.RenderStatus.afterNextRender(this, @_onResize.bind(@))
 
    
 
    @$.rows.appendChild(@renderer.view);
 
    @$.rows.appendChild(@renderer.view)
 

	
 
    ko.computed =>
 
      @stage.setTransform(0, -(@viewState.rowsY()), 1, 1, 0, 0, 0, 0, 0)
 
@@ -323,20 +323,23 @@ coffeeElementSetup(class TimeZoomed exte
 
    
 
  gatherNotes: ->
 
    U = (x) => @graph.Uri(x)
 
    return unless @song?
 
    log('assign rows', @song)
 

	
 
    log('assign rows',@song)
 
    songNotes = @graph.objects(U(@song), U(':note'))
 
    
 

	
 
    @stage.removeChildren()
 
    n.destroy() for n in @notes
 
    @notes = []
 
    
 
    noteNum = 0
 
    for uri in _.sortBy(@graph.objects(@song, U(':note')), 'id')
 
    for uri in _.sortBy(songNotes, 'id')
 
      con = new PIXI.Container()
 
      @stage.addChild(con)
 
      row = noteNum % 6
 
      rowTop = @viewState.rowsY() + 20 + 150 * row
 
      note = new Note(con, @project, @graph, @selection, uri, @setAdjuster, @song, @viewState, rowTop, rowTop + 140)
 
      note = new Note(con, @project, @graph, @selection, uri, @setAdjuster, U(@song), @viewState, rowTop, rowTop + 140)
 
      @notes.push(note)
 
      noteNum = noteNum + 1
 
 
 
@@ -384,7 +387,7 @@ coffeeElementSetup(class TimeAxis extend
 
class Note
 
  constructor: (@container, @project, @graph, @selection, @uri, @setAdjuster, @song, @viewState, @rowTopY, @rowBotY) ->
 
    @adjusterIds = {} # id : true
 
    @draw()
 
    Polymer.RenderStatus.afterNextRender(this, @graph.runHandler(@draw.bind(@), 'note draw'))
 

	
 
  destroy: ->
 
    log('destroy', @uri.value)
0 comments (0 inline, 0 general)