Mercurial > code > home > repos > light9
changeset 1746:84adc69fdf8a
fix inlineattrs setup and effect editing
Ignore-this: f5d5089ab5550815158fcdbaa79d71f1
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Tue, 22 May 2018 06:42:10 +0000 |
parents | b0d6ace1db5a |
children | 5c4d6be0f0fe |
files | light9/web/edit-choice.coffee light9/web/timeline/inline-attrs.coffee light9/web/timeline/inline-attrs.html light9/web/timeline/timeline-elements.html light9/web/timeline/timeline.coffee |
diffstat | 5 files changed, 29 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/edit-choice.coffee Sat May 19 23:40:35 2018 +0000 +++ b/light9/web/edit-choice.coffee Tue May 22 06:42:10 2018 +0000 @@ -48,13 +48,14 @@ graph: {type: Object, notify: true}, uri: {type: String, notify: true}, + _setUri: (u) -> + @uri = u + @dispatchEvent(new CustomEvent('edited')) + connectedCallback: -> super.connectedCallback() - @uri = null - setupDrop @$.box, @$.box, null, (uri) => - @uri=uri - @updateLabel() + setupDrop(@$.box, @$.box, null, @_setUri.bind(@)) unlink: -> - @uri = null + @_setUri(null) )
--- a/light9/web/timeline/inline-attrs.coffee Sat May 19 23:40:35 2018 +0000 +++ b/light9/web/timeline/inline-attrs.coffee Tue May 22 06:42:10 2018 +0000 @@ -4,34 +4,34 @@ @is: "light9-timeline-note-inline-attrs" @getter_properties: graph: { type: Object, notify: true } + project: { type: Object, notify: true } song: { type: String, notify: true } config: { type: Object } # just for setup uri: { type: Object, notify: true } # the Note - effect: { type: Object, notify: true } effectStr: { type: String, notify: true } colorScale: { type: String, notify: true } noteLabel: { type: String, notify: true } selection: { type: Object, notify: true } @getter_observers: [ + '_onConfig(config)' 'addHandler(graph, uri)' 'onColorScale(graph, uri, colorScale)' - '_onConfig(config)' - '_effectToStr(effect)' - '_effectToUri(effectStr, graph)' ] - _effectToStr: (effect) -> - @effectStr = @effect?.value - log('now str is', @effectStr) - _effectToUri: (effectStr, graph) -> - if @effectStr - @effect = @graph.Uri(@effectStr) - else - @effect = null + + ready: -> + super.ready() + @$.effect.addEventListener 'edited', => + @graph.patchObject(@uri, @graph.Uri(':effectClass'), @graph.Uri(@effectStr), @graph.Uri(@song)) + _onConfig: -> @uri = @config.uri for side in ['top', 'left', 'width', 'height'] @.style[side] = @config[side] + 'px' + addHandler: -> + return unless @uri + @graph.runHandler(@update.bind(@), "update inline attrs #{@uri.value}") + onColorScale: -> return U = (x) => @graph.Uri(x) @@ -63,17 +63,11 @@ ]} @graph.applyAndSendPatch(patch) - addHandler: -> - return unless @uri - @graph.runHandler(@update.bind(@), "update inline attrs #{@uri.value}") - update: -> - return unless @uri? console.time('attrs update') U = (x) => @graph.Uri(x) - @effect = @graph.uriValue(@uri, U(':effectClass')) + @effectStr = @graph.uriValue(@uri, U(':effectClass'))?.value @noteLabel = @uri.value.replace(/.*\//, '') - return existingColorScaleSetting = null for setting in @graph.objects(@uri, U(':setting')) ea = @graph.uriValue(setting, U(':effectAttr')) @@ -87,7 +81,6 @@ @colorScale = '#ffffff' console.timeEnd('attrs update') - onDel: -> - deleteNote(@graph, @song, @uri, @selection) + @project.deleteNote(@graph.Uri(@song), @uri, @selection) )
--- a/light9/web/timeline/inline-attrs.html Sat May 19 23:40:35 2018 +0000 +++ b/light9/web/timeline/inline-attrs.html Tue May 22 06:42:10 2018 +0000 @@ -22,7 +22,7 @@ <div>note [[noteLabel]] <button on-click="onDel">del</button></div> <table> - <tr><th>effect:</th><td><edit-choice graph="{{graph}}" uri="{{effectStr}}"></edit-choice></td></tr> + <tr><th>effect:</th><td><edit-choice id="effect" graph="{{graph}}" uri="{{effectStr}}"></edit-choice></td></tr> <tr><th>colorScale:</th><td> <light9-color-picker color="{{colorScale}}"></light9-color-picker> </td></tr>
--- a/light9/web/timeline/timeline-elements.html Sat May 19 23:40:35 2018 +0000 +++ b/light9/web/timeline/timeline-elements.html Tue May 22 06:42:10 2018 +0000 @@ -121,6 +121,8 @@ <div id="rows"></div> <template is="dom-repeat" items="{{inlineAttrConfigs}}"> <light9-timeline-note-inline-attrs graph="{{graph}}" + project="{{project}}" + selection="{{selection}}" song="{{song}}" config="{{item}}"> </light9-timeline-note-inline-attrs>
--- a/light9/web/timeline/timeline.coffee Sat May 19 23:40:35 2018 +0000 +++ b/light9/web/timeline/timeline.coffee Tue May 22 06:42:10 2018 +0000 @@ -36,16 +36,16 @@ @graph.applyAndSendPatch({delQuads: [], addQuads: quads}) return effect - makeNewNote: (effect, dropTime, desiredWidthT) -> + makeNewNote: (song, effect, dropTime, desiredWidthT) -> U = (x) => @graph.Uri(x) - quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song} + quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: song} 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) + quad(song, U(':note'), newNote) quad(newNote, RDF + 'type', U(':Note')) quad(newNote, U(':originTime'), @graph.LiteralRoundedFloat(dropTime)) quad(newNote, U(':effectClass'), effect) @@ -87,7 +87,7 @@ tMax - tMin deleteNote: (song, note, selection) -> - patch = {delQuads: [{subject: song, predicate: graph.Uri(':note'), object: note, graph: song}], addQuads: []} + patch = {delQuads: [@graph.Quad(song, graph.Uri(':note'), note, song)], addQuads: []} @graph.applyAndSendPatch(patch) if note in selection.selected() selection.selected(_.without(selection.selected(), note)) @@ -385,7 +385,7 @@ desiredWidthX = @offsetWidth * .3 desiredWidthT = @viewState.zoomInX.invert(desiredWidthX) - @viewState.zoomInX.invert(0) desiredWidthT = Math.min(desiredWidthT, @zoom.duration() - dropTime) - @project.makeNewNote(effect, dropTime, desiredWidthT) + @project.makeNewNote(U(@song), effect, dropTime, desiredWidthT) updateInlineAttrs: (note, config) -> if not config? @@ -430,6 +430,7 @@ log('destroy', @uri.value) @isDetached = true @clearAdjusters() + @parentElem.updateInlineAttrs(@uri, null) clearAdjusters: -> for i in Object.keys(@adjusterIds)