mirror of
https://github.com/lalbornoz/roar.git
synced 2024-12-22 12:26:37 +00:00
Tool bug fixes & usability improvements.
1) Circle, rectangle tool: initiate dragging with <Ctrl>, conclude w/ <[LR]MB> release. 2) Circle tool: fix artifacts and radius inference from brush size. 3) Line tool: fix origin point artifacts. 4) Rectangle tool: correctly determine target point.
This commit is contained in:
parent
fe6b79a2ab
commit
2592fa9ad8
@ -19,10 +19,10 @@
|
||||
|
||||
Release roadmap:
|
||||
1) {copy,cut,delete,insert from,paste}, edit asset in new canvas, import from {canvas,object}
|
||||
2) floating/dockable toolbar https://wxpython.org/Phoenix/docs/html/wx.aui.AuiManager.html
|
||||
3) reimplement cursor unmasking w/ simple list of points
|
||||
4) operators: crop, scale, shift, slice
|
||||
5) auto{load,save} & {backup,restore}
|
||||
6) tools: unicode block elements
|
||||
2) operators: crop, scale, shift, slice
|
||||
3) tools: unicode block elements
|
||||
4) floating/dockable toolbar https://wxpython.org/Phoenix/docs/html/wx.aui.AuiManager.html
|
||||
5) reimplement cursor unmasking w/ simple list of points
|
||||
6) auto{load,save} & {backup,restore}
|
||||
|
||||
vim:ff=dos tw=0
|
||||
|
@ -23,43 +23,43 @@ class ToolCircle(Tool):
|
||||
del cells[-1]
|
||||
for numRow in range(len(cells)):
|
||||
for numCol in range(len(cells[numRow])):
|
||||
if ((numRow == 0) or (numRow == (len(cells) - 1))) \
|
||||
or ((numCol == 0) or (numCol == (len(cells[numRow]) - 1))):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif ((numRow > 0) and (cells[numRow][numCol][0] < cells[numRow - 1][0][0])) \
|
||||
or ((numRow < len(cells)) and (cells[numRow][numCol][0] < cells[numRow + 1][0][0])):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif ((numRow > 0) and (cells[numRow][numCol][0] > cells[numRow - 1][-1][0])) \
|
||||
or ((numRow < len(cells)) and (cells[numRow][numCol][0] > cells[numRow + 1][-1][0])):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif brushColours[1] == -1:
|
||||
if (cells[numRow][numCol][0] < canvas.size[0]) \
|
||||
and (cells[numRow][numCol][1] < canvas.size[1]):
|
||||
patch = [cells[numRow][numCol][0], cells[numRow][numCol][1], *canvas.map[cells[numRow][numCol][1]][cells[numRow][numCol][0]]]
|
||||
point = cells[numRow][numCol]
|
||||
if ((point[0] >= 0) and (point[1] >= 0)) \
|
||||
and (point[0] < canvas.size[0]) and (point[1] < canvas.size[1]):
|
||||
if ((numRow == 0) or (numRow == (len(cells) - 1))) \
|
||||
or ((numCol == 0) or (numCol == (len(cells[numRow]) - 1))):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif ((numRow > 0) and (cells[numRow][numCol][0] < cells[numRow - 1][0][0])) \
|
||||
or ((numRow < len(cells)) and (cells[numRow][numCol][0] < cells[numRow + 1][0][0])):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif ((numRow > 0) and (cells[numRow][numCol][0] > cells[numRow - 1][-1][0])) \
|
||||
or ((numRow < len(cells)) and (cells[numRow][numCol][0] > cells[numRow + 1][-1][0])):
|
||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||
elif brushColours[1] == -1:
|
||||
if (cells[numRow][numCol][0] < canvas.size[0]) \
|
||||
and (cells[numRow][numCol][1] < canvas.size[1]):
|
||||
patch = [cells[numRow][numCol][0], cells[numRow][numCol][1], *canvas.map[cells[numRow][numCol][1]][cells[numRow][numCol][0]]]
|
||||
else:
|
||||
patch = [*cells[numRow][numCol], brushColours[1], brushColours[1], 0, " "]
|
||||
else:
|
||||
patch = [*cells[numRow][numCol], brushColours[1], brushColours[1], 0, " "]
|
||||
else:
|
||||
patch = [*cells[numRow][numCol], brushColours[1], brushColours[1], 0, " "]
|
||||
patches += [patch]
|
||||
patches += [patch]
|
||||
return patches
|
||||
|
||||
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
||||
brushColours = [brushColours[1], brushColours[0]] if mouseRightDown else brushColours
|
||||
brushSize = [brushSize[0] * 2, brushSize[1]]
|
||||
brushColours, brushSize = [brushColours[1], brushColours[0]] if mouseRightDown else brushColours, brushSize[0] * 2
|
||||
if self.toolState == self.TS_NONE:
|
||||
originPoint, radius, targetPoint = list(mapPoint), brushSize[0], (brushSize[0] / 2, brushSize[0] / 2,)
|
||||
originPoint, radius, targetPoint = list(mapPoint), brushSize, (brushSize / 2,) * 2
|
||||
if (keyModifiers == wx.MOD_CONTROL) and (mouseLeftDown or mouseRightDown):
|
||||
self.brushColours, isCursor, self.originPoint, self.toolState = list(brushColours), True, originPoint, self.TS_ORIGIN
|
||||
self.brushColours, isCursor, self.originPoint, self.toolState = brushColours, True, originPoint, self.TS_ORIGIN
|
||||
else:
|
||||
isCursor = not (mouseLeftDown or mouseRightDown)
|
||||
elif self.toolState == self.TS_ORIGIN:
|
||||
brushColours, originPoint = self.brushColours, self.originPoint
|
||||
if mapPoint[0] > self.originPoint[0]:
|
||||
radius, targetPoint = brushSize[0] + (mapPoint[0] - self.originPoint[0]), ((brushSize[0] + (mapPoint[0] - self.originPoint[0])) / 2, (brushSize[0] + (mapPoint[0] - self.originPoint[0])) / 2,)
|
||||
else:
|
||||
radius, targetPoint = brushSize[0], (brushSize[0] / 2, brushSize[0] / 2,)
|
||||
if keyModifiers != wx.MOD_CONTROL:
|
||||
isCursor, self.brushColours, self.originPoint, self.toolState = False, None, None, self.TS_NONE
|
||||
brushSize += (mapPoint[0] - self.originPoint[0]); brushSize = brushSize + (brushSize % 2);
|
||||
brushColours, originPoint, radius, targetPoint = self.brushColours, self.originPoint, brushSize, (brushSize / 2,) * 2
|
||||
if not (mouseLeftDown or mouseRightDown):
|
||||
self.brushColours, isCursor, self.originPoint, self.toolState = None, False, None, self.TS_NONE
|
||||
else:
|
||||
isCursor = True
|
||||
patches = self._drawCircle(brushColours, canvas, originPoint, targetPoint, radius)
|
||||
|
@ -53,7 +53,7 @@ class ToolLine(Tool):
|
||||
if self.toolState == self.TS_NONE:
|
||||
if mouseLeftDown or mouseRightDown:
|
||||
self.toolOriginPoint, self.toolState = list(mapPoint), self.TS_ORIGIN
|
||||
patches, rc = [], True
|
||||
isCursor, patches, rc = True, [], True
|
||||
for brushCol in range(brushSize[0]):
|
||||
if ((mapPoint[0] + brushCol) < canvas.size[0]) \
|
||||
and (mapPoint[1] < canvas.size[1]):
|
||||
|
@ -14,9 +14,9 @@ class ToolRect(Tool):
|
||||
|
||||
def _drawRect(self, brushColours, canvas, rect):
|
||||
patches = []
|
||||
for brushRow in range(rect[3] - rect[1]):
|
||||
for brushCol in range(rect[2] - rect[0]):
|
||||
if (brushCol in [0, (rect[2] - rect[0]) - 1]) or (brushRow in [0, (rect[3] - rect[1]) - 1]):
|
||||
for brushRow in range((rect[3] - rect[1]) + 1):
|
||||
for brushCol in range((rect[2] - rect[0]) + 1):
|
||||
if (brushCol in [0, (rect[2] - rect[0])]) or (brushRow in [0, (rect[3] - rect[1])]):
|
||||
patchColours = [brushColours[0]] * 2
|
||||
patch = [rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]
|
||||
elif brushColours[1] == -1:
|
||||
@ -39,10 +39,10 @@ class ToolRect(Tool):
|
||||
self.brushColours, isCursor, self.originPoint, self.toolState = list(brushColours), True, list(mapPoint), self.TS_ORIGIN
|
||||
else:
|
||||
isCursor = not (mouseLeftDown or mouseRightDown)
|
||||
rect = [*mapPoint, *[a + b for a, b in zip(brushSize, mapPoint)]]
|
||||
rect = [*mapPoint, *([a + b for a, b in zip(brushSize, mapPoint)] if brushSize[0] > 1 else mapPoint)]
|
||||
elif self.toolState == self.TS_ORIGIN:
|
||||
rect = [*self.originPoint, *mapPoint]
|
||||
if keyModifiers != wx.MOD_CONTROL:
|
||||
if not (mouseLeftDown or mouseRightDown):
|
||||
brushColours, isCursor, self.brushColours, self.originPoint, self.toolState = self.brushColours, False, None, None, self.TS_NONE
|
||||
else:
|
||||
isCursor = True
|
||||
|
Loading…
Reference in New Issue
Block a user