Changeset - f9593805e109
[Not reviewed]
default
0 4 0
Drew Perttula - 7 years ago 2018-05-14 02:38:00
drewp@bigasterisk.com
no more 'listeners' in polymer2. use 'ready' event more.
Ignore-this: a32c3be6f48e9b26e3e03b89e67c60fc
4 files changed with 21 insertions and 21 deletions:
0 comments (0 inline, 0 general)
light9/web/coffee_element.coffee
Show inline comments
 
# Polymer seems to need static getters for 'observers' and
 
# 'listeners', not just static attributes, though I don't know how it
 
# 'properties', not just static attributes, though I don't know how it
 
# can even tell the difference.
 
#
 
# This workaround is to use names like '@getter_properties' in the
 
# class then register with this function that fixes them.
 
# 
 
# Also see http://coffeescript.org/#unsupported-get-set
 
window.coffeeElementSetup = (cls) ->
 
  for attr in ['properties', 'observers', 'listeners']
 
  for attr in ['properties', 'observers']
 
    val = cls['getter_' + attr]
 
    if val?
 
      do (val) ->
 
        Object.defineProperty(cls, attr, {get: ( -> val)})  
 
  customElements.define(cls.is, cls)
light9/web/timeline/adjusters.coffee
Show inline comments
 
@@ -6,16 +6,15 @@ coffeeElementSetup(class AdjustersCanvas
 
  @is: 'light9-adjusters-canvas'
 
  @getter_properties:
 
    adjs: { type: Object, notify: true }, # adjId: Adjustable
 
  @getter_observers: [
 
    'updateAllCoords(adjs)'
 
  ]
 
  @getter_listeners:
 
    'iron-resize': 'resizeUpdate'
 
  connectedCallback: ->
 
    super.connectedCallback()
 
  ready: ->
 
    super.ready()
 
    @addEventListener('iron-resize', @resizeUpdate.bind(@))
 
    @adjs = {}
 
    @ctx = @$.canvas.getContext('2d')
 

	
 
    @redraw()
 
   
 
  onDown: (ev) ->
light9/web/timeline/cursor_canvas.coffee
Show inline comments
 
coffeeElementSetup(class CursorCanvas extends Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element)
 
  @is: 'light9-cursor-canvas'
 
  @getter_properties:
 
    viewState: { type: Object, notify: true, observer: "onViewState" }
 
  @getter_listeners: 'iron-resize': 'update'
 
  connectedCallback: ->
 
    super.connectedCallback()
 
  ready: ->
 
    super.ready()
 
    @mouseX = 0
 
    @mouseY = 0
 
    @cursorPath = null
 
    @ctx = @$.canvas.getContext('2d')
 
    @onResize()
 
    @addEventListener('iron-resize', @onResize.bind(@))
 

	
 
  onViewState: ->
 
    ko.computed(@redrawCursor.bind(@))
 

	
 
  update: (ev) ->
 
    @$.canvas.width = ev.target.offsetWidth
 
    @$.canvas.height = ev.target.offsetHeight
 
    @redraw()
 
  onResize: (ev) ->
 
    @$.canvas.width = @offsetWidth
 
    @$.canvas.height = @offsetHeight
 
    @redrawCursor()
 

	
 
  redrawCursor: ->
 
    vs = @viewState
 
    dependOn = [vs.zoomSpec.t1(), vs.zoomSpec.t2()]
 
    xZoomedOut = vs.fullZoomX(vs.latestMouseTime())
 
    xZoomedIn = vs.mouse.pos().e(1)
 
@@ -29,13 +30,13 @@ coffeeElementSetup(class CursorCanvas ex
 
      top1: $V([xZoomedOut, vs.audioY() + vs.audioH()])
 
      mid0: $V([xZoomedIn + 2, vs.zoomedTimeY() + vs.zoomedTimeH()])
 
      mid1: $V([xZoomedIn - 2, vs.zoomedTimeY() + vs.zoomedTimeH()])
 
      mid2: $V([xZoomedOut - 1, vs.audioY() + vs.audioH()])
 
      mid3: $V([xZoomedOut + 1, vs.audioY() + vs.audioH()])
 
      bot0: $V([xZoomedIn, vs.zoomedTimeY() + vs.zoomedTimeH()])
 
      bot1: $V([xZoomedIn, @offsetParent.offsetHeight])
 
      bot1: $V([xZoomedIn, @offsetHeight])
 
    }
 
    @redraw()
 

	
 
  redraw: ->
 
    return unless @ctx
 
    @ctx.clearRect(0, 0, @$.canvas.width, @$.canvas.height)
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -202,14 +202,14 @@ coffeeElementSetup(class TimelineEditor 
 
  @getter_observers: [
 
    'setSong(playerSong, followPlayerSong)',
 
    'onGraph(graph)',
 
    '_onSongDuration(songDuration, viewState)',
 
    '_onSongTime(songTime, viewState)',
 
  ]
 
  connectedCallback: ->
 
    super.connectedCallback()
 
  ready: ->
 
    super.ready()
 
    
 
    ko.options.deferUpdates = true;
 
    
 
    @dia = @$.dia
 
     
 
    @selection = {hover: ko.observable(null), selected: ko.observable([])}
 
@@ -398,14 +398,14 @@ coffeeElementSetup(class TimeZoomed exte
 
    @stage = new PIXI.Container()
 
    
 
    @renderer = PIXI.autoDetectRenderer({
 
         backgroundColor: 0xff6060,
 
    })
 
     
 
  connectedCallback: ->
 
    super.connectedCallback()
 
  ready: ->
 
    super.ready()
 
     
 
    @addEventListener('iron-resize', @update.bind(@))
 
    @update()
 
    
 
    @$.rows.appendChild(@renderer.view);
 
  
 
@@ -525,13 +525,12 @@ class NoteRow
 
      e.zoomInX = @zoomInX
 

	
 
class Note
 
  constructor: (@graph, @selection, @dia, @uri, @setAdjuster, @song, @zoomInX)->0
 
  @is: 'light9-timeline-note'
 
  @behaviors: [ Polymer.IronResizableBehavior ]
 
  @listeners: 'iron-resize': 'update' #move to parent elem
 
  @properties:
 
    graph: { type: Object, notify: true }
 
    selection: { type: Object, notify: true }
 
    dia: { type: Object, notify: true }
 
    uri: { type: String, notify: true }
 
    zoomInX: { type: Object, notify: true }
 
@@ -541,12 +540,13 @@ class Note
 
  @observers: [
 
    'onUri(graph, dia, uri, zoomInX, setAdjuster, song)'
 
    'update(graph, dia, uri, zoomInX, setAdjuster, song)'
 
    ]
 
  ready: ->
 
    @adjusterIds = {} # id : true
 
    @addEventListener('iron-resize', @update)
 

	
 
  detached: ->
 
    log('detatch', @uri)
 
    @dia.clearNote(@uri)
 
    @isDetached = true
 
    @clearAdjusters()
 
@@ -699,14 +699,14 @@ class Note
 
coffeeElementSetup(class DiagramLayer extends Polymer.Element
 
  # note boxes. 
 
  @is: 'light9-timeline-diagram-layer'
 
  @getter_properties: {
 
    selection: {type: Object, notify: true}
 
  }
 
  connectedCallback: ->
 
    super.connectedCallback()
 
  ready: ->
 
    super.ready()
 
    @elemById = {}
 

	
 
 
 
  getOrCreateElem: (uri, groupId, tag, attrs, moreBuild) ->
 
    elem = @elemById[uri]
 
    if !elem
0 comments (0 inline, 0 general)