Changeset - 8ba8d1c469b5
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 9 years ago 2016-06-13 00:11:32
drewp@bigasterisk.com
TL lets you pick colorscale for each note
Ignore-this: b79796da75382dbeba09e9831aa115a9
2 files changed with 44 insertions and 9 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/timeline-elements.html
Show inline comments
 
@@ -318,13 +318,17 @@ background: rgba(126, 52, 245, 0.0784313
 
     }
 
    </style>
 
    <div id="top" style$="left: [[rect.left]]px; top: [[rect.top]]px; width: [[rect.width]]px; height: [[rect.height]]px; display: [[rect.display]]">
 
      <div>note [[noteLabel]] <button on-click="onDel">del</button></div>
 
      <table>
 
        <tr><th>effect:</th><td><edit-choice uri="{{effect}}" label="{{effectLabel}}"></edit-choice></td></tr>
 
        <!-- <tr><th>color:</th><td>[[color]]</td></tr> -->
 
        <tr><th>colorScale:</th><td>
 
          <!-- this could share with live/index.html's
 
          light9-live-control, but that one is currently junky -->
 
          <span><input type="color" value="{{colorScale::input}}"> [[colorScale]]</span>
 
        </td></tr>
 
      </table>
 
    </div>
 
  </template>
 
</dom-module>
 

	
 
<script src="/lib/sylvester/sylvester.js"></script>
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -331,34 +331,31 @@ Polymer
 
    'onZoom(zoomInX)'
 
    ]
 
  onGraph: ->
 
    @graph.runHandler(@update.bind(@), "row notes #{@rowIndex}")
 
  update: ->
 
    U = (x) -> @graph.Uri(x)
 
    log("row #{@rowIndex} updating")
 

	
 
    notesForThisRow = []
 
    i = 0
 
    for n in _.sortBy(@graph.objects(@song, U(':note')))
 
      if (i % ROW_COUNT) == @rowIndex
 
        notesForThisRow.push(n)
 
      i++
 
    log("row #{@rowIndex} gets", notesForThisRow)
 

	
 
    updateChildren @, notesForThisRow, (newUri) =>
 
      child = document.createElement('light9-timeline-note')
 
      child.graph = @graph
 
      child.dia = @dia
 
      child.uri = newUri
 
      child.setAdjuster = @setAdjuster
 
      child.song = @song # could change, but all the notes will be rebuilt
 
      child.zoomInX = @zoomInX # missing binding; see onZoom
 
      return child      
 

	
 
  onZoom: ->
 
    log('row onzoom')
 
    for e in @children
 
      e.zoomInX = @zoomInX
 

	
 

	
 
getCurvePoints = (graph, curve, xOffset) ->
 
  worldPts = []
 
@@ -426,14 +423,14 @@ Polymer
 

	
 
    screenPts = ($V([@zoomInX(pt.e(1)), @offsetTop + (1 - pt.e(2)) * @offsetHeight]) for pt in worldPts)
 
    @dia.setNote(@uri, screenPts, label)
 

	
 
    leftX = Math.max(2, screenPts[1].e(1) + 5)
 
    rightX = screenPts[2].e(1) - 5
 
    w = 120
 
    h = 45
 
    w = 170
 
    h = 80
 
    @inlineRect = {
 
      left: leftX,
 
      top: @offsetTop + @offsetHeight - h - 5,
 
      width: w,
 
      height: h,
 
      display: if rightX - leftX > w then 'block' else 'none'
 
@@ -494,29 +491,63 @@ Polymer
 

	
 
Polymer
 
  is: "light9-timeline-note-inline-attrs"
 
  properties:
 
    graph: { type: Object, notify: true }
 
    song: { type: String, notify: true }
 
    uri: { type: String, notify: true }
 
    uri: { type: String, notify: true }  # the Note
 
    rect: { type: Object, notify: true }
 
    effect: { type: String, notify: true }
 
    effectLabel: { type: String, notify: true }
 
    color: { type: String, notify: true }
 
    colorScale: { type: String, notify: true }
 
    noteLabel: { type: String, notify: true }
 
  observers: [
 
    'addHandler(graph, uri)'
 
    'onColorScale(graph, uri, colorScale)'
 
    ]
 
  onColorScale: ->
 
    U = (x) -> @graph.Uri(x)
 
    log('onColorScale', @colorScale, @colorScaleFromGraph, @existingColorScaleSetting)
 
    if @colorScale == @colorScaleFromGraph
 
      return
 
      
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: @song}
 

	
 
    settingValue = @graph.Literal(@colorScale)
 
    if @existingColorScaleSetting
 
      @graph.patchObject(@existingColorScaleSetting, U(':value'), settingValue, @song)
 
    else
 
      setting = @graph.nextNumberedResource(@uri + 'set')
 
      patch = {delQuads: [], addQuads: [
 
        quad(@uri, U(':setting'), setting)
 
        quad(setting, U(':effectAttr'), U(':colorScale'))
 
        quad(setting, U(':value'), settingValue)
 
        ]}
 
      @graph.applyAndSendPatch(patch)
 
    
 
  addHandler: ->
 
    @graph.runHandler(@update.bind(@))
 
  update: ->
 
    U = (x) -> @graph.Uri(x)
 
    @effect = @graph.uriValue(@uri, U(':effectClass'))
 
    @effectLabel = @effect.replace(/.*\//, '')
 
    @noteLabel = @uri.replace(/.*\//, '')
 
    @color = '#ff0000'
 

	
 
    @existingColorScaleSetting = null
 
    for setting in @graph.objects(@uri, U(':setting'))
 
      ea = @graph.uriValue(setting, U(':effectAttr'))
 
      value = @graph.stringValue(setting, U(':value'))
 
      if ea == U(':colorScale')
 
        @colorScaleFromGraph = value
 
        @colorScale = value
 
        @existingColorScaleSetting = setting
 
    if @existingColorScaleSetting == null
 
      @colorScaleFromGraph = '#ffffff'
 
      @colorScale = '#ffffff'
 

	
 

	
 
  onDel: ->
 
    patch = {delQuads: [{subject: @song, predicate: @graph.Uri(':note'), object: @uri, graph: @song}], addQuads: []}
 
    @graph.applyAndSendPatch(patch)
 

	
 

	
 
Polymer
0 comments (0 inline, 0 general)