mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-02 13:56:39 +00:00
0c66f94797
1) {About,Melp?} window: switch to green on black. 2) Assets window: scroll assets list on selected item update w/ <Cursor> or on deletion. 3) Canvas window: change default brush colours to [3, -1]. 4) Canvas window: copy canvas cells given transparent cells from tools. 5) Canvas window: don't disable {re,un}do during object tool usage. 6) Canvas window: don't hide cursor during {re,un}do. 7) Canvas window: draw new cells using current brush background colour on resize. 8) Canvas window: fix memory leak on cell size updating. 9) Text tool: process [\r\n] in text pasted from clipboard. assets/audio/roar{vap0r[1-8],viking[1-5]}.wav: added. assets/text/README.txt: updated. assets/tools/AnsiToMiRCART.py: added (for spoke.) assets/tools/deploy-python.sh: updated.
48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# ToolRect.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
from Tool import Tool
|
|
import wx
|
|
|
|
class ToolRect(Tool):
|
|
name = "Rectangle"
|
|
TS_NONE = 0
|
|
TS_ORIGIN = 1
|
|
|
|
def _drawRect(self, brushColours, canvas, rect):
|
|
patches = []
|
|
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
|
|
else:
|
|
patchColours = [brushColours[1]] * 2
|
|
patches += [[rect[0] + brushCol, rect[1] + brushRow, *patchColours, 0, " "]]
|
|
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)] if brushSize[0] > 1 else mapPoint)]
|
|
elif self.toolState == self.TS_ORIGIN:
|
|
rect = [*self.originPoint, *mapPoint]
|
|
if not (mouseLeftDown or mouseRightDown):
|
|
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
|