libcanvas/CanvasJournal.py:{begin,end,updateCurrentDeltas}(): {insert,delete,append} at patchesUndoLevel.

libgui/GuiWindow.py:{onEnterWindow,__init__}(): bind wx.EVT_ENTER_WINDOW.
libroar/RoarCanvasWindow.py:applyTool(): only call tool.onMouseEvent() if mouse has moved to another cell since the last dirtying call & update lastDirtyCell.
libroar/RoarCanvasWindow.py:{onEnterWindow,onLeaveWindow,__init__}(): reset lastDirtyCell.
libroar/RoarCanvasWindow.py:__init__():
assets/text/TODO: updated.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-12 16:24:53 +02:00
parent b6c063c5d3
commit 6e05238efa
4 changed files with 38 additions and 27 deletions

View File

@ -4,20 +4,18 @@
4) Open and toggle a reference image in the background 4) Open and toggle a reference image in the background
5) Client-Server or Peer-to-Peer realtime collaboration 5) Client-Server or Peer-to-Peer realtime collaboration
6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.) 6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
7) Hotkey & graphical interfaces to {composed,parametrised} tools 7) Incremental auto{load,save} & {backup,restore} (needs Settings window)
8) Incremental auto{load,save} & {backup,restore} (needs Settings window) 8) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...)
9) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...) 9) Composition, parametrisation & keying of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools
10) Composition and parametrisation of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools; unit tools: 10) GUI: a) switch to GTK b) replace logo w/ canvas panel in About dialogue c) {copy,cut,insert from,paste}, {edit asset in new canvas,import from canvas}
a) geometric primitives (arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star)
b) regions (crop, duplicate, erase, fill, invert, measure, pick, rotate, scale, select, shift, slice, tile, translate) High-priority list:
c) text (edit, Unicode sets) 1) geometric primitives: arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star
11) GUI: 2) region filters: crop, duplicate, erase, fill, invert, measure, pick, rotate, scale, select, shift, slice, tile, translate
a) {copy,cut,insert from,paste}, {de,in}crease cell size 3) text tool: a) allow navigating w/ cursor keys b) Unicode set key & GUI w/ MRU
b) replace logo w/ canvas panel in About dialogue 4) fix outstanding {re,un}do bugs
c) switch from wxPython to GTK 5) GUI: {de,in}crease cell size
d) edit asset in new canvas 6) GUI: MRU {directories,files}
e) MRU {directories,files} 7) cleanup & refactor
f) ruler
12) fix outstanding {re,un}do bugs
vim:ff=dos tw=0 vim:ff=dos tw=0

View File

@ -7,12 +7,12 @@
class CanvasJournal(): class CanvasJournal():
# {{{ begin(self) # {{{ begin(self)
def begin(self): def begin(self):
deltaItem = [[], []]; self.patchesUndo.insert(0, deltaItem); deltaItem = [[], []]; self.patchesUndo.insert(self.patchesUndoLevel, deltaItem);
# }}} # }}}
# {{{ end(self) # {{{ end(self)
def end(self): def end(self):
if self.patchesUndo[0] == [[], []]: if self.patchesUndo[self.patchesUndoLevel] == [[], []]:
del self.patchesUndo[0] del self.patchesUndo[self.patchesUndoLevel]
# }}} # }}}
# {{{ popCursor(self) # {{{ popCursor(self)
def popCursor(self): def popCursor(self):
@ -56,7 +56,8 @@ class CanvasJournal():
# }}} # }}}
# {{{ updateCurrentDeltas(self, redoPatches, undoPatches) # {{{ updateCurrentDeltas(self, redoPatches, undoPatches)
def updateCurrentDeltas(self, redoPatches, undoPatches): def updateCurrentDeltas(self, redoPatches, undoPatches):
self.patchesUndo[0][0].append(undoPatches); self.patchesUndo[0][1].append(redoPatches); self.patchesUndo[self.patchesUndoLevel][0].append(undoPatches)
self.patchesUndo[self.patchesUndoLevel][1].append(redoPatches)
# }}} # }}}
# {{{ __del__(self): destructor method # {{{ __del__(self): destructor method

View File

