mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-21 23:06:38 +00:00
Implement {circle,rectangle} dragging w/ <Ctrl>.
assets/text/hotkeys.txt: updated. assets/text/TODO: updated.
This commit is contained in:
parent
50edb55e0b
commit
fe6b79a2ab
@ -20,10 +20,9 @@
|
||||
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) allow dragging {circle,rect,...} w/ <Ctrl> irrespective of current brush size
|
||||
4) reimplement cursor unmasking w/ simple list of points
|
||||
5) operators: crop, scale, shift, slice
|
||||
6) auto{load,save} & {backup,restore}
|
||||
7) tools: unicode block elements
|
||||
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
|
||||
|
||||
vim:ff=dos tw=0
|
||||
|
@ -20,6 +20,7 @@ Canvas hotkeys:
|
||||
<RMB> Apply current tool with background colour (with exceptions)
|
||||
|
||||
Tool-specific hotkeys:
|
||||
(Circle, rectangle) <Ctrl> <LMB>/<RMB> Initiate circle/rectangle dragging irrespective of brush size
|
||||
(Erase) <RMB> Erase background colour with foreground colour
|
||||
(Fill) <Ctrl> <LMB>/<Space>/<RMB> Fill entire region with foreground/background colour ignoring character cells
|
||||
(Line, object) <LMB>/<Space> Initiate line drawing/selection
|
||||
|
@ -5,16 +5,15 @@
|
||||
#
|
||||
|
||||
from Tool import Tool
|
||||
import wx
|
||||
|
||||
class ToolCircle(Tool):
|
||||
name = "Circle"
|
||||
TS_NONE = 0
|
||||
TS_ORIGIN = 1
|
||||
|
||||
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
||||
brushColours, brushSize, isCursor = list(brushColours), [brushSize[0] * 2, brushSize[1]], not (mouseLeftDown or mouseRightDown)
|
||||
originPoint, radius = (brushSize[0] / 2, brushSize[0] / 2), brushSize[0]
|
||||
if mouseRightDown:
|
||||
brushColours = [brushColours[1], brushColours[0]]
|
||||
cells = []
|
||||
def _drawCircle(self, brushColours, canvas, mapPoint, originPoint, radius):
|
||||
cells, patches = [], []
|
||||
for brushY in range(-radius, radius + 1):
|
||||
cells += [[]]
|
||||
for brushX in range(-radius, radius + 1):
|
||||
@ -22,7 +21,6 @@ class ToolCircle(Tool):
|
||||
cells[-1] += [[mapPoint[i] + int(originPoint[i] + o) for i, o in zip((0, 1,), (brushX, brushY,))]]
|
||||
if cells[-1] == []:
|
||||
del cells[-1]
|
||||
patches = []
|
||||
for numRow in range(len(cells)):
|
||||
for numCol in range(len(cells[numRow])):
|
||||
if ((numRow == 0) or (numRow == (len(cells) - 1))) \
|
||||
@ -43,6 +41,31 @@ class ToolCircle(Tool):
|
||||
else:
|
||||
patch = [*cells[numRow][numCol], brushColours[1], brushColours[1], 0, " "]
|
||||
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]]
|
||||
if self.toolState == self.TS_NONE:
|
||||
originPoint, radius, targetPoint = list(mapPoint), brushSize[0], (brushSize[0] / 2, brushSize[0] / 2,)
|
||||
if (keyModifiers == wx.MOD_CONTROL) and (mouseLeftDown or mouseRightDown):
|
||||
self.brushColours, isCursor, self.originPoint, self.toolState = list(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
|
||||
else:
|
||||
isCursor = True
|
||||
patches = self._drawCircle(brushColours, canvas, originPoint, targetPoint, radius)
|
||||
return True, patches if not isCursor else None, patches if isCursor else None
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args); self.brushColours, self.originPoint, self.toolState = None, None, self.TS_NONE;
|
||||
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||
|
@ -5,32 +5,51 @@
|
||||
#
|
||||
|
||||
from Tool import Tool
|
||||
import wx
|
||||
|
||||
class ToolRect(Tool):
|
||||
name = "Rectangle"
|
||||
TS_NONE = 0
|
||||
TS_ORIGIN = 1
|
||||
|
||||
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
||||
brushColours, brushSize, isCursor, patches = list(brushColours), list(brushSize), not (mouseLeftDown or mouseRightDown), []
|
||||
if mouseRightDown:
|
||||
brushColours = [brushColours[1], brushColours[0]]
|
||||
if brushSize[0] > 1:
|
||||
brushSize[0] *= 2
|
||||
for brushRow in range(brushSize[1]):
|
||||
for brushCol in range(brushSize[0]):
|
||||
if (brushCol in [0, brushSize[0] - 1]) \
|
||||
or (brushRow in [0, brushSize[1] - 1]):
|
||||
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]):
|
||||
patchColours = [brushColours[0]] * 2
|
||||
patch = [mapPoint[0] + brushCol, mapPoint[1] + brushRow, *patchColours, 0, " "]
|
||||
patch = [rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]
|
||||
elif brushColours[1] == -1:
|
||||
if ((mapPoint[0] + brushCol) < canvas.size[0]) \
|
||||
and ((mapPoint[1] + brushRow) < canvas.size[1]):
|
||||
patch = [mapPoint[0] + brushCol, mapPoint[1] + brushRow, *canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol]]
|
||||
if ((rect[0] + brushCol) < canvas.size[0]) \
|
||||
and ((rect[1] + brushRow) < canvas.size[1]):
|
||||
patch = [rect[0] + brushCol, rect[1] + brushRow, *canvas.map[rect[1] + brushRow][rect[0] + brushCol]]
|
||||
else:
|
||||
patch = [mapPoint[0] + brushCol, mapPoint[1] + brushRow, -1, -1, 0, " "]
|
||||
patch = [rect[0] + brushCol, rect[1] + brushRow, -1, -1, 0, " "]
|
||||
else:
|
||||
patchColours = [brushColours[1]] * 2
|
||||
patch = [mapPoint[0] + brushCol, mapPoint[1] + brushRow, *patchColours, 0, " "]
|
||||
patch = [rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]
|
||||
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, patches = list(brushSize), []; brushSize[0] *= 2 if brushSize[0] > 1 else brushSize[0];
|
||||
if self.toolState == self.TS_NONE:
|
||||
if (keyModifiers == wx.MOD_CONTROL) and (mouseLeftDown or mouseRightDown):
|
||||
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)]]
|
||||
elif self.toolState == self.TS_ORIGIN:
|
||||
rect = [*self.originPoint, *mapPoint]
|
||||
if keyModifiers != wx.MOD_CONTROL:
|
||||
brushColours, isCursor, self.brushColours, self.originPoint, self.toolState = self.brushColours, False, None, None, self.TS_NONE
|
||||
else:
|
||||
isCursor = True
|
||||
patches = self._drawRect(brushColours, canvas, rect)
|
||||
return True, patches if not isCursor else None, patches if isCursor else None
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args); self.brushColours, self.originPoint, self.toolState = None, None, self.TS_NONE;
|
||||
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||
|
Loading…
Reference in New Issue
Block a user