mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 16:56:37 +00:00
f428daa9e0
1) Add format clarification to commands documentation. 2) Allow changing {canvas,brush} size w/ {<Ctrl> <Shift>,<Ctrl>} <Mouse wheel>. 3) Backend: {draw,produce,remove} cursor w/ list of coordinates instead of cells. 4) Update changing rendered cell size hotkey to <Ctrl> <Alt> <Mouse wheel>.
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# CanvasJournal.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
class CanvasJournal():
|
|
def begin(self):
|
|
deltaItem = [[], []]; self.patchesUndo.insert(self.patchesUndoLevel, deltaItem);
|
|
|
|
def end(self):
|
|
if self.patchesUndo[self.patchesUndoLevel] == [[], []]:
|
|
del self.patchesUndo[self.patchesUndoLevel]
|
|
else:
|
|
if self.patchesUndoLevel > 0:
|
|
del self.patchesUndo[:self.patchesUndoLevel]; self.patchesUndoLevel = 0;
|
|
|
|
def popCursor(self):
|
|
if len(self.patchesCursor):
|
|
patchesCursor = self.patchesCursor; self.patchesCursor = [];
|
|
return patchesCursor
|
|
else:
|
|
return []
|
|
|
|
def popRedo(self):
|
|
if self.patchesUndoLevel > 0:
|
|
self.patchesUndoLevel -= 1; patches = self.patchesUndo[self.patchesUndoLevel];
|
|
return patches[1]
|
|
else:
|
|
return []
|
|
|
|
def popUndo(self):
|
|
if self.patchesUndo[self.patchesUndoLevel] != None:
|
|
patches = self.patchesUndo[self.patchesUndoLevel]; self.patchesUndoLevel += 1;
|
|
return patches[0]
|
|
else:
|
|
return []
|
|
|
|
def pushCursor(self, patches):
|
|
self.patchesCursor = patches
|
|
|
|
def resetCursor(self):
|
|
if self.patchesCursor != None:
|
|
self.patchesCursor.clear()
|
|
self.patchesCursor = []
|
|
|
|
def resetUndo(self):
|
|
if self.patchesUndo != None:
|
|
self.patchesUndo.clear()
|
|
self.patchesUndo = [None]; self.patchesUndoLevel = 0;
|
|
|
|
def updateCurrentDeltas(self, redoPatches, undoPatches):
|
|
self.patchesUndo[self.patchesUndoLevel][0].append(undoPatches)
|
|
self.patchesUndo[self.patchesUndoLevel][1].append(redoPatches)
|
|
|
|
def __del__(self):
|
|
self.resetCursor(); self.resetUndo();
|
|
|
|
def __init__(self):
|
|
self.patchesCursor, self.patchesUndo, self. patchesUndoLevel = None, None, None
|
|
self.resetCursor(); self.resetUndo();
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|