changeset 1516:b1fed8880ada

shadow on adjs. try to draw faster and wait less for debouncing Ignore-this: b54a18b559c274591c1c2671b9e7287f
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 06 Apr 2017 11:15:56 +0000
parents 37dd11031bcf
children 3bb58b74c9c1
files light9/web/timeline/timeline.coffee
diffstat 1 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/timeline/timeline.coffee	Thu Apr 06 10:04:27 2017 +0000
+++ b/light9/web/timeline/timeline.coffee	Thu Apr 06 11:15:56 2017 +0000
@@ -56,6 +56,8 @@
     @song = @playerSong if @followPlayerSong
 
   ready: ->
+    ko.options.deferUpdates = true;
+
     window.debug_zoomOrLayoutChangedCount = 0
     window.debug_adjUpdateDisplay = 0
     
@@ -89,7 +91,7 @@
     
   attached: ->
     @dia = @$.dia
-    ko.computed(@zoomOrLayoutChanged.bind(@)).extend({rateLimit: 5})
+    ko.computed(@zoomOrLayoutChanged.bind(@))
     ko.computed(@songTimeChanged.bind(@))
 
     @trackMouse()
@@ -743,7 +745,8 @@
   ready: ->
     @adjs = {}
     @ctx = @$.canvas.getContext('2d')
-    
+
+    @dirty = false
     @redraw()
    
   onDown: (ev) ->
@@ -779,9 +782,7 @@
         @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
     
@@ -828,6 +829,10 @@
     @$.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)
@@ -840,7 +845,7 @@
       @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'
@@ -851,13 +856,21 @@
     
   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)