libcanvas/Canvas.py:dispatchPatchSingle(): cloned from dispatchPatch().

lib{canvas/Canvas{,Journal},gui/GuiCanvasPanel}.py: replace dirtyJournal & pushDeltas() w/ explicit {begin,end}().
libgui/GuiCanvasPanel.py:applyTool(): updated.
libgui/GuiCanvasPanel.py:dispatchPatchSingle(): cloned from dispatchPatch().
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py:on{Mouse,Keyboard}Event(): return rc, dirty.
libtools/ToolSelect{Clone,Move}.py:onSelectEvent(): return rc, dirty.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-09 18:43:33 +02:00
parent b3f587fc73
commit 0fe6899d05
12 changed files with 99 additions and 62 deletions

View File

@ -16,8 +16,21 @@ class Canvas():
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True)
def dispatchPatch(self, isCursor, patch, commitUndo=True):
if (patch[0] >= self.size[0]) \
or (patch[1] >= self.size[1]):
if (patch[0] >= self.size[0]) or (patch[1] >= self.size[1]):
return False
else:
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
if isCursor:
self.journal.pushCursor(patchDelta)
else:
if commitUndo:
self.journal.begin(); self.journal.updateCurrentDeltas(patch, patchDelta); self.journal.end();
self._commitPatch(patch)
return True
# }}}
# {{{ dispatchPatchSingle(self, isCursor, patch, commitUndo=True)
def dispatchPatchSingle(self, isCursor, patch, commitUndo=True):
if (patch[0] >= self.size[0]) or (patch[1] >= self.size[1]):
return False
else:
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
@ -25,8 +38,6 @@ class Canvas():
self.journal.pushCursor(patchDelta)
else:
if commitUndo:
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas(patch, patchDelta)
self._commitPatch(patch)
return True
@ -34,7 +45,6 @@ class Canvas():
# {{{ resize(self, newSize, commitUndo=True)
def resize(self, newSize, commitUndo=True):
if newSize != self.size:
self.dirtyJournal = False
if self.map == None:
self.map, oldSize = [], [0, 0]
else:
@ -42,16 +52,13 @@ class Canvas():
deltaSize = [b - a for a, b in zip(oldSize, newSize)]
self.journal.resetCursor()
if commitUndo:
self.journal.begin()
undoPatches, redoPatches = ["resize", *oldSize], ["resize", *newSize]
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas(redoPatches, undoPatches)
if deltaSize[0] < 0:
for numRow in range(oldSize[1]):
if commitUndo:
for numCol in range((oldSize[0] + deltaSize[0]), oldSize[0]):
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas(None, [numCol, numRow, *self.map[numRow][numCol]])
del self.map[numRow][-1:(deltaSize[0]-1):-1]
else:
@ -59,16 +66,12 @@ class Canvas():
self.map[numRow].extend([[1, 1, 0, " "]] * deltaSize[0])
for numNewCol in range(oldSize[0], newSize[0]):
if commitUndo:
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas([numNewCol, numRow, 1, 1, 0, " "], None)
self.dispatchPatch(False, [numNewCol, numRow, 1, 1, 0, " "], False)
if deltaSize[1] < 0:
if commitUndo:
for numRow in range((oldSize[1] + deltaSize[1]), oldSize[1]):
for numCol in range(oldSize[0] + deltaSize[0]):
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas(None, [numCol, numRow, *self.map[numRow][numCol]])
del self.map[-1:(deltaSize[1]-1):-1]
else:
@ -76,11 +79,11 @@ class Canvas():
self.map.extend([[[1, 1, 0, " "]] * newSize[0]])
for numNewCol in range(newSize[0]):
if commitUndo:
if not self.dirtyJournal:
self.journal.pushDeltas([], []); self.dirtyJournal = True;
self.journal.updateCurrentDeltas([numNewCol, numNewRow, 1, 1, 0, " "], None)
self.dispatchPatch(False, [numNewCol, numNewRow, 1, 1, 0, " "], False)
self.size = newSize
if commitUndo:
self.journal.end()
return True
else:
return False
@ -98,7 +101,7 @@ class Canvas():
#
# __init__(self, size): initialisation method
def __init__(self, size):
self.dirtyJournal, self.dirtyCursor, self.map, self.size = False, False, None, size
self.dirtyCursor, self.map, self.size = False, None, size
self.exportStore, self.importStore, self.journal = CanvasExportStore(), CanvasImportStore(), CanvasJournal()
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -5,6 +5,17 @@
#
class CanvasJournal():
# {{{ begin(self)
def begin(self):
if self.patchesUndoLevel > 0:
del self.patchesUndo[0:self.patchesUndoLevel]; self.patchesUndoLevel = 0;
deltaItem = [[], []]; self.patchesUndo.insert(0, deltaItem);
# }}}
# {{{ end(self)
def end(self):
if self.patchesUndo[0] == [[], []]:
del self.patchesUndo[0]
# }}}
# {{{ popCursor(self)
def popCursor(self):
if len(self.patchesCursor):
@ -33,13 +44,6 @@ class CanvasJournal():
def pushCursor(self, patches):
self.patchesCursor.append(patches)
# }}}
# {{{ pushDeltas(self, redoPatches, undoPatches)
def pushDeltas(self, redoPatches, undoPatches):
if self.patchesUndoLevel > 0:
del self.patchesUndo[0:self.patchesUndoLevel]; self.patchesUndoLevel = 0;
deltaItem = [undoPatches, redoPatches]; self.patchesUndo.insert(0, deltaItem);
return deltaItem
# }}}
# {{{ resetCursor(self)
def resetCursor(self):
if self.patchesCursor != None:

