Mercurial > code > home > repos > light9
changeset 1741:17f56584e253
fix types so graph writing works again.
Ignore-this: 8691cc024983e1d581d1a16202c92870
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sat, 19 May 2018 07:25:01 +0000 |
parents | 7cb53b510a6a |
children | 70873145cc71 |
files | light9/web/graph.coffee light9/web/timeline/timeline-elements.html light9/web/timeline/timeline.coffee |
diffstat | 3 files changed, 22 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/graph.coffee Fri May 18 07:54:42 2018 +0000 +++ b/light9/web/graph.coffee Sat May 19 07:25:01 2018 +0000 @@ -165,6 +165,8 @@ @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 @@ 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 @@ 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 @@ 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]
--- a/light9/web/timeline/timeline-elements.html Fri May 18 07:54:42 2018 +0000 +++ b/light9/web/timeline/timeline-elements.html Sat May 19 07:25:01 2018 +0000 @@ -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>
--- a/light9/web/timeline/timeline.coffee Fri May 18 07:54:42 2018 +0000 +++ b/light9/web/timeline/timeline.coffee Sat May 19 07:25:01 2018 +0000 @@ -40,9 +40,9 @@ 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 @@ 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,10 +124,8 @@ ready: -> super.ready() - ko.options.deferUpdates = true; + ko.options.deferUpdates = true - @dia = @$.dia - @selection = {hover: ko.observable(null), selected: ko.observable([])} window.debug_zoomOrLayoutChangedCount = 0 @@ -170,6 +168,7 @@ _onGraph: (graph) -> @project = new Project(graph) + @show = 'http://light9.bigasterisk.com/show/dance2017' _onSetAdjuster: () -> @makeZoomAdjs() @@ -188,6 +187,7 @@ 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 @@ @$.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 @@ @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 @@ 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 @@ 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)