     action = @undoStack.pop()
     action.undo()
     @redoStack.push(action)
+    @trigger('undo', {action})
 
   redo: ->
     return unless @redoStack.length
     action = @redoStack.pop()
     @undoStack.push(action)
     action.do()
+    @trigger('redo', {action})
 
   getPixel: (x, y) ->
     p = @drawingCoordsToClientCoords x, y


  saveShape: (shape) ->
    @execute(new LC.AddShapeAction(this, shape))

  pan: (x, y) ->
    # Subtract because we are moving the viewport
    @position.x = @position.x - x
    @position.y = @position.y - y

  zoom: (factor) ->
    oldScale = @scale

      @position.y, @canvas.height, oldScale, @scale)

    @repaint()
    @trigger('zoom', {oldScale: oldScale, newScale: @scale})

  # Repaints the canvas.
  # If dirty is true then all saved shapes are completely redrawn,
