Changeset - 84adc69fdf8a
[Not reviewed]
default
0 5 0
Drew Perttula - 7 years ago 2018-05-22 06:42:10
drewp@bigasterisk.com
fix inlineattrs setup and effect editing
Ignore-this: f5d5089ab5550815158fcdbaa79d71f1
5 files changed with 29 insertions and 32 deletions:
0 comments (0 inline, 0 general)
light9/web/edit-choice.coffee
Show inline comments
 
@@ -48,13 +48,14 @@ coffeeElementSetup(class EditChoice exte
 
        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)
 
)
light9/web/timeline/inline-attrs.coffee
Show inline comments
 
@@ -4,34 +4,34 @@ coffeeElementSetup(class InlineAttrs ext
 
  @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 @@ coffeeElementSetup(class InlineAttrs ext
 
        ]}
 
      @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 @@ coffeeElementSetup(class InlineAttrs ext
 
      @colorScale = '#ffffff'
 
    console.timeEnd('attrs update')
 

	
 

	
 
  onDel: ->
 
    deleteNote(@graph, @song, @uri, @selection)
 
    @project.deleteNote(@graph.Uri(@song), @uri, @selection)
 
)
light9/web/timeline/inline-attrs.html
Show inline comments
 
@@ -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>
light9/web/timeline/timeline-elements.html
Show inline comments
 
@@ -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>
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -36,16 +36,16 @@ class Project
 
    @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 @@ class Project
 
    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 @@ coffeeElementSetup(class TimeZoomed exte
 
    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 @@ class Note
 
    log('destroy', @uri.value)
 
    @isDetached = true
 
    @clearAdjusters()
 
    @parentElem.updateInlineAttrs(@uri, null)
 

	
 
  clearAdjusters: ->
 
    for i in Object.keys(@adjusterIds)
0 comments (0 inline, 0 general)