Changeset - b1fed8880ada
[Not reviewed]
default
0 1 0
Drew Perttula - 8 years ago 2017-04-06 11:15:56
drewp@bigasterisk.com
shadow on adjs. try to draw faster and wait less for debouncing
Ignore-this: b54a18b559c274591c1c2671b9e7287f
1 file changed with 21 insertions and 8 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -53,12 +53,14 @@ Polymer
 
    d = 700 if d < 1 # bug is that asco isn't giving duration, but 0 makes the scale corrupt
 
    @viewState.zoomSpec.duration(d)
 
  setSong: (s) ->
 
    @song = @playerSong if @followPlayerSong
 

	
 
  ready: ->
 
    ko.options.deferUpdates = true;
 

	
 
    window.debug_zoomOrLayoutChangedCount = 0
 
    window.debug_adjUpdateDisplay = 0
 
    
 
    @viewState =
 
      zoomSpec:
 
        duration: ko.observable(100)
 
@@ -86,13 +88,13 @@ Polymer
 
     #{window.debug_adjsCount} adjuster items registered,
 
     #{window.debug_adjUpdateDisplay} adjuster updateDisplay calls,
 
    "
 
    
 
  attached: ->
 
    @dia = @$.dia
 
    ko.computed(@zoomOrLayoutChanged.bind(@)).extend({rateLimit: 5})
 
    ko.computed(@zoomOrLayoutChanged.bind(@))
 
    ko.computed(@songTimeChanged.bind(@))
 

	
 
    @trackMouse()
 
    @bindKeys()
 
    @bindWheelZoom()
 
    @forwardMouseEventsToAdjustersCanvas()
 
@@ -740,13 +742,14 @@ Polymer
 
  properties:
 
    adjs: { type: Object, notify: true }, # adjId: Adjustable
 
  listeners: 'iron-resize': 'update'
 
  ready: ->
 
    @adjs = {}
 
    @ctx = @$.canvas.getContext('2d')
 
    
 

	
 
    @dirty = false
 
    @redraw()
 
   
 
  onDown: (ev) ->
 
    if ev.buttons == 1
 
      ev.stopPropagation()
 
      start = $V([ev.x, ev.y])
 
@@ -776,15 +779,13 @@ Polymer
 
        delete @adjs[adjId]
 
      else
 
        adj = makeAdjustable()
 
        @adjs[adjId] = adj
 
        adj.id = adjId
 

	
 
    # this is relying on makeCurveAdjusters always calling setAdjuster
 
    # whenever the values may have changed
 
    @debounce('adjsChanged', @adjsChanged.bind(@), 10)
 
    @dirty = true 
 

	
 
    window.debug_adjsCount = Object.keys(@adjs).length
 
    
 
  adjsChanged: ->
 
    @updateAllCoords()
 

	
 
@@ -825,42 +826,54 @@ Polymer
 
    @redraw()
 

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

	
 
  flush: () ->
 
    if @dirty
 
      @redraw()
 
    
 
  redraw: (adjs) ->
 
    @ctx.clearRect(0, 0, @$.canvas.width, @$.canvas.height)
 

	
 
    for adjId, adj of @adjs
 
      ctr = adj.getCenter()
 
      target = adj.getTarget()
 
      @drawConnector(ctr, target)
 
      
 
      @drawAdjuster(adj.getDisplayValue(),
 
                    Math.floor(ctr.e(1)) - 20, Math.floor(ctr.e(2)) - 10,
 
                    Math.floor(ctr.e(1)) + 20, Math.floor(ctr.e(2)) + 10)
 

	
 
    @dirty = false
 

	
 
  drawConnector: (ctr, target) ->
 
    @ctx.strokeStyle = '#aaa'
 
    @ctx.lineWidth = 2
 
    @ctx.beginPath()
 
    _line(@ctx, ctr, target)
 
    @ctx.stroke()
 
    
 
  drawAdjuster: (label, x1, y1, x2, y2) ->
 
    radius = 8
 

	
 
    @ctx.shadowColor = 'black'
 
    @ctx.shadowBlur = 15
 
    @ctx.shadowOffsetX = 5
 
    @ctx.shadowOffsetY = 9
 
    
 
    @ctx.fillStyle = 'rgba(255, 255, 0, 0.5)'
 
    @ctx.beginPath()
 
    _roundRect(@ctx, x1, y1, x2, y2, radius)
 
    @ctx.fill()
 
    
 

	
 
    @ctx.shadowColor = 'rgba(0,0,0,0)'
 
        
 
    @ctx.strokeStyle = 'yellow'
 
    @ctx.lineWidth = 3
 
    @ctx.lineWidth = 2
 
    @ctx.setLineDash([3, 3])
 
    @ctx.beginPath()
 
    _roundRect(@ctx, x1, y1, x2, y2, radius)
 
    @ctx.stroke()
 
    @ctx.setLineDash([])
 

	
0 comments (0 inline, 0 general)