mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-16 12:36:38 +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:
|
Release roadmap:
|
||||||
1) {copy,cut,delete,insert from,paste}, edit asset in new canvas, import from {canvas,object}
|
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
|
2) operators: crop, scale, shift, slice
|
||||||
3) reimplement cursor unmasking w/ simple list of points
|
3) tools: unicode block elements
|
||||||
4) operators: crop, scale, shift, slice
|
4) floating/dockable toolbar https://wxpython.org/Phoenix/docs/html/wx.aui.AuiManager.html
|
||||||
5) auto{load,save} & {backup,restore}
|
5) reimplement cursor unmasking w/ simple list of points
|
||||||
6) tools: unicode block elements
|
6) auto{load,save} & {backup,restore}
|
||||||
|
|
||||||
vim:ff=dos tw=0
|
vim:ff=dos tw=0
|
||||||
|
@ -23,6 +23,9 @@ class ToolCircle(Tool):
|
|||||||
del cells[-1]
|
del cells[-1]
|
||||||
for numRow in range(len(cells)):
|
for numRow in range(len(cells)):
|
||||||
for numCol in range(len(cells[numRow])):
|
for numCol in range(len(cells[numRow])):
|
||||||
|
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))) \
|
if ((numRow == 0) or (numRow == (len(cells) - 1))) \
|
||||||
or ((numCol == 0) or (numCol == (len(cells[numRow]) - 1))):
|
or ((numCol == 0) or (numCol == (len(cells[numRow]) - 1))):
|
||||||
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
patch = [*cells[numRow][numCol], brushColours[0], brushColours[0], 0, " "]
|
||||||
@ -44,22 +47,19 @@ class ToolCircle(Tool):
|
|||||||
return patches
|
return patches
|
||||||
|
|
||||||
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
||||||
brushColours = [brushColours[1], brushColours[0]] if mouseRightDown else brushColours
|
brushColours, brushSize = [brushColours[1], brushColours[0]] if mouseRightDown else brushColours, brushSize[0] * 2
|
||||||
brushSize = [brushSize[0] * 2, brushSize[1]]
|
|
||||||
if self.toolState == self.TS_NONE:
|
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):
|
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:
|
else:
|
||||||
isCursor = not (mouseLeftDown or mouseRightDown)
|
isCursor = not (mouseLeftDown or mouseRightDown)
|
||||||
elif self.toolState == self.TS_ORIGIN:
|
elif self.toolState == self.TS_ORIGIN:
|
||||||
brushColours, originPoint = self.brushColours, self.originPoint
|
|
||||||
if mapPoint[0] > self.originPoint[0]:
|
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,)
|
brushSize += (mapPoint[0] - self.originPoint[0]); brushSize = brushSize + (brushSize % 2);
|
||||||
else:
|
brushColours, originPoint, radius, targetPoint = self.brushColours, self.originPoint, brushSize, (brushSize / 2,) * 2
|
||||||
radius, targetPoint = brushSize[0], (brushSize[0] / 2, brushSize[0] / 2,)
|
if not (mouseLeftDown or mouseRightDown):
|
||||||
if keyModifiers != wx.MOD_CONTROL:
|
self.brushColours, isCursor, self.originPoint, self.toolState = None, False, None, self.TS_NONE
|
||||||
isCursor, self.brushColours, self.originPoint, self.toolState = False, None, None, self.TS_NONE
|
|
||||||
else:
|
else:
|
||||||
isCursor = True
|
isCursor = True
|
||||||
patches = self._drawCircle(brushColours, canvas, originPoint, targetPoint, radius)
|
patches = self._drawCircle(brushColours, canvas, originPoint, targetPoint, radius)
|
||||||
|
@ -53,7 +53,7 @@ class ToolLine(Tool):
|
|||||||
if self.toolState == self.TS_NONE:
|
if self.toolState == self.TS_NONE:
|
||||||
if mouseLeftDown or mouseRightDown:
|
if mouseLeftDown or mouseRightDown:
|
||||||
self.toolOriginPoint, self.toolState = list(mapPoint), self.TS_ORIGIN
|
self.toolOriginPoint, self.toolState = list(mapPoint), self.TS_ORIGIN
|
||||||
patches, rc = [], True
|
isCursor, patches, rc = True, [], True
|
||||||
for brushCol in range(brushSize[0]):
|
for brushCol in range(brushSize[0]):
|
||||||
if ((mapPoint[0] + brushCol) < canvas.size[0]) \
|
if ((mapPoint[0] + brushCol) < canvas.size[0]) \
|
||||||
and (mapPoint[1] < canvas.size[1]):
|
and (mapPoint[1] < canvas.size[1]):
|
||||||
|
@ -14,9 +14,9 @@ class ToolRect(Tool):
|
|||||||
|
|
||||||
def _drawRect(self, brushColours, canvas, rect):
|
def _drawRect(self, brushColours, canvas, rect):
|
||||||
patches = []
|
patches = []
|
||||||
for brushRow in range(rect[3] - rect[1]):
|
for brushRow in range((rect[3] - rect[1]) + 1):
|
||||||
for brushCol in range(rect[2] - rect[0]):
|
for brushCol in range((rect[2] - rect[0]) + 1):
|
||||||
if (brushCol in [0, (rect[2] - rect[0]) - 1]) or (brushRow in [0, (rect[3] - rect[1]) - 1]):
|
if (brushCol in [0, (rect[2] - rect[0])]) or (brushRow in [0, (rect[3] - rect[1])]):
|
||||||
patchColours = [brushColours[0]] * 2
|
patchColours = [brushColours[0]] * 2
|
||||||
patch = [rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]
|
patch = [rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]
|
||||||
elif brushColours[1] == -1:
|
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
|
self.brushColours, isCursor, self.originPoint, self.toolState = list(brushColours), True, list(mapPoint), self.TS_ORIGIN
|
||||||
else:
|
else:
|
||||||
isCursor = not (mouseLeftDown or mouseRightDown)
|
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:
|
elif self.toolState == self.TS_ORIGIN:
|
||||||
rect = [*self.originPoint, *mapPoint]
|
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
|
brushColours, isCursor, self.brushColours, self.originPoint, self.toolState = self.brushColours, False, None, None, self.TS_NONE
|
||||||
else:
|
else:
|
||||||
isCursor = True
|
isCursor = True
|
||||||
|
Loading…
Reference in New Issue
Block a user