mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-18 21:36:38 +00:00
MiRCART{CanvasJournal,Frame,ToolRect}.py: implements variable brush size.
This commit is contained in:
parent
6a4356568b
commit
54adf3a95c
@ -221,6 +221,7 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
|
|
||||||
super().__init__(parent, pos=canvasPos, \
|
super().__init__(parent, pos=canvasPos, \
|
||||||
size=[w*h for w,h in zip(canvasSize, cellSize)])
|
size=[w*h for w,h in zip(canvasSize, cellSize)])
|
||||||
|
self.SetDoubleBuffered(True)
|
||||||
self.Bind(wx.EVT_CLOSE, self.onClose)
|
self.Bind(wx.EVT_CLOSE, self.onClose)
|
||||||
self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseWindowEvent)
|
self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseWindowEvent)
|
||||||
self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseWindowEvent)
|
self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseWindowEvent)
|
||||||
|
@ -60,7 +60,10 @@ class MiRCARTCanvasJournal():
|
|||||||
self._popTmp(eventDc, tmpDc)
|
self._popTmp(eventDc, tmpDc)
|
||||||
for patch in mapPatch[1]:
|
for patch in mapPatch[1]:
|
||||||
absMapPoint = self._relMapPointToAbsMapPoint(patch[0], atPoint)
|
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._pushTmp(absMapPoint)
|
||||||
self.parentCanvas.onJournalUpdate(mapPatchTmp, \
|
self.parentCanvas.onJournalUpdate(mapPatchTmp, \
|
||||||
absMapPoint, patch, eventDc, tmpDc, atPoint)
|
absMapPoint, patch, eventDc, tmpDc, atPoint)
|
||||||
|
@ -340,9 +340,14 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
|||||||
elif cid == self.CID_DELETE[0]:
|
elif cid == self.CID_DELETE[0]:
|
||||||
pass
|
pass
|
||||||
elif cid == self.CID_INCRBRUSH[0]:
|
elif cid == self.CID_INCRBRUSH[0]:
|
||||||
pass
|
self.panelCanvas.brushSize = \
|
||||||
elif cid == self.CID_DECRBRUSH[0]:
|
[a+1 for a in self.panelCanvas.brushSize]
|
||||||
pass
|
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]:
|
elif cid == self.CID_SOLID_BRUSH[0]:
|
||||||
pass
|
pass
|
||||||
elif cid == self.CID_RECT[0]:
|
elif cid == self.CID_RECT[0]:
|
||||||
@ -351,7 +356,7 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
|||||||
pass
|
pass
|
||||||
elif cid == self.CID_LINE[0]:
|
elif cid == self.CID_LINE[0]:
|
||||||
pass
|
pass
|
||||||
elif cid >= self.CID_COLOUR00[0] \
|
elif cid >= self.CID_COLOUR00[0] \
|
||||||
and cid <= self.CID_COLOUR15[0]:
|
and cid <= self.CID_COLOUR15[0]:
|
||||||
numColour = cid - self.CID_COLOUR00[0]
|
numColour = cid - self.CID_COLOUR00[0]
|
||||||
if event.GetEventType() == wx.wxEVT_TOOL:
|
if event.GetEventType() == wx.wxEVT_TOOL:
|
||||||
|
@ -33,14 +33,18 @@ class MiRCARTToolRect(MiRCARTTool):
|
|||||||
brushColours = brushColours.copy()
|
brushColours = brushColours.copy()
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
brushColours[1] = brushColours[0]
|
brushColours[1] = brushColours[0]
|
||||||
return [[False, [[[0, 0], brushColours, 0, " "]]], \
|
|
||||||
[True, [[[0, 0], brushColours, 0, " "]]]]
|
|
||||||
elif isRightDown:
|
elif isRightDown:
|
||||||
brushColours[0] = brushColours[1]
|
brushColours[0] = brushColours[1]
|
||||||
return [[False, [[[0, 0], brushColours, 0, " "]]], \
|
|
||||||
[True, [[[0, 0], brushColours, 0, " "]]]]
|
|
||||||
else:
|
else:
|
||||||
brushColours[1] = brushColours[0]
|
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
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||||
|
Loading…
Reference in New Issue
Block a user