Changeset - 46d1c0f0a5ce
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 7 years ago 2018-06-08 11:50:13
drewp@bigasterisk.com
attempted redraw fixes, but the real problem is in autodeps
Ignore-this: 96cc361f1951d165131d46b8173b6685
3 files changed with 12 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjustable.coffee
Show inline comments
 
@@ -101,26 +101,27 @@ class window.AdjustableFloatObject exten
 
  constructor: (@config) ->
 
    # config also has:
 
    #   graph
 
    #   subj
 
    #   pred
 
    #   ctx
 
    #   getTargetPosForValue(value) -> getTarget result for value
 
    #   getValueForPos
 
    super()
 
    @ctor2()
 
    if not @config.ctx?
 
      throw new Error("missing ctx")
 
    # this seems to not fire enough.
 
    @config.graph.runHandler(@_syncValue.bind(@),
 
                             "adj sync #{@config.subj.value}")
 
                             "adj sync #{@config.subj.value} #{@config.pred.value}")
 

	
 
  _syncValue: () ->
 
    @_currentValue = @config.graph.floatValue(@config.subj, @config.pred)
 
    @_onChange() if @_onChange
 

	
 
  _getValue: () ->
 
    # this is a big speedup- callers use _getValue about 4x as much as
 
    # the graph changes and graph.floatValue is slow
 
    @_currentValue
 

	
 
  getTarget: () ->
 
    @config.getTargetPosForValue(@_getValue())
 
@@ -129,24 +130,25 @@ class window.AdjustableFloatObject exten
 
    # only works on one subscription at a time
 
    throw new Error('multi subscribe not implemented') if @_onChange
 
    @_onChange = onChange
 

	
 
  continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start
 
    super(pos)
 
    newValue = @config.getValueForPos(@_editorCoordinates())
 

	
 
    @config.graph.patchObject(@config.subj, @config.pred,
 
                              @config.graph.LiteralRoundedFloat(newValue),
 
                              @config.ctx)
 
    #@_syncValue()
 

	
 
class window.AdjustableFade extends Adjustable
 
  constructor: (@yForV, @zoomInX, @i0, @i1, @note, offset, ctx) ->
 
    super()
 
    @config = {
 
      getSuggestedTargetOffset: -> offset
 
      getTarget: @getTarget.bind(@)
 
      ctx: ctx
 
    }
 
    @ctor2()
 

	
 
  getTarget: ->
light9/web/timeline/adjusters.coffee
Show inline comments
 
@@ -39,47 +39,49 @@ coffeeElementSetup(class AdjustersCanvas
 
      if adj
 
        ev.stopPropagation()
 
        @currentDrag = {start: start, adj: adj}
 
        adj.startDrag()
 

	
 
  onMove: (ev) ->
 
    pos = @_mousePos(ev)
 
    if @currentDrag
 
      @hoveringNear = null
 
      @currentDrag.cur = pos
 
      @currentDrag.adj.continueDrag(
 
        @currentDrag.cur.subtract(@currentDrag.start))
 
      @redraw()
 
    else
 
      near = @_adjAtPoint(pos)
 
      if @hoveringNear != near
 
        @hoveringNear = near
 
        @redraw()
 

	
 
  onUp: (ev) ->
 
    return unless @currentDrag
 
    @currentDrag.adj.endDrag()
 
    @currentDrag = null
 
    
 
  _setAdjuster: (adjId, makeAdjustable) ->
 
    # callers register/unregister the Adjustables they want us to make
 
    # adjuster elements for. Caller invents adjId.  makeAdjustable is
 
    # a function returning the Adjustable or it is null to clear any
 
    # adjusters with this id.
 
    if not @adjs[adjId] or not makeAdjustable?
 
      if not makeAdjustable?
 
    if not makeAdjustable?
 
      if @adjs[adjId]
 
        delete @adjs[adjId]
 
      else
 
        adj = makeAdjustable()
 
        @adjs[adjId] = adj
 
        adj.id = adjId
 
    else
 
      # this might be able to reuse an existing one a bit
 
      adj = makeAdjustable()
 
      @adjs[adjId] = adj
 
      adj.id = adjId
 

	
 
    @redraw()
 

	
 
    window.debug_adjsCount = Object.keys(@adjs).length
 

	
 
  updateAllCoords: ->
 
    @redraw()
 

	
 
  _adjAtPoint: (pt) ->
 
    nearest = @qt.find(pt.e(1), pt.e(2))
 
    if not nearest? or nearest.distanceFrom(pt) > maxDist
 
      return null
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -528,24 +528,25 @@ class Note
 
      @_traceBorder(params.screenPts, 12, 0x888888)
 
    if params.selected
 
      @_traceBorder(params.screenPts, 6, 0xff2900)
 

	
 
    shape = new PIXI.Polygon(params.screenPts)
 
    @graphics.beginFill(@_noteColor(params.effect), .313)
 
    @graphics.drawShape(shape)
 
    @graphics.endFill()
 

	
 
    @_traceBorder(params.screenPts, 2, 0xffd900)
 

	
 
    @_addMouseBindings()
 
    
 
                 
 
  update: ->
 
    if not @parentElem.isActiveNote(@uri)
 
      # stale redraw call
 
      return
 

	
 
    if @worldPts
 
      @brickLayout.setNoteSpan(@, @worldPts[0].e(1),
 
                               @worldPts[@worldPts.length - 1].e(1))
 

	
 
    params = @_planDrawing()
 
    @worldPts = params.worldPts
0 comments (0 inline, 0 general)