MiRCART{CanvasJournal,Frame,ToolRect}.py: implements variable brush size.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-08 00:25:59 +01:00
parent 54ce9975e2
commit 26937149fb
4 changed files with 23 additions and 10 deletions

View File

@ -221,6 +221,7 @@ class MiRCARTCanvas(wx.Panel):
super().__init__(parent, pos=canvasPos, \
size=[w*h for w,h in zip(canvasSize, cellSize)])
self.SetDoubleBuffered(True)
self.Bind(wx.EVT_CLOSE, self.onClose)
self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseWindowEvent)
self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseWindowEvent)

View File

@ -60,7 +60,10 @@ class MiRCARTCanvasJournal():
self._popTmp(eventDc, tmpDc)
for patch in mapPatch[1]:
absMapPoint = self._relMapPointToAbsMapPoint(patch[0], atPoint)
if mapPatchTmp:
if absMapPoint[0] >= self.parentCanvas.canvasSize[0] \
or absMapPoint[1] >= self.parentCanvas.canvasSize[1]:
continue
elif mapPatchTmp:
self._pushTmp(absMapPoint)
self.parentCanvas.onJournalUpdate(mapPatchTmp, \
absMapPoint, patch, eventDc, tmpDc, atPoint)

View File

@ -340,9 +340,14 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
elif cid == self.CID_DELETE[0]:
pass
elif cid == self.CID_INCRBRUSH[0]:
pass
elif cid == self.CID_DECRBRUSH[0]:
pass
self.panelCanvas.brushSize = \
[a+1 for a in self.panelCanvas.brushSize]
print(self.panelCanvas.brushSize)
elif cid == self.CID_DECRBRUSH[0] \
and self.panelCanvas.brushSize != [0,0]:
self.panelCanvas.brushSize = \
[a-1 for a in self.panelCanvas.brushSize]
print(self.panelCanvas.brushSize)
elif cid == self.CID_SOLID_BRUSH[0]:
pass
elif cid == self.CID_RECT[0]:

View File

@ -33,14 +33,18 @@ class MiRCARTToolRect(MiRCARTTool):
brushColours = brushColours.copy()
if isLeftDown:
brushColours[1] = brushColours[0]
return [[False, [[[0, 0], brushColours, 0, " "]]], \
[True, [[[0, 0], brushColours, 0, " "]]]]
elif isRightDown:
brushColours[0] = brushColours[1]
return [[False, [[[0, 0], brushColours, 0, " "]]], \
[True, [[[0, 0], brushColours, 0, " "]]]]
else:
brushColours[1] = brushColours[0]
return [[True, [[[0, 0], brushColours, 0, " "]]]]
brushPatches = []
for brushRow in range(brushSize[1]):
for brushCol in range(brushSize[0] * 2):
brushPatches.append([[brushCol, brushRow], \
brushColours, 0, " "])
if isLeftDown or isRightDown:
return [[False, brushPatches], [True, brushPatches]]
else:
return [[True, brushPatches]]
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120