View File

@ -30,18 +30,19 @@ class GuiCanvasPanel(wx.ScrolledWindow):
# {{{ applyTool(self, eventDc, eventType, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect)
def applyTool(self, eventDc, eventType, keyChar, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, tool, viewRect):
rc = False
self.canvas.dirtyJournal, self.canvas.dirtyCursor, rc = False, False, False
dirty, self.canvas.dirtyCursor, rc = False, False, False
self.canvas.journal.begin()
if eventType == wx.wxEVT_CHAR:
rc = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.dispatchPatch, eventDc, keyChar, keyModifiers, self.brushPos, viewRect)
rc, dirty = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.dispatchPatchSingle, eventDc, keyChar, keyModifiers, self.brushPos, viewRect)
else:
if (mapPoint[0] < self.canvas.size[0]) \
if (mapPoint[0] < self.canvas.size[0]) \
and (mapPoint[1] < self.canvas.size[1]):
self.brushPos = mapPoint
rc = tool.onMouseEvent(self.brushColours, self.brushSize, self.dispatchPatch, eventDc, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
if self.canvas.dirtyJournal:
rc, dirty = tool.onMouseEvent(self.brushColours, self.brushSize, self.dispatchPatchSingle, eventDc, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
if dirty:
self.dirty = True
self.interface.update(dirty=self.dirty, cellPos=self.brushPos, undoLevel=self.canvas.journal.patchesUndoLevel)
self.canvas.journal.end()
if eventType == wx.wxEVT_MOTION:
self.interface.update(cellPos=mapPoint)
return rc
@ -62,6 +63,11 @@ class GuiCanvasPanel(wx.ScrolledWindow):
if self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True):
self._drawPatch(eventDc, isCursor, patch, viewRect)
# }}}
# {{{ dispatchPatchSingle(self, eventDc, isCursor, patch, viewRect)
def dispatchPatchSingle(self, eventDc, isCursor, patch, viewRect):
if self.canvas.dispatchPatchSingle(isCursor, patch, False if isCursor else True):
self._drawPatch(eventDc, isCursor, patch, viewRect)
# }}}
# {{{ resize(self, newSize, commitUndo=True)
def resize(self, newSize, commitUndo=True):
oldSize = [0, 0] if self.canvas.map == None else self.canvas.size

View File

@ -7,13 +7,13 @@
class Tool():
parentCanvas = None
# {{{ onKeyboardEvent(self, brushColours, brushSize, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect):
# {{{ onKeyboardEvent(self, brushColours, brushSize, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect)
def onKeyboardEvent(self, brushColours, brushSize, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect):
pass
return False, False
# }}}
# {{{ onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
pass
return False, False
# }}}
#

View File

@ -12,7 +12,7 @@ class ToolCircle(Tool):
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
brushColours = brushColours.copy()
brushColours, dirty = brushColours.copy(), False
if mouseLeftDown:
brushColours[1] = brushColours[0]
elif mouseRightDown:
@ -29,9 +29,11 @@ class ToolCircle(Tool):
mapPoint[1] + int(originPoint[1] + brushY), \
*brushColours, 0, " "]
if mouseLeftDown or mouseRightDown:
if not dirty:
dirty = True
dispatchFn(eventDc, False, patch, viewRect); dispatchFn(eventDc, True, patch, viewRect);
else:
dispatchFn(eventDc, True, patch, viewRect)
return True
return True, dirty
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -12,8 +12,7 @@ class ToolFill(Tool):
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
pointStack, pointsDone = [list(mapPoint)], []
testColour = self.parentCanvas.canvas.map[mapPoint[1]][mapPoint[0]][0:2]
dirty, pointsDone, pointStack, testColour, = False, [], [list(mapPoint)], self.parentCanvas.canvas.map[mapPoint[1]][mapPoint[0]][0:2]
if mouseLeftDown or mouseRightDown:
if mouseRightDown:
brushColours = [brushColours[1], brushColours[0]]
@ -23,6 +22,8 @@ class ToolFill(Tool):
if (pointCell[0:2] == testColour) \
or ((pointCell[3] == " ") and (pointCell[1] == testColour[1])):
if not point in pointsDone:
if not dirty:
dirty = True
dispatchFn(eventDc, False, [*point, brushColours[0], brushColours[0], 0, " "], viewRect)
if point[0] > 0:
pointStack.append([point[0] - 1, point[1]])
@ -36,6 +37,6 @@ class ToolFill(Tool):
else:
patch = [mapPoint[0], mapPoint[1], brushColours[0], brushColours[0], 0, " "]
dispatchFn(eventDc, True, patch, viewRect)
return True
return True, dirty
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -13,6 +13,7 @@ class ToolLine(Tool):
# {{{ _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint, viewRect)
def _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint, viewRect):
dirty = False
originPoint, targetPoint = originPoint.copy(), targetPoint.copy()
pointDelta = self._pointDelta(originPoint, targetPoint)
lineXSign = 1 if pointDelta[0] > 0 else -1; lineYSign = 1 if pointDelta[1] > 0 else -1;
@ -32,10 +33,13 @@ class ToolLine(Tool):
if isCursor:
dispatchFn(eventDc, False, patch, viewRect); dispatchFn(eventDc, True, patch, viewRect);
else:
if not dirty:
dirty = True
dispatchFn(eventDc, True, patch, viewRect)
if lineD > 0:
lineD -= pointDelta[0]; lineY += 1;
lineD += pointDelta[1]
return dirty
# }}}
# {{{ _pointDelta(self, a, b)
def _pointDelta(self, a, b):
@ -49,7 +53,7 @@ class ToolLine(Tool):
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
brushColours = brushColours.copy()
brushColours, dirty = brushColours.copy(), False
if mouseLeftDown:
brushColours[1] = brushColours[0]
elif mouseRightDown:
@ -62,12 +66,12 @@ class ToolLine(Tool):
dispatchFn(eventDc, True, [*mapPoint, *brushColours, 0, " "], viewRect)
elif self.toolState == self.TS_ORIGIN:
originPoint, targetPoint = self.toolOriginPoint, list(mapPoint)
self._getLine(self.toolColours, brushSize, dispatchFn, eventDc, mouseLeftDown or mouseRightDown, originPoint, targetPoint, viewRect)
dirty = self._getLine(self.toolColours, brushSize, dispatchFn, eventDc, mouseLeftDown or mouseRightDown, originPoint, targetPoint, viewRect)
if mouseLeftDown or mouseRightDown:
self.toolColours, self.toolOriginPoint, self.toolState = None, None, self.TS_NONE
else:
return False
return True
return False, dirty
return True, dirty
# __init__(self, *args): initialisation method
def __init__(self, *args):