@ -21,6 +21,10 @@ class GuiWindow(wx.ScrolledWindow):
def onClose(self, event): def onClose(self, event):
self.Destroy() self.Destroy()
# }}} # }}}
# {{{ onEnterWindow(self, event)
def onEnterWindow(self, event):
event.Skip()
# }}}
# {{{ onKeyboardInput(self, event) # {{{ onKeyboardInput(self, event)
def onKeyboardInput(self, event): def onKeyboardInput(self, event):
return False return False
@ -60,10 +64,10 @@ class GuiWindow(wx.ScrolledWindow):
super().__init__(parent, pos=pos, size=size, style=style) super().__init__(parent, pos=pos, size=size, style=style)
self.pos, self.scrollFlag, self.scrollStep, self.size = pos, False, scrollStep, size self.pos, self.scrollFlag, self.scrollStep, self.size = pos, False, scrollStep, size
for eventType, f in ( for eventType, f in (
(wx.EVT_CHAR, self.onKeyboardInput), (wx.EVT_CLOSE, self.onClose), (wx.EVT_LEAVE_WINDOW, self.onLeaveWindow), (wx.EVT_CHAR, self.onKeyboardInput), (wx.EVT_CLOSE, self.onClose), (wx.EVT_ENTER_WINDOW, self.onEnterWindow),
(wx.EVT_LEFT_DOWN, self.onMouseInput), (wx.EVT_MOTION, self.onMouseInput), (wx.EVT_PAINT, self.onPaint), (wx.EVT_LEAVE_WINDOW, self.onLeaveWindow), (wx.EVT_LEFT_DOWN, self.onMouseInput), (wx.EVT_MOTION, self.onMouseInput),
(wx.EVT_RIGHT_DOWN, self.onMouseInput), (wx.EVT_SCROLLWIN_LINEDOWN, self.onScroll), (wx.EVT_SCROLLWIN_LINEUP, self.onScroll), (wx.EVT_PAINT, self.onPaint), (wx.EVT_RIGHT_DOWN, self.onMouseInput), (wx.EVT_SCROLLWIN_LINEDOWN, self.onScroll),
(wx.EVT_SIZE, self.onSize)): (wx.EVT_SCROLLWIN_LINEUP, self.onScroll), (wx.EVT_SIZE, self.onSize)):
self.Bind(eventType, f) self.Bind(eventType, f)
self.SetScrollRate(*self.scrollStep); self._updateScrollBars(); self.SetScrollRate(*self.scrollStep); self._updateScrollBars();

View File

@ -49,10 +49,13 @@ class RoarCanvasWindow(GuiWindow):
dirty, self.canvas.dirtyCursor, rc = False, False, False dirty, self.canvas.dirtyCursor, rc = False, False, False
self.canvas.journal.begin() self.canvas.journal.begin()
if eventMouse: if eventMouse:
if (mapPoint[0] < self.canvas.size[0]) \ if ((mapPoint[0] < self.canvas.size[0]) \
and (mapPoint[1] < self.canvas.size[1]): and (mapPoint[1] < self.canvas.size[1])) \
self.brushPos = mapPoint and ((self.dirtyLastCell == None) or (self.dirtyLastCell != mapPoint)):
self.brushPos = list(mapPoint)
rc, dirty = tool.onMouseEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect) rc, dirty = tool.onMouseEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
if dirty:
self.dirtyLastCell = list(mapPoint)
else: else:
rc, dirty = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyChar, keyModifiers, self.brushPos, viewRect) rc, dirty = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyChar, keyModifiers, self.brushPos, viewRect)
if dirty: if dirty:
@ -122,10 +125,15 @@ class RoarCanvasWindow(GuiWindow):
if not self.applyTool(eventDc, False, keyChar, keyModifiers, None, None, None, None, self.commands.currentTool, viewRect): if not self.applyTool(eventDc, False, keyChar, keyModifiers, None, None, None, None, self.commands.currentTool, viewRect):
event.Skip() event.Skip()
# }}} # }}}
# {{{ onEnterWindow(self, event)
def onEnterWindow(self, event):
self.dirtyLastCell = None
# }}}
# {{{ onLeaveWindow(self, event) # {{{ onLeaveWindow(self, event)
def onLeaveWindow(self, event): def onLeaveWindow(self, event):
eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, self.GetViewStart()) eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, self.GetViewStart())
self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc, self.GetViewStart()) self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc, self.GetViewStart())
self.dirtyLastCell = None
# }}} # }}}
# {{{ onMouseInput(self, event) # {{{ onMouseInput(self, event)
def onMouseInput(self, event): def onMouseInput(self, event):
@ -154,7 +162,7 @@ class RoarCanvasWindow(GuiWindow):
def __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size): def __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size):
super().__init__(parent, pos, scrollStep, [w * h for w, h in zip(cellSize, size)]) super().__init__(parent, pos, scrollStep, [w * h for w, h in zip(cellSize, size)])
self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame
self.brushColours, self.brushPos, self.brushSize, self.dirty = [4, 1], [0, 0], [1, 1], False self.brushColours, self.brushPos, self.brushSize, self.dirty, self.dirtyLastCell = [4, 1], [0, 0], [1, 1], False, None
self.dropTarget = RoarCanvasWindowDropTarget(self) self.dropTarget = RoarCanvasWindowDropTarget(self)
self.SetDropTarget(self.dropTarget) self.SetDropTarget(self.dropTarget)