Changeset - 9723a5ab27d6
[Not reviewed]
default
0 1 0
Drew Perttula - 7 years ago 2018-05-07 00:38:33
drewp@bigasterisk.com
fight coffeescript on how to get ctor called
Ignore-this: b74e7e5547fb234716862e5dfa4e2885
1 file changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjustable.coffee
Show inline comments
 
@@ -8,12 +8,15 @@ class Adjustable
 
  # The way dragging should work is that you start in the yellow *adj
 
  # widget*, wherever it is, but your drag is moving the *target*. The
 
  # adj will travel around too, but it may do extra moves to not bump
 
  # into stuff or to get out from under your finger.
 

	
 
  constructor: (@config) ->
 
    @ctor2()
 

	
 
  ctor2: () ->
 
    # config has:
 
    #   getTarget -> vec2 of current target position
 
    #   getSuggestedTargetOffset -> vec2 pixel offset from target
 
    #   emptyBox -> true if you want no value display
 
    
 
    # updated later by layout algoritm
 
@@ -72,13 +75,14 @@ class Adjustable
 
class window.AdjustableFloatObservable extends Adjustable
 
  constructor: (@config) ->
 
    # config also has:
 
    #   observable -> ko.observable we will read and write
 
    #   getValueForPos(pos) -> what should we set to if the user
 
    #                          moves target to this coord?
 
    super(@config)
 
    super()
 
    @ctor2()
 

	
 
  _getValue: () ->
 
    @config.observable()
 
    
 
  continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start.
 
@@ -99,14 +103,14 @@ class window.AdjustableFloatObject exten
 
    #   graph
 
    #   subj
 
    #   pred
 
    #   ctx
 
    #   getTargetPosForValue(value) -> getTarget result for value
 
    #   getValueForPos
 

	
 
    super(@config)
 
    super()
 
    @ctor2()
 
    if not @config.ctx?
 
      throw new Error("missing ctx")
 
    @config.graph.runHandler(@_syncValue.bind(@), "adj sync #{@config.subj}")
 

	
 
  _syncValue: () ->
 
    @_currentValue = @config.graph.floatValue(@config.subj, @config.pred)
 
@@ -133,18 +137,19 @@ class window.AdjustableFloatObject exten
 
    @config.graph.patchObject(@config.subj, @config.pred,
 
                              @config.graph.LiteralRoundedFloat(newValue),
 
                              @config.ctx)
 
                              
 
class window.AdjustableFade extends Adjustable
 
  constructor: (@yForV, @i0, @i1, @note, offset, ctx) ->
 
    super()
 
    @config = {
 
      getSuggestedTargetOffset: -> offset
 
      getTarget: @getTarget.bind(@)
 
      ctx: ctx
 
    }
 
    super(@config)
 
    @ctor2()
 

	
 
  getTarget: ->
 
    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
 
    $V([@note.zoomInX(mid.e(1)), @yForV(mid.e(2))])
 

	
 
  _getValue: ->
0 comments (0 inline, 0 general)