View File

@ -12,7 +12,7 @@ class ToolRect(Tool):
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
brushColours = brushColours.copy()
brushColours, dirty = brushColours.copy(), False
if mouseLeftDown:
brushColours[1] = brushColours[0]
elif mouseRightDown:
@ -26,9 +26,11 @@ class ToolRect(Tool):
for brushCol in range(brushSize[0]):
patch = [mapPoint[0] + brushCol, mapPoint[1] + brushRow, *brushColours, 0, " "]
if mouseLeftDown or mouseRightDown:
if not dirty:
dirty = True
dispatchFn(eventDc, False, patch, viewRect); dispatchFn(eventDc, True, patch, viewRect);
else:
dispatchFn(eventDc, True, patch, viewRect)
return True
return True, dirty
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -22,9 +22,10 @@ class ToolSelect(Tool):
disp, isCursor, newTargetRect = [0, 0], False, selectRect.copy()
else:
disp, isCursor, newTargetRect = [0, 0], True, selectRect.copy()
self.onSelectEvent(disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect, viewRect)
dirty = self.onSelectEvent(disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect, viewRect)
self._drawSelectRect(newTargetRect, dispatchFn, eventDc, viewRect)
self.targetRect = newTargetRect
return dirty
# }}}
# {{{ _drawSelectRect(self, rect, dispatchFn, eventDc, viewRect)
def _drawSelectRect(self, rect, dispatchFn, eventDc, viewRect):
@ -49,6 +50,7 @@ class ToolSelect(Tool):
self.targetRect, self.toolState = [list(mapPoint), []], self.TS_ORIGIN
else:
dispatchFn(eventDc, True, [*mapPoint, *brushColours, 0, " "], viewRect)
return False
# }}}
# {{{ _mouseEventTsOrigin(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def _mouseEventTsOrigin(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
@ -70,47 +72,53 @@ class ToolSelect(Tool):
else:
self.targetRect[1] = list(mapPoint)
self._drawSelectRect(self.targetRect, dispatchFn, eventDc, viewRect)
return False
# }}}
# {{{ _mouseEventTsSelect(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def _mouseEventTsSelect(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
if mouseLeftDown \
and (mapPoint[0] >= (self.targetRect[0][0] - 1)) \
and (mapPoint[0] <= (self.targetRect[1][0] + 1)) \
and (mapPoint[1] >= (self.targetRect[0][1] - 1)) \
dirty = False
if mouseLeftDown \
and (mapPoint[0] >= (self.targetRect[0][0] - 1)) \
and (mapPoint[0] <= (self.targetRect[1][0] + 1)) \
and (mapPoint[1] >= (self.targetRect[0][1] - 1)) \
and (mapPoint[1] <= (self.targetRect[1][1] + 1)):
self.lastAtPoint, self.toolState = list(mapPoint), self.TS_TARGET
elif mouseRightDown:
self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
dirty = self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
self.targetRect, self.toolState = None, self.TS_NONE
else:
self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
dirty = self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
return dirty
# }}}
# {{{ _mouseEventTsTarget(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def _mouseEventTsTarget(self, mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
dirty = False
if mouseLeftDown:
self.toolState = self.TS_TARGET
self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
dirty = self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
elif mouseRightDown:
self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
dirty = self._dispatchSelectEvent(mapPoint, dispatchFn, eventDc, mouseLeftDown, mouseRightDown, self.targetRect, viewRect)
self.targetRect, self.toolState = None, self.TS_NONE
else:
self.toolState = self.TS_SELECT
return dirty
# }}}
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
def onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
dirty = False
if self.toolState == self.TS_NONE:
self._mouseEventTsNone(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
dirty = self._mouseEventTsNone(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
elif self.toolState == self.TS_ORIGIN:
self._mouseEventTsOrigin(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
dirty = self._mouseEventTsOrigin(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
elif self.toolState == self.TS_SELECT:
self._mouseEventTsSelect(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
dirty = self._mouseEventTsSelect(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
elif self.toolState == self.TS_TARGET:
self._mouseEventTsTarget(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
dirty = self._mouseEventTsTarget(mapPoint, brushColours, dispatchFn, eventDc, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
else:
return False
return True
return False, dirty
return True, dirty
#
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect, viewRect)

View File

@ -12,11 +12,13 @@ class ToolSelectClone(ToolSelect):
#
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect, viewRect)
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect, viewRect):
dirty = False
for numRow in range(len(self.toolSelectMap)):
for numCol in range(len(self.toolSelectMap[numRow])):
cellOld = self.toolSelectMap[numRow][numCol]
rectX, rectY = selectRect[0][0] + numCol, selectRect[0][1] + numRow
dirty = False if isCursor else True
dispatchFn(eventDc, isCursor, [rectX + disp[0], rectY + disp[1], *cellOld], viewRect)
return True
return dirty
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -12,6 +12,7 @@ class ToolSelectMove(ToolSelect):
#
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect, viewRect)
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect, viewRect):
dirty = False
for numRow in range(len(self.toolSelectMap)):
for numCol in range(len(self.toolSelectMap[numRow])):
dispatchFn(eventDc, isCursor, [self.srcRect[0] + numCol, self.srcRect[1] + numRow, 1, 1, 0, " "], viewRect)
@ -19,7 +20,8 @@ class ToolSelectMove(ToolSelect):
for numCol in range(len(self.toolSelectMap[numRow])):
cellOld = self.toolSelectMap[numRow][numCol]
rectX, rectY = selectRect[0][0] + numCol, selectRect[0][1] + numRow
dirty = False if isCursor else True
dispatchFn(eventDc, isCursor, [rectX + disp[0], rectY + disp[1], *cellOld], viewRect)
return True
return dirty
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -13,11 +13,14 @@ class ToolText(Tool):
#
# onKeyboardEvent(self, brushColours, brushSize, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect)
def onKeyboardEvent(self, brushColours, brushSize, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect):
dirty = False
if not keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT):
return False
else:
if self.textPos == None:
self.textPos = list(mapPoint)
if not dirty:
dirty = True
dispatchFn(eventDc, False, [*self.textPos, *brushColours, 0, keyChar], viewRect)
if self.textPos[0] < (self.parentCanvas.canvas.size[0] - 1):
self.textPos[0] += 1
@ -25,7 +28,7 @@ class ToolText(Tool):
self.textPos[0] = 0; self.textPos[1] += 1;
else:
self.textPos = [0, 0]
return True
return True, dirty
#
# onMouseEvent(self, brushColours, brushSize, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
@ -33,7 +36,7 @@ class ToolText(Tool):
if mouseLeftDown or mouseRightDown:
self.textPos = list(mapPoint)
dispatchFn(eventDc, True, [*mapPoint, *brushColours, 0, "_"], viewRect)
return True
return True, False
# __init__(self, *args): initialisation method
def __init__(self, *args):