def undo(self): """Updates the document as needed when undo() is invoked""" # When called, this is always reversing a previous redo(). # Update the doc and send notifications. assert self._move is None if (self._x, self._y) == (self._x0, self._y0): return layer = self.doc.layer_stack.deepget(self._layer_path) dx = self._x - self._x0 dy = self._y - self._y0 redraw_bboxes = layer.translate(-dx, -dy) self._notify_canvas_observers(redraw_bboxes)
def redo(self): """Updates the document as needed when do()/redo() is invoked""" # The first time this is called, finish up the active move. # Doc has already been updated, and notifications were sent. if self._move is not None: assert self._processing_complete self._move.cleanup() self._move = None return # Any second invocation is always reversing a previous undo(). # Need to do doc updates and send notifications this time. if (self._x, self._y) == (self._x0, self._y0): return layer = self.doc.layer_stack.deepget(self._layer_path) dx = self._x - self._x0 dy = self._y - self._y0 redraw_bboxes = layer.translate(dx, dy) self._notify_canvas_observers(redraw_bboxes)