mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-25 00:26:38 +00:00
assets/text/ImgurApiKey.py.template, lib{canvas,gui,rtl,tools}/*.py: deXXXify.
This commit is contained in:
parent
6da84c05c5
commit
c77813380a
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ImgurApiKey.py -- XXX
|
# ImgurApiKey.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
# This project is licensed under the terms of the MIT licence.
|
# This project is licensed under the terms of the MIT licence.
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Canvas.py -- XXX
|
# Canvas.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -9,14 +9,12 @@ from CanvasImportStore import CanvasImportStore
|
|||||||
from CanvasJournal import CanvasJournal
|
from CanvasJournal import CanvasJournal
|
||||||
|
|
||||||
class Canvas():
|
class Canvas():
|
||||||
"""XXX"""
|
# {{{ _commitPatch(self, patch)
|
||||||
|
|
||||||
# {{{ _commitPatch(self, patch): XXX
|
|
||||||
def _commitPatch(self, patch):
|
def _commitPatch(self, patch):
|
||||||
self.map[patch[1]][patch[0]] = patch[2:]
|
self.map[patch[1]][patch[0]] = patch[2:]
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True): XXX
|
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True)
|
||||||
def dispatchPatch(self, isCursor, patch, commitUndo=True):
|
def dispatchPatch(self, isCursor, patch, commitUndo=True):
|
||||||
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
|
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
|
||||||
if isCursor:
|
if isCursor:
|
||||||
@ -28,7 +26,7 @@ class Canvas():
|
|||||||
self.journal.updateCurrentDeltas(patch, patchDelta)
|
self.journal.updateCurrentDeltas(patch, patchDelta)
|
||||||
self._commitPatch(patch)
|
self._commitPatch(patch)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resize(self, newSize, commitUndo=True): XXX
|
# {{{ resize(self, newSize, commitUndo=True)
|
||||||
def resize(self, newSize, commitUndo=True):
|
def resize(self, newSize, commitUndo=True):
|
||||||
if newSize != self.size:
|
if newSize != self.size:
|
||||||
self.dirtyJournal = False
|
self.dirtyJournal = False
|
||||||
@ -82,7 +80,7 @@ class Canvas():
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ update(self, newSize, newCanvas=None): XXX
|
# {{{ update(self, newSize, newCanvas=None)
|
||||||
def update(self, newSize, newCanvas=None):
|
def update(self, newSize, newCanvas=None):
|
||||||
for numRow in range(self.size[1]):
|
for numRow in range(self.size[1]):
|
||||||
for numCol in range(self.size[0]):
|
for numCol in range(self.size[0]):
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# CanvasColours.py -- XXX
|
# CanvasColours.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
# {{{ AnsiBgToMiRCARTColours: XXX
|
# {{{ AnsiBgToMiRCARTColours
|
||||||
AnsiBgToMiRCARTColours = {
|
AnsiBgToMiRCARTColours = {
|
||||||
107: 0, # Bright White
|
107: 0, # Bright White
|
||||||
40: 1, # Black
|
40: 1, # Black
|
||||||
@ -24,7 +24,7 @@ AnsiBgToMiRCARTColours = {
|
|||||||
47: 15, # Light Grey
|
47: 15, # Light Grey
|
||||||
};
|
};
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ AnsiFgBoldToMiRCARTColours: XXX
|
# {{{ AnsiFgBoldToMiRCARTColours
|
||||||
AnsiFgBoldToMiRCARTColours = {
|
AnsiFgBoldToMiRCARTColours = {
|
||||||
97: 0, # Bright White
|
97: 0, # Bright White
|
||||||
30: 14, # Grey
|
30: 14, # Grey
|
||||||
@ -44,7 +44,7 @@ AnsiFgBoldToMiRCARTColours = {
|
|||||||
37: 0, # Bright White
|
37: 0, # Bright White
|
||||||
};
|
};
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ AnsiFgToMiRCARTColours: XXX
|
# {{{ AnsiFgToMiRCARTColours
|
||||||
AnsiFgToMiRCARTColours = {
|
AnsiFgToMiRCARTColours = {
|
||||||
97: 0, # Bright White
|
97: 0, # Bright White
|
||||||
30: 1, # Black
|
30: 1, # Black
|
||||||
@ -104,7 +104,7 @@ ColourMapNormal = [
|
|||||||
[187, 187, 187], # Light Grey
|
[187, 187, 187], # Light Grey
|
||||||
]
|
]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ MiRCARTToAnsiColours: XXX
|
# {{{ MiRCARTToAnsiColours
|
||||||
MiRCARTToAnsiColours = [
|
MiRCARTToAnsiColours = [
|
||||||
97, # Bright White
|
97, # Bright White
|
||||||
30, # Black
|
30, # Black
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# CanvasExportStore.py -- XXX
|
# CanvasExportStore.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -20,7 +20,6 @@ except ImportError:
|
|||||||
haveUrllib = False
|
haveUrllib = False
|
||||||
|
|
||||||
class CanvasExportStore():
|
class CanvasExportStore():
|
||||||
"""XXX"""
|
|
||||||
# {{{ _CellState(): Cell state
|
# {{{ _CellState(): Cell state
|
||||||
class _CellState():
|
class _CellState():
|
||||||
CS_NONE = 0x00
|
CS_NONE = 0x00
|
||||||
@ -31,7 +30,7 @@ class CanvasExportStore():
|
|||||||
ImgurUploadUrl = "https://api.imgur.com/3/upload.json"
|
ImgurUploadUrl = "https://api.imgur.com/3/upload.json"
|
||||||
PastebinPostUrl = "https://pastebin.com/api/api_post.php"
|
PastebinPostUrl = "https://pastebin.com/api/api_post.php"
|
||||||
|
|
||||||
# {{{ _drawUnderline(self, curPos, fillColour, fontSize, imgDraw): XXX
|
# {{{ _drawUnderline(self, curPos, fillColour, fontSize, imgDraw)
|
||||||
def _drawUnderLine(self, curPos, fillColour, fontSize, imgDraw):
|
def _drawUnderLine(self, curPos, fillColour, fontSize, imgDraw):
|
||||||
imgDraw.line( \
|
imgDraw.line( \
|
||||||
xy=(curPos[0], curPos[1] + (fontSize[1] - 2), \
|
xy=(curPos[0], curPos[1] + (fontSize[1] - 2), \
|
||||||
@ -39,7 +38,7 @@ class CanvasExportStore():
|
|||||||
fill=fillColour)
|
fill=fillColour)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ exportAnsiFile(self, canvasMap, canvasSize, outFile): XXX
|
# {{{ exportAnsiFile(self, canvasMap, canvasSize, outFile)
|
||||||
def exportAnsiFile(self, canvasMap, canvasSize, outFile):
|
def exportAnsiFile(self, canvasMap, canvasSize, outFile):
|
||||||
outBuffer = ""
|
outBuffer = ""
|
||||||
for inCurRow in range(len(canvasMap)):
|
for inCurRow in range(len(canvasMap)):
|
||||||
@ -73,7 +72,7 @@ class CanvasExportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "empty buffer generated")
|
return (False, "empty buffer generated")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportBitmapToImgur(self, apiKey, canvasBitmap, imgName, imgTitle, imgType): XXX
|
# {{{ exportBitmapToImgur(self, apiKey, canvasBitmap, imgName, imgTitle, imgType)
|
||||||
def exportBitmapToImgur(self, apiKey, canvasBitmap, imgName, imgTitle, imgType):
|
def exportBitmapToImgur(self, apiKey, canvasBitmap, imgName, imgTitle, imgType):
|
||||||
tmpPathName = tempfile.mkstemp()
|
tmpPathName = tempfile.mkstemp()
|
||||||
os.close(tmpPathName[0])
|
os.close(tmpPathName[0])
|
||||||
@ -96,11 +95,11 @@ class CanvasExportStore():
|
|||||||
os.remove(tmpPathName[1])
|
os.remove(tmpPathName[1])
|
||||||
return imgurResult
|
return imgurResult
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportBitmapToPngFile(self, canvasBitmap, outPathName, outType): XXX
|
# {{{ exportBitmapToPngFile(self, canvasBitmap, outPathName, outType)
|
||||||
def exportBitmapToPngFile(self, canvasBitmap, outPathName, outType):
|
def exportBitmapToPngFile(self, canvasBitmap, outPathName, outType):
|
||||||
return canvasBitmap.ConvertToImage().SaveFile(outPathName, outType)
|
return canvasBitmap.ConvertToImage().SaveFile(outPathName, outType)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportPastebin(self, apiDevKey, canvasMap, canvasSize, pasteName="", pastePrivate=0): XXX
|
# {{{ exportPastebin(self, apiDevKey, canvasMap, canvasSize, pasteName="", pastePrivate=0)
|
||||||
def exportPastebin(self, apiDevKey, canvasMap, canvasSize, pasteName="", pastePrivate=0):
|
def exportPastebin(self, apiDevKey, canvasMap, canvasSize, pasteName="", pastePrivate=0):
|
||||||
if haveUrllib:
|
if haveUrllib:
|
||||||
outFile = io.StringIO()
|
outFile = io.StringIO()
|
||||||
@ -119,7 +118,7 @@ class CanvasExportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "missing requests and/or urllib3 module(s)")
|
return (False, "missing requests and/or urllib3 module(s)")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportPngFile(self, canvasMap, fontFilePath, fontSize, outPathName): XXX
|
# {{{ exportPngFile(self, canvasMap, fontFilePath, fontSize, outPathName)
|
||||||
def exportPngFile(self, canvasMap, fontFilePath, fontSize, outPathName):
|
def exportPngFile(self, canvasMap, fontFilePath, fontSize, outPathName):
|
||||||
if havePIL:
|
if havePIL:
|
||||||
inSize = (len(canvasMap[0]), len(canvasMap))
|
inSize = (len(canvasMap[0]), len(canvasMap))
|
||||||
@ -163,7 +162,7 @@ class CanvasExportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "missing PIL modules")
|
return (False, "missing PIL modules")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportTextBuffer(self, canvasMap, canvasSize): XXX
|
# {{{ exportTextBuffer(self, canvasMap, canvasSize)
|
||||||
def exportTextBuffer(self, canvasMap, canvasSize):
|
def exportTextBuffer(self, canvasMap, canvasSize):
|
||||||
outBuffer = ""
|
outBuffer = ""
|
||||||
for canvasRow in range(canvasSize[1]):
|
for canvasRow in range(canvasSize[1]):
|
||||||
@ -202,7 +201,7 @@ class CanvasExportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "empty buffer generated")
|
return (False, "empty buffer generated")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ exportTextFile(self, canvasMap, canvasSize, outFile): XXX
|
# {{{ exportTextFile(self, canvasMap, canvasSize, outFile)
|
||||||
def exportTextFile(self, canvasMap, canvasSize, outFile):
|
def exportTextFile(self, canvasMap, canvasSize, outFile):
|
||||||
rc, outBuffer = self.exportTextBuffer(canvasMap, canvasSize)
|
rc, outBuffer = self.exportTextBuffer(canvasMap, canvasSize)
|
||||||
return outFile.write(outBuffer) if rc else (rc, outBuffer)
|
return outFile.write(outBuffer) if rc else (rc, outBuffer)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# CanvasImportStore.py -- XXX
|
# CanvasImportStore.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
# This project is licensed under the terms of the MIT licence.
|
# This project is licensed under the terms of the MIT licence.
|
||||||
#
|
#
|
||||||
@ -9,7 +9,6 @@ from CanvasColours import AnsiBgToMiRCARTColours, AnsiFgToMiRCARTColours, AnsiFg
|
|||||||
import io, os, re, struct, sys
|
import io, os, re, struct, sys
|
||||||
|
|
||||||
class CanvasImportStore():
|
class CanvasImportStore():
|
||||||
"""XXX"""
|
|
||||||
# {{{ _CellState(): Cell state
|
# {{{ _CellState(): Cell state
|
||||||
class _CellState():
|
class _CellState():
|
||||||
CS_NONE = 0x00
|
CS_NONE = 0x00
|
||||||
@ -18,12 +17,12 @@ class CanvasImportStore():
|
|||||||
CS_UNDERLINE = 0x04
|
CS_UNDERLINE = 0x04
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ _flipCellStateBit(self, bit, cellState): XXX
|
# {{{ _flipCellStateBit(self, bit, cellState)
|
||||||
def _flipCellStateBit(self, bit, cellState):
|
def _flipCellStateBit(self, bit, cellState):
|
||||||
return cellState & ~bit if cellState & bit else cellState | bit
|
return cellState & ~bit if cellState & bit else cellState | bit
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ importAnsiBuffer(self, inBuffer, encoding="cp437", width=None): XXX
|
# {{{ importAnsiBuffer(self, inBuffer, encoding="cp437", width=None)
|
||||||
def importAnsiBuffer(self, inBuffer, encoding="cp437", width=None):
|
def importAnsiBuffer(self, inBuffer, encoding="cp437", width=None):
|
||||||
curBg, curBgAnsi, curBoldAnsi, curFg, curFgAnsi = 1, 30, False, 15, 37
|
curBg, curBgAnsi, curBoldAnsi, curFg, curFgAnsi = 1, 30, False, 15, 37
|
||||||
done, outMap, outMaxCols = False, [[]], 0
|
done, outMap, outMaxCols = False, [[]], 0
|
||||||
@ -76,11 +75,11 @@ class CanvasImportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "empty output map")
|
return (False, "empty output map")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ importAnsiFile(self, inPathName, encoding="cp437"): XXX
|
# {{{ importAnsiFile(self, inPathName, encoding="cp437")
|
||||||
def importAnsiFile(self, inPathName, encoding="cp437"):
|
def importAnsiFile(self, inPathName, encoding="cp437"):
|
||||||
return self.importAnsiBuffer(open(inPathName, "rb").read(), encoding)
|
return self.importAnsiBuffer(open(inPathName, "rb").read(), encoding)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ importSauceFile(self, inPathName, encoding="cp437"): XXX
|
# {{{ importSauceFile(self, inPathName, encoding="cp437")
|
||||||
def importSauceFile(self, inPathName, encoding="cp437"):
|
def importSauceFile(self, inPathName, encoding="cp437"):
|
||||||
with open(inPathName, "rb") as inFile:
|
with open(inPathName, "rb") as inFile:
|
||||||
inFileStat = os.stat(inPathName)
|
inFileStat = os.stat(inPathName)
|
||||||
@ -92,7 +91,7 @@ class CanvasImportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "only character based ANSi SAUCE files are supported")
|
return (False, "only character based ANSi SAUCE files are supported")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ importTextBuffer(self, inFile): XXX
|
# {{{ importTextBuffer(self, inFile)
|
||||||
def importTextBuffer(self, inFile):
|
def importTextBuffer(self, inFile):
|
||||||
inLine, outMap, outMaxCols = inFile.readline(), [], 0
|
inLine, outMap, outMaxCols = inFile.readline(), [], 0
|
||||||
while inLine:
|
while inLine:
|
||||||
@ -133,7 +132,7 @@ class CanvasImportStore():
|
|||||||
else:
|
else:
|
||||||
return (False, "empty output map")
|
return (False, "empty output map")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ importTextFile(self, pathName): XXX
|
# {{{ importTextFile(self, pathName)
|
||||||
def importTextFile(self, pathName):
|
def importTextFile(self, pathName):
|
||||||
with open(pathName, "r", encoding="utf-8-sig") as inFile:
|
with open(pathName, "r", encoding="utf-8-sig") as inFile:
|
||||||
return self.importTextBuffer(inFile)
|
return self.importTextBuffer(inFile)
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# CanvasJournal.py -- XXX
|
# CanvasJournal.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
class CanvasJournal():
|
class CanvasJournal():
|
||||||
"""XXX"""
|
# {{{ popCursor(self)
|
||||||
|
|
||||||
# {{{ popCursor(self): XXX
|
|
||||||
def popCursor(self):
|
def popCursor(self):
|
||||||
if len(self.patchesCursor):
|
if len(self.patchesCursor):
|
||||||
patchesCursor = self.patchesCursor; self.patchesCursor = [];
|
patchesCursor = self.patchesCursor; self.patchesCursor = [];
|
||||||
@ -15,7 +13,7 @@ class CanvasJournal():
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ popRedo(self): XXX
|
# {{{ popRedo(self)
|
||||||
def popRedo(self):
|
def popRedo(self):
|
||||||
if self.patchesUndoLevel > 0:
|
if self.patchesUndoLevel > 0:
|
||||||
self.patchesUndoLevel -= 1; patches = self.patchesUndo[self.patchesUndoLevel];
|
self.patchesUndoLevel -= 1; patches = self.patchesUndo[self.patchesUndoLevel];
|
||||||
@ -23,7 +21,7 @@ class CanvasJournal():
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ popUndo(self): XXX
|
# {{{ popUndo(self)
|
||||||
def popUndo(self):
|
def popUndo(self):
|
||||||
if self.patchesUndo[self.patchesUndoLevel] != None:
|
if self.patchesUndo[self.patchesUndoLevel] != None:
|
||||||
patches = self.patchesUndo[self.patchesUndoLevel]; self.patchesUndoLevel += 1;
|
patches = self.patchesUndo[self.patchesUndoLevel]; self.patchesUndoLevel += 1;
|
||||||
@ -31,30 +29,30 @@ class CanvasJournal():
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ pushCursor(self, patches): XXX
|
# {{{ pushCursor(self, patches)
|
||||||
def pushCursor(self, patches):
|
def pushCursor(self, patches):
|
||||||
self.patchesCursor.append(patches)
|
self.patchesCursor.append(patches)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ pushDeltas(self, redoPatches, undoPatches): XXX
|
# {{{ pushDeltas(self, redoPatches, undoPatches)
|
||||||
def pushDeltas(self, redoPatches, undoPatches):
|
def pushDeltas(self, redoPatches, undoPatches):
|
||||||
if self.patchesUndoLevel > 0:
|
if self.patchesUndoLevel > 0:
|
||||||
del self.patchesUndo[0:self.patchesUndoLevel]; self.patchesUndoLevel = 0;
|
del self.patchesUndo[0:self.patchesUndoLevel]; self.patchesUndoLevel = 0;
|
||||||
deltaItem = [undoPatches, redoPatches]; self.patchesUndo.insert(0, deltaItem);
|
deltaItem = [undoPatches, redoPatches]; self.patchesUndo.insert(0, deltaItem);
|
||||||
return deltaItem
|
return deltaItem
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resetCursor(self): XXX
|
# {{{ resetCursor(self)
|
||||||
def resetCursor(self):
|
def resetCursor(self):
|
||||||
if self.patchesCursor != None:
|
if self.patchesCursor != None:
|
||||||
self.patchesCursor.clear()
|
self.patchesCursor.clear()
|
||||||
self.patchesCursor = []
|
self.patchesCursor = []
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resetUndo(self): XXX
|
# {{{ resetUndo(self)
|
||||||
def resetUndo(self):
|
def resetUndo(self):
|
||||||
if self.patchesUndo != None:
|
if self.patchesUndo != None:
|
||||||
self.patchesUndo.clear()
|
self.patchesUndo.clear()
|
||||||
self.patchesUndo = [None]; self.patchesUndoLevel = 0;
|
self.patchesUndo = [None]; self.patchesUndoLevel = 0;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ updateCurrentDeltas(self, redoPatches, undoPatches): XXX
|
# {{{ updateCurrentDeltas(self, redoPatches, undoPatches)
|
||||||
def updateCurrentDeltas(self, redoPatches, undoPatches):
|
def updateCurrentDeltas(self, redoPatches, undoPatches):
|
||||||
self.patchesUndo[0][0].append(undoPatches); self.patchesUndo[0][1].append(redoPatches);
|
self.patchesUndo[0][0].append(undoPatches); self.patchesUndo[0][1].append(redoPatches);
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiCanvasColours.py -- XXX
|
# GuiCanvasColours.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiCanvasInterface.py -- XXX
|
# GuiCanvasInterface.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -25,8 +25,7 @@ from ImgurApiKey import ImgurApiKey
|
|||||||
import io, os, sys, wx
|
import io, os, sys, wx
|
||||||
|
|
||||||
def GuiCanvasCommandDecorator(caption, label, icon, accel, initialState):
|
def GuiCanvasCommandDecorator(caption, label, icon, accel, initialState):
|
||||||
"""XXX"""
|
# {{{ GuiCanvasCommandDecoratorOuter(targetObject)
|
||||||
# {{{ GuiCanvasCommandDecoratorOuter(targetObject): XXX
|
|
||||||
def GuiCanvasCommandDecoratorOuter(targetObject):
|
def GuiCanvasCommandDecoratorOuter(targetObject):
|
||||||
if callable(targetObject):
|
if callable(targetObject):
|
||||||
if not hasattr(targetObject, "attrDict"):
|
if not hasattr(targetObject, "attrDict"):
|
||||||
@ -37,8 +36,7 @@ def GuiCanvasCommandDecorator(caption, label, icon, accel, initialState):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def GuiCanvasSelectDecorator(idx, caption, label, icon, accel, initialState):
|
def GuiCanvasSelectDecorator(idx, caption, label, icon, accel, initialState):
|
||||||
"""XXX"""
|
# {{{ GuiCanvasSelectDecoratorOuter(targetObject)
|
||||||
# {{{ GuiCanvasSelectDecoratorOuter(targetObject): XXX
|
|
||||||
def GuiCanvasSelectDecoratorOuter(targetObject):
|
def GuiCanvasSelectDecoratorOuter(targetObject):
|
||||||
if callable(targetObject):
|
if callable(targetObject):
|
||||||
if not hasattr(targetObject, "attrList"):
|
if not hasattr(targetObject, "attrList"):
|
||||||
@ -50,9 +48,7 @@ def GuiCanvasSelectDecorator(idx, caption, label, icon, accel, initialState):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class GuiCanvasInterface():
|
class GuiCanvasInterface():
|
||||||
"""XXX"""
|
# {{{ _initColourBitmaps(self)
|
||||||
|
|
||||||
# {{{ _initColourBitmaps(self): XXX
|
|
||||||
def _initColourBitmaps(self):
|
def _initColourBitmaps(self):
|
||||||
for numColour in range(len(self.canvasColour.attrList)):
|
for numColour in range(len(self.canvasColour.attrList)):
|
||||||
if numColour < len(Colours):
|
if numColour < len(Colours):
|
||||||
@ -76,7 +72,7 @@ class GuiCanvasInterface():
|
|||||||
toolBitmapDc.DrawRectangle(8, 8, 16, 16)
|
toolBitmapDc.DrawRectangle(8, 8, 16, 16)
|
||||||
self.canvasColourAlpha.attrList[0]["icon"] = ["", None, toolBitmap]
|
self.canvasColourAlpha.attrList[0]["icon"] = ["", None, toolBitmap]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _promptSaveChanges(self): XXX
|
# {{{ _promptSaveChanges(self)
|
||||||
def _promptSaveChanges(self):
|
def _promptSaveChanges(self):
|
||||||
if self.parentCanvas.dirty:
|
if self.parentCanvas.dirty:
|
||||||
with wx.MessageDialog(self.parentCanvas, \
|
with wx.MessageDialog(self.parentCanvas, \
|
||||||
@ -95,12 +91,12 @@ class GuiCanvasInterface():
|
|||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasAbout(self, event): XXX
|
# {{{ canvasAbout(self, event)
|
||||||
@GuiCanvasCommandDecorator("About", "&About", None, None, True)
|
@GuiCanvasCommandDecorator("About", "&About", None, None, True)
|
||||||
def canvasAbout(self, event):
|
def canvasAbout(self, event):
|
||||||
GuiCanvasInterfaceAbout(self.parentFrame)
|
GuiCanvasInterfaceAbout(self.parentFrame)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasBrush(self, f, idx): XXX
|
# {{{ canvasBrush(self, f, idx)
|
||||||
@GuiCanvasSelectDecorator(0, "Solid brush", "Solid brush", None, None, True)
|
@GuiCanvasSelectDecorator(0, "Solid brush", "Solid brush", None, None, True)
|
||||||
def canvasBrush(self, f, idx):
|
def canvasBrush(self, f, idx):
|
||||||
def canvasBrush_(self, event):
|
def canvasBrush_(self, event):
|
||||||
@ -109,7 +105,7 @@ class GuiCanvasInterface():
|
|||||||
setattr(canvasBrush_, "isSelect", True)
|
setattr(canvasBrush_, "isSelect", True)
|
||||||
return canvasBrush_
|
return canvasBrush_
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasColour(self, f, idx): XXX
|
# {{{ canvasColour(self, f, idx)
|
||||||
@GuiCanvasSelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, None, False)
|
@GuiCanvasSelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, None, False)
|
||||||
@GuiCanvasSelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, None, False)
|
@GuiCanvasSelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, None, False)
|
||||||
@GuiCanvasSelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, None, False)
|
@GuiCanvasSelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, None, False)
|
||||||
@ -137,7 +133,7 @@ class GuiCanvasInterface():
|
|||||||
setattr(canvasColour_, "isSelect", True)
|
setattr(canvasColour_, "isSelect", True)
|
||||||
return canvasColour_
|
return canvasColour_
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasColourAlpha(self, f, idx): XXX
|
# {{{ canvasColourAlpha(self, f, idx)
|
||||||
@GuiCanvasSelectDecorator(0, "Transparent colour", "Transparent colour", None, None, False)
|
@GuiCanvasSelectDecorator(0, "Transparent colour", "Transparent colour", None, None, False)
|
||||||
def canvasColourAlpha(self, f, idx):
|
def canvasColourAlpha(self, f, idx):
|
||||||
def canvasColourAlpha_(self, event):
|
def canvasColourAlpha_(self, event):
|
||||||
@ -150,28 +146,28 @@ class GuiCanvasInterface():
|
|||||||
setattr(canvasColourAlpha_, "isSelect", True)
|
setattr(canvasColourAlpha_, "isSelect", True)
|
||||||
return canvasColourAlpha_
|
return canvasColourAlpha_
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasCopy(self, event): XXX
|
# {{{ canvasCopy(self, event)
|
||||||
@GuiCanvasCommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False)
|
@GuiCanvasCommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False)
|
||||||
def canvasCopy(self, event):
|
def canvasCopy(self, event):
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasCut(self, event): XXX
|
# {{{ canvasCut(self, event)
|
||||||
@GuiCanvasCommandDecorator("Cut", "Cu&t", ["", wx.ART_CUT], None, False)
|
@GuiCanvasCommandDecorator("Cut", "Cu&t", ["", wx.ART_CUT], None, False)
|
||||||
def canvasCut(self, event):
|
def canvasCut(self, event):
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDelete(self, event): XXX
|
# {{{ canvasDelete(self, event)
|
||||||
@GuiCanvasCommandDecorator("Delete", "De&lete", ["", wx.ART_DELETE], None, False)
|
@GuiCanvasCommandDecorator("Delete", "De&lete", ["", wx.ART_DELETE], None, False)
|
||||||
def canvasDelete(self, event):
|
def canvasDelete(self, event):
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasExit(self, event): XXX
|
# {{{ canvasExit(self, event)
|
||||||
@GuiCanvasCommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None)
|
@GuiCanvasCommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None)
|
||||||
def canvasExit(self, event):
|
def canvasExit(self, event):
|
||||||
if self._promptSaveChanges():
|
if self._promptSaveChanges():
|
||||||
self.parentFrame.Close(True)
|
self.parentFrame.Close(True)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasNew(self, event, newCanvasSize=None): XXX
|
# {{{ canvasNew(self, event, newCanvasSize=None)
|
||||||
@GuiCanvasCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
|
@GuiCanvasCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
|
||||||
def canvasNew(self, event, newCanvasSize=None):
|
def canvasNew(self, event, newCanvasSize=None):
|
||||||
if self._promptSaveChanges():
|
if self._promptSaveChanges():
|
||||||
@ -185,7 +181,7 @@ class GuiCanvasInterface():
|
|||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
|
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasOpen(self, event): XXX
|
# {{{ canvasOpen(self, event)
|
||||||
@GuiCanvasCommandDecorator("Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None)
|
@GuiCanvasCommandDecorator("Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None)
|
||||||
def canvasOpen(self, event):
|
def canvasOpen(self, event):
|
||||||
if self._promptSaveChanges():
|
if self._promptSaveChanges():
|
||||||
@ -206,18 +202,18 @@ class GuiCanvasInterface():
|
|||||||
print("error: {}".format(error), file=sys.stderr)
|
print("error: {}".format(error), file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasPaste(self, event): XXX
|
# {{{ canvasPaste(self, event)
|
||||||
@GuiCanvasCommandDecorator("Paste", "&Paste", ["", wx.ART_PASTE], None, False)
|
@GuiCanvasCommandDecorator("Paste", "&Paste", ["", wx.ART_PASTE], None, False)
|
||||||
def canvasPaste(self, event):
|
def canvasPaste(self, event):
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasRedo(self, event): XXX
|
# {{{ canvasRedo(self, event)
|
||||||
@GuiCanvasCommandDecorator("Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False)
|
@GuiCanvasCommandDecorator("Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False)
|
||||||
def canvasRedo(self, event):
|
def canvasRedo(self, event):
|
||||||
self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popRedo())
|
self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popRedo())
|
||||||
self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel)
|
self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasSave(self, event): XXX
|
# {{{ canvasSave(self, event)
|
||||||
@GuiCanvasCommandDecorator("Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None)
|
@GuiCanvasCommandDecorator("Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None)
|
||||||
def canvasSave(self, event):
|
def canvasSave(self, event):
|
||||||
if self.canvasPathName == None:
|
if self.canvasPathName == None:
|
||||||
@ -234,7 +230,7 @@ class GuiCanvasInterface():
|
|||||||
except IOError as error:
|
except IOError as error:
|
||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasSaveAs(self, event): XXX
|
# {{{ canvasSaveAs(self, event)
|
||||||
@GuiCanvasCommandDecorator("Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None)
|
@GuiCanvasCommandDecorator("Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None)
|
||||||
def canvasSaveAs(self, event):
|
def canvasSaveAs(self, event):
|
||||||
with wx.FileDialog(self.parentCanvas, "Save As", os.getcwd(), "", "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
with wx.FileDialog(self.parentCanvas, "Save As", os.getcwd(), "", "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
||||||
@ -244,86 +240,86 @@ class GuiCanvasInterface():
|
|||||||
self.canvasPathName = dialog.GetPath()
|
self.canvasPathName = dialog.GetPath()
|
||||||
return self.canvasSave(event)
|
return self.canvasSave(event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasUndo(self, event): XXX
|
# {{{ canvasUndo(self, event)
|
||||||
@GuiCanvasCommandDecorator("Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False)
|
@GuiCanvasCommandDecorator("Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False)
|
||||||
def canvasUndo(self, event):
|
def canvasUndo(self, event):
|
||||||
self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popUndo())
|
self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popUndo())
|
||||||
self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel)
|
self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasDecrBrushHeight(self, event): XXX
|
# {{{ canvasDecrBrushHeight(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease brush height", "Decrease brush height", ["toolDecrBrushH.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease brush height", "Decrease brush height", ["toolDecrBrushH.png"], None, None)
|
||||||
def canvasDecrBrushHeight(self, event):
|
def canvasDecrBrushHeight(self, event):
|
||||||
if self.parentCanvas.brushSize[1] > 1:
|
if self.parentCanvas.brushSize[1] > 1:
|
||||||
self.parentCanvas.brushSize[1] -= 1
|
self.parentCanvas.brushSize[1] -= 1
|
||||||
self.update(brushSize=self.parentCanvas.brushSize)
|
self.update(brushSize=self.parentCanvas.brushSize)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDecrBrushHeightWidth(self, event): XXX
|
# {{{ canvasDecrBrushHeightWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease brush size", "Decrease brush size", ["toolDecrBrushHW.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease brush size", "Decrease brush size", ["toolDecrBrushHW.png"], None, None)
|
||||||
def canvasDecrBrushHeightWidth(self, event):
|
def canvasDecrBrushHeightWidth(self, event):
|
||||||
self.canvasDecrBrushHeight(event)
|
self.canvasDecrBrushHeight(event)
|
||||||
self.canvasDecrBrushWidth(event)
|
self.canvasDecrBrushWidth(event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDecrBrushWidth(self, event): XXX
|
# {{{ canvasDecrBrushWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease brush width", "Decrease brush width", ["toolDecrBrushW.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease brush width", "Decrease brush width", ["toolDecrBrushW.png"], None, None)
|
||||||
def canvasDecrBrushWidth(self, event):
|
def canvasDecrBrushWidth(self, event):
|
||||||
if self.parentCanvas.brushSize[0] > 1:
|
if self.parentCanvas.brushSize[0] > 1:
|
||||||
self.parentCanvas.brushSize[0] -= 1
|
self.parentCanvas.brushSize[0] -= 1
|
||||||
self.update(brushSize=self.parentCanvas.brushSize)
|
self.update(brushSize=self.parentCanvas.brushSize)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDecrCanvasHeight(self, event): XXX
|
# {{{ canvasDecrCanvasHeight(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease canvas height", "Decrease canvas height", ["toolDecrCanvasH.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease canvas height", "Decrease canvas height", ["toolDecrCanvasH.png"], None, None)
|
||||||
def canvasDecrCanvasHeight(self, event):
|
def canvasDecrCanvasHeight(self, event):
|
||||||
if self.parentCanvas.canvas.size[1] > 1:
|
if self.parentCanvas.canvas.size[1] > 1:
|
||||||
self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] - 1])
|
self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] - 1])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDecrCanvasHeightWidth(self, event): XXX
|
# {{{ canvasDecrCanvasHeightWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease canvas size", "Decrease canvas size", ["toolDecrCanvasHW.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease canvas size", "Decrease canvas size", ["toolDecrCanvasHW.png"], None, None)
|
||||||
def canvasDecrCanvasHeightWidth(self, event):
|
def canvasDecrCanvasHeightWidth(self, event):
|
||||||
self.canvasDecrCanvasHeight(event)
|
self.canvasDecrCanvasHeight(event)
|
||||||
self.canvasDecrCanvasWidth(event)
|
self.canvasDecrCanvasWidth(event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasDecrCanvasWidth(self, event): XXX
|
# {{{ canvasDecrCanvasWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Decrease canvas width", "Decrease canvas width", ["toolDecrCanvasW.png"], None, None)
|
@GuiCanvasCommandDecorator("Decrease canvas width", "Decrease canvas width", ["toolDecrCanvasW.png"], None, None)
|
||||||
def canvasDecrCanvasWidth(self, event):
|
def canvasDecrCanvasWidth(self, event):
|
||||||
if self.parentCanvas.canvas.size[0] > 1:
|
if self.parentCanvas.canvas.size[0] > 1:
|
||||||
self.parentCanvas.resize([self.parentCanvas.canvas.size[0] - 1, self.parentCanvas.canvas.size[1]])
|
self.parentCanvas.resize([self.parentCanvas.canvas.size[0] - 1, self.parentCanvas.canvas.size[1]])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrBrushHeight(self, event): XXX
|
# {{{ canvasIncrBrushHeight(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase brush height", "Increase brush height", ["toolIncrBrushH.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase brush height", "Increase brush height", ["toolIncrBrushH.png"], None, None)
|
||||||
def canvasIncrBrushHeight(self, event):
|
def canvasIncrBrushHeight(self, event):
|
||||||
self.parentCanvas.brushSize[1] += 1
|
self.parentCanvas.brushSize[1] += 1
|
||||||
self.update(brushSize=self.parentCanvas.brushSize)
|
self.update(brushSize=self.parentCanvas.brushSize)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrBrushHeightWidth(self, event): XXX
|
# {{{ canvasIncrBrushHeightWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase brush size", "Increase brush size", ["toolIncrBrushHW.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase brush size", "Increase brush size", ["toolIncrBrushHW.png"], None, None)
|
||||||
def canvasIncrBrushHeightWidth(self, event):
|
def canvasIncrBrushHeightWidth(self, event):
|
||||||
self.canvasIncrBrushHeight(event)
|
self.canvasIncrBrushHeight(event)
|
||||||
self.canvasIncrBrushWidth(event)
|
self.canvasIncrBrushWidth(event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrBrushWidth(self, event): XXX
|
# {{{ canvasIncrBrushWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase brush width", "Increase brush width", ["toolIncrBrushW.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase brush width", "Increase brush width", ["toolIncrBrushW.png"], None, None)
|
||||||
def canvasIncrBrushWidth(self, event):
|
def canvasIncrBrushWidth(self, event):
|
||||||
self.parentCanvas.brushSize[0] += 1
|
self.parentCanvas.brushSize[0] += 1
|
||||||
self.update(brushSize=self.parentCanvas.brushSize)
|
self.update(brushSize=self.parentCanvas.brushSize)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrCanvasHeight(self, event): XXX
|
# {{{ canvasIncrCanvasHeight(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase canvas height", "Increase canvas height", ["toolIncrCanvasH.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase canvas height", "Increase canvas height", ["toolIncrCanvasH.png"], None, None)
|
||||||
def canvasIncrCanvasHeight(self, event):
|
def canvasIncrCanvasHeight(self, event):
|
||||||
self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] + 1])
|
self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] + 1])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrCanvasHeightWidth(self, event): XXX
|
# {{{ canvasIncrCanvasHeightWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase canvas size", "Increase canvas size", ["toolIncrCanvasHW.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase canvas size", "Increase canvas size", ["toolIncrCanvasHW.png"], None, None)
|
||||||
def canvasIncrCanvasHeightWidth(self, event):
|
def canvasIncrCanvasHeightWidth(self, event):
|
||||||
self.canvasIncrCanvasHeight(event)
|
self.canvasIncrCanvasHeight(event)
|
||||||
self.canvasIncrCanvasWidth(event)
|
self.canvasIncrCanvasWidth(event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrCanvasWidth(self, event): XXX
|
# {{{ canvasIncrCanvasWidth(self, event)
|
||||||
@GuiCanvasCommandDecorator("Increase canvas width", "Increase canvas width", ["toolIncrCanvasW.png"], None, None)
|
@GuiCanvasCommandDecorator("Increase canvas width", "Increase canvas width", ["toolIncrCanvasW.png"], None, None)
|
||||||
def canvasIncrCanvasWidth(self, event):
|
def canvasIncrCanvasWidth(self, event):
|
||||||
self.parentCanvas.resize([self.parentCanvas.canvas.size[0] + 1, self.parentCanvas.canvas.size[1]])
|
self.parentCanvas.resize([self.parentCanvas.canvas.size[0] + 1, self.parentCanvas.canvas.size[1]])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasTool(self, f, idx): XXX
|
# {{{ canvasTool(self, f, idx)
|
||||||
@GuiCanvasSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False)
|
@GuiCanvasSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False)
|
||||||
@GuiCanvasSelectDecorator(1, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
@GuiCanvasSelectDecorator(1, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
||||||
@GuiCanvasSelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False)
|
@GuiCanvasSelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False)
|
||||||
@ -343,7 +339,7 @@ class GuiCanvasInterface():
|
|||||||
return canvasTool_
|
return canvasTool_
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasExportAsAnsi(self, event): XXX
|
# {{{ canvasExportAsAnsi(self, event)
|
||||||
@GuiCanvasCommandDecorator("Export as ANSI...", "Export as ANSI...", None, None, None)
|
@GuiCanvasCommandDecorator("Export as ANSI...", "Export as ANSI...", None, None, None)
|
||||||
def canvasExportAsAnsi(self, event):
|
def canvasExportAsAnsi(self, event):
|
||||||
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
||||||
@ -357,7 +353,7 @@ class GuiCanvasInterface():
|
|||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasExportAsPng(self, event): XXX
|
# {{{ canvasExportAsPng(self, event)
|
||||||
@GuiCanvasCommandDecorator("Export as PNG...", "Export as PN&G...", None, None, None)
|
@GuiCanvasCommandDecorator("Export as PNG...", "Export as PN&G...", None, None, None)
|
||||||
def canvasExportAsPng(self, event):
|
def canvasExportAsPng(self, event):
|
||||||
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "PNG (*.png)|*.png|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "PNG (*.png)|*.png|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
||||||
@ -370,7 +366,7 @@ class GuiCanvasInterface():
|
|||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasExportImgur(self, event): XXX
|
# {{{ canvasExportImgur(self, event)
|
||||||
@GuiCanvasCommandDecorator("Export to Imgur...", "Export to I&mgur...", None, None, haveUrllib)
|
@GuiCanvasCommandDecorator("Export to Imgur...", "Export to I&mgur...", None, None, haveUrllib)
|
||||||
def canvasExportImgur(self, event):
|
def canvasExportImgur(self, event):
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
@ -383,7 +379,7 @@ class GuiCanvasInterface():
|
|||||||
else:
|
else:
|
||||||
wx.MessageBox("Failed to export to Imgur: {}".format(result), "Export to Imgur", wx.ICON_EXCLAMATION | wx.OK)
|
wx.MessageBox("Failed to export to Imgur: {}".format(result), "Export to Imgur", wx.ICON_EXCLAMATION | wx.OK)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasExportPastebin(self, event): XXX
|
# {{{ canvasExportPastebin(self, event)
|
||||||
@GuiCanvasCommandDecorator("Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib)
|
@GuiCanvasCommandDecorator("Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib)
|
||||||
def canvasExportPastebin(self, event):
|
def canvasExportPastebin(self, event):
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
@ -398,7 +394,7 @@ class GuiCanvasInterface():
|
|||||||
else:
|
else:
|
||||||
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, "Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, "Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasExportToClipboard(self, event): XXX
|
# {{{ canvasExportToClipboard(self, event)
|
||||||
@GuiCanvasCommandDecorator("Export to clipboard", "&Export to clipboard", None, None, None)
|
@GuiCanvasCommandDecorator("Export to clipboard", "&Export to clipboard", None, None, None)
|
||||||
def canvasExportToClipboard(self, event):
|
def canvasExportToClipboard(self, event):
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
@ -409,7 +405,7 @@ class GuiCanvasInterface():
|
|||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasImportAnsi(self, event): XXX
|
# {{{ canvasImportAnsi(self, event)
|
||||||
@GuiCanvasCommandDecorator("Import ANSI...", "Import ANSI...", None, None, None)
|
@GuiCanvasCommandDecorator("Import ANSI...", "Import ANSI...", None, None, None)
|
||||||
def canvasImportAnsi(self, event):
|
def canvasImportAnsi(self, event):
|
||||||
with wx.FileDialog(self.parentCanvas, "Open", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_OPEN) as dialog:
|
with wx.FileDialog(self.parentCanvas, "Open", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_OPEN) as dialog:
|
||||||
@ -430,7 +426,7 @@ class GuiCanvasInterface():
|
|||||||
print("error: {}".format(error), file=sys.stderr)
|
print("error: {}".format(error), file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasImportFromClipboard(self, event): XXX
|
# {{{ canvasImportFromClipboard(self, event)
|
||||||
@GuiCanvasCommandDecorator("Import from clipboard", "&Import from clipboard", None, None, None)
|
@GuiCanvasCommandDecorator("Import from clipboard", "&Import from clipboard", None, None, None)
|
||||||
def canvasImportFromClipboard(self, event):
|
def canvasImportFromClipboard(self, event):
|
||||||
rc = False
|
rc = False
|
||||||
@ -454,7 +450,7 @@ class GuiCanvasInterface():
|
|||||||
with wx.MessageDialog(self.parentCanvas, "Clipboard does not contain text data and/or cannot be opened", "", wx.ICON_QUESTION | wx.OK | wx.OK_DEFAULT) as dialog:
|
with wx.MessageDialog(self.parentCanvas, "Clipboard does not contain text data and/or cannot be opened", "", wx.ICON_QUESTION | wx.OK | wx.OK_DEFAULT) as dialog:
|
||||||
dialog.ShowModal()
|
dialog.ShowModal()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasImportSauce(self, event): XXX
|
# {{{ canvasImportSauce(self, event)
|
||||||
@GuiCanvasCommandDecorator("Import SAUCE...", "Import SAUCE...", None, None, None)
|
@GuiCanvasCommandDecorator("Import SAUCE...", "Import SAUCE...", None, None, None)
|
||||||
def canvasImportSauce(self, event):
|
def canvasImportSauce(self, event):
|
||||||
with wx.FileDialog(self.parentCanvas, "Open", os.getcwd(), "", "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_OPEN) as dialog:
|
with wx.FileDialog(self.parentCanvas, "Open", os.getcwd(), "", "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_OPEN) as dialog:
|
||||||
@ -476,7 +472,7 @@ class GuiCanvasInterface():
|
|||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ update(self, **kwargs): XXX
|
# {{{ update(self, **kwargs)
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
self.lastPanelState.update(kwargs); textItems = [];
|
self.lastPanelState.update(kwargs); textItems = [];
|
||||||
if "cellPos" in self.lastPanelState:
|
if "cellPos" in self.lastPanelState:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiCanvasInterfaceAbout.py -- XXX
|
# GuiCanvasInterfaceAbout.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -8,15 +8,13 @@ from glob import glob
|
|||||||
import os, random, wx, wx.adv
|
import os, random, wx, wx.adv
|
||||||
|
|
||||||
class GuiCanvasInterfaceAbout(wx.Dialog):
|
class GuiCanvasInterfaceAbout(wx.Dialog):
|
||||||
"""XXX"""
|
# {{{ onButtonRoar(self, event)
|
||||||
|
|
||||||
# {{{ onButtonRoar(self, event): XXX
|
|
||||||
def onButtonRoar(self, event):
|
def onButtonRoar(self, event):
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# __init__(self, parent, size=(320, 240), title="About roar"): XXX
|
# __init__(self, parent, size=(320, 240), title="About roar")
|
||||||
def __init__(self, parent, size=(320, 240), title="About roar"):
|
def __init__(self, parent, size=(320, 240), title="About roar"):
|
||||||
super(GuiCanvasInterfaceAbout, self).__init__(parent, size=size, title=title)
|
super(GuiCanvasInterfaceAbout, self).__init__(parent, size=size, title=title)
|
||||||
self.panel, self.sizer, self.sizerH1, self.sizerH2 = wx.Panel(self), wx.BoxSizer(wx.VERTICAL), wx.BoxSizer(wx.HORIZONTAL), wx.BoxSizer(wx.HORIZONTAL)
|
self.panel, self.sizer, self.sizerH1, self.sizerH2 = wx.Panel(self), wx.BoxSizer(wx.VERTICAL), wx.BoxSizer(wx.HORIZONTAL), wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiCanvasPanel.py -- XXX
|
# GuiCanvasPanel.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
class GuiCanvasPanel(wx.Panel):
|
class GuiCanvasPanel(wx.Panel):
|
||||||
"""XXX"""
|
# {{{ _drawPatch(self, eventDc, isCursor, patch)
|
||||||
|
|
||||||
# {{{ _drawPatch(self, eventDc, isCursor, patch): XXX
|
|
||||||
def _drawPatch(self, eventDc, isCursor, patch):
|
def _drawPatch(self, eventDc, isCursor, patch):
|
||||||
if not self.canvas.dirtyCursor:
|
if not self.canvas.dirtyCursor:
|
||||||
self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc)
|
self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc)
|
||||||
@ -20,7 +18,7 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
self.canvas.journal.pushCursor(patchDelta)
|
self.canvas.journal.pushCursor(patchDelta)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ dispatchDeltaPatches(self, deltaPatches): XXX
|
# {{{ dispatchDeltaPatches(self, deltaPatches)
|
||||||
def dispatchDeltaPatches(self, deltaPatches):
|
def dispatchDeltaPatches(self, deltaPatches):
|
||||||
eventDc = self.backend.getDeviceContext(self)
|
eventDc = self.backend.getDeviceContext(self)
|
||||||
for patch in deltaPatches:
|
for patch in deltaPatches:
|
||||||
@ -31,12 +29,12 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
else:
|
else:
|
||||||
self.canvas._commitPatch(patch); self.backend.drawPatch(eventDc, patch);
|
self.canvas._commitPatch(patch); self.backend.drawPatch(eventDc, patch);
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ dispatchPatch(self, eventDc, isCursor, patch): XXX
|
# {{{ dispatchPatch(self, eventDc, isCursor, patch)
|
||||||
def dispatchPatch(self, eventDc, isCursor, patch):
|
def dispatchPatch(self, eventDc, isCursor, patch):
|
||||||
self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True)
|
self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True)
|
||||||
self._drawPatch(eventDc, isCursor, patch)
|
self._drawPatch(eventDc, isCursor, patch)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resize(self, newSize, commitUndo=True): XXX
|
# {{{ resize(self, newSize, commitUndo=True)
|
||||||
def resize(self, newSize, commitUndo=True):
|
def resize(self, newSize, commitUndo=True):
|
||||||
oldSize = [0, 0] if self.canvas.map == None else self.canvas.size
|
oldSize = [0, 0] if self.canvas.map == None else self.canvas.size
|
||||||
deltaSize = [b - a for a, b in zip(oldSize, newSize)]
|
deltaSize = [b - a for a, b in zip(oldSize, newSize)]
|
||||||
@ -59,7 +57,7 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
del eventDc; wx.SafeYield();
|
del eventDc; wx.SafeYield();
|
||||||
self.interface.update(size=newSize, undoLevel=self.canvas.journal.patchesUndoLevel)
|
self.interface.update(size=newSize, undoLevel=self.canvas.journal.patchesUndoLevel)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ update(self, newSize, commitUndo=True, newCanvas=None): XXX
|
# {{{ update(self, newSize, commitUndo=True, newCanvas=None)
|
||||||
def update(self, newSize, commitUndo=True, newCanvas=None):
|
def update(self, newSize, commitUndo=True, newCanvas=None):
|
||||||
self.resize(newSize, commitUndo)
|
self.resize(newSize, commitUndo)
|
||||||
self.canvas.update(newSize, newCanvas)
|
self.canvas.update(newSize, newCanvas)
|
||||||
@ -70,15 +68,15 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
wx.SafeYield()
|
wx.SafeYield()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ onPanelClose(self, event): XXX
|
# {{{ onPanelClose(self, event)
|
||||||
def onPanelClose(self, event):
|
def onPanelClose(self, event):
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelEnterWindow(self, event): XXX
|
# {{{ onPanelEnterWindow(self, event)
|
||||||
def onPanelEnterWindow(self, event):
|
def onPanelEnterWindow(self, event):
|
||||||
self.parentFrame.SetFocus()
|
self.parentFrame.SetFocus()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelInput(self, event): XXX
|
# {{{ onPanelInput(self, event)
|
||||||
def onPanelInput(self, event):
|
def onPanelInput(self, event):
|
||||||
self.canvas.dirtyJournal, self.canvas.dirtyCursor = False, False
|
self.canvas.dirtyJournal, self.canvas.dirtyCursor = False, False
|
||||||
eventDc, eventType, tool = self.backend.getDeviceContext(self), event.GetEventType(), self.interface.currentTool
|
eventDc, eventType, tool = self.backend.getDeviceContext(self), event.GetEventType(), self.interface.currentTool
|
||||||
@ -103,12 +101,12 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
if eventType == wx.wxEVT_MOTION:
|
if eventType == wx.wxEVT_MOTION:
|
||||||
self.interface.update(cellPos=mapPoint)
|
self.interface.update(cellPos=mapPoint)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelLeaveWindow(self, event): XXX
|
# {{{ onPanelLeaveWindow(self, event)
|
||||||
def onPanelLeaveWindow(self, event):
|
def onPanelLeaveWindow(self, event):
|
||||||
eventDc = self.backend.getDeviceContext(self)
|
eventDc = self.backend.getDeviceContext(self)
|
||||||
self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc)
|
self.backend.drawCursorMaskWithJournal(self.canvas.journal, eventDc)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelPaint(self, event): XXX
|
# {{{ onPanelPaint(self, event)
|
||||||
def onPanelPaint(self, event):
|
def onPanelPaint(self, event):
|
||||||
self.backend.onPanelPaintEvent(event, self)
|
self.backend.onPanelPaintEvent(event, self)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiCanvasWxBackend.py -- XXX
|
# GuiCanvasWxBackend.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -8,16 +8,14 @@ from GuiCanvasColours import Colours
|
|||||||
import wx
|
import wx
|
||||||
|
|
||||||
class GuiCanvasWxBackend():
|
class GuiCanvasWxBackend():
|
||||||
"""XXX"""
|
# {{{ _drawBrushPatch(self, eventDc, patch)
|
||||||
|
|
||||||
# {{{ _drawBrushPatch(self, eventDc, patch): XXX
|
|
||||||
def _drawBrushPatch(self, eventDc, patch):
|
def _drawBrushPatch(self, eventDc, patch):
|
||||||
absPoint = self._xlatePoint(patch)
|
absPoint = self._xlatePoint(patch)
|
||||||
brushBg, brushFg, pen = self._getBrushPatchColours(patch)
|
brushBg, brushFg, pen = self._getBrushPatchColours(patch)
|
||||||
self._setBrushDc(brushBg, brushFg, eventDc, pen)
|
self._setBrushDc(brushBg, brushFg, eventDc, pen)
|
||||||
eventDc.DrawRectangle(*absPoint, *self.cellSize)
|
eventDc.DrawRectangle(*absPoint, *self.cellSize)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _drawCharPatch(self, eventDc, patch): XXX
|
# {{{ _drawCharPatch(self, eventDc, patch)
|
||||||
def _drawCharPatch(self, eventDc, patch):
|
def _drawCharPatch(self, eventDc, patch):
|
||||||
absPoint, fontBitmap = self._xlatePoint(patch), wx.Bitmap(*self.cellSize)
|
absPoint, fontBitmap = self._xlatePoint(patch), wx.Bitmap(*self.cellSize)
|
||||||
brushBg, brushFg, pen = self._getCharPatchColours(patch)
|
brushBg, brushFg, pen = self._getCharPatchColours(patch)
|
||||||
@ -29,13 +27,13 @@ class GuiCanvasWxBackend():
|
|||||||
fontDc.DrawRectangle(0, 0, *self.cellSize); fontDc.DrawText(patch[5], 0, 0);
|
fontDc.DrawRectangle(0, 0, *self.cellSize); fontDc.DrawText(patch[5], 0, 0);
|
||||||
eventDc.Blit(*absPoint, *self.cellSize, fontDc, 0, 0)
|
eventDc.Blit(*absPoint, *self.cellSize, fontDc, 0, 0)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _finiBrushesAndPens(self): XXX
|
# {{{ _finiBrushesAndPens(self)
|
||||||
def _finiBrushesAndPens(self):
|
def _finiBrushesAndPens(self):
|
||||||
[brush.Destroy() for brush in self._brushes or []]
|
[brush.Destroy() for brush in self._brushes or []]
|
||||||
[pen.Destroy() for pen in self._pens or []]
|
[pen.Destroy() for pen in self._pens or []]
|
||||||
self._brushes, self._lastBrushBg, self._lastBrushFg, self._lastPen, self._pens = None, None, None, None, None
|
self._brushes, self._lastBrushBg, self._lastBrushFg, self._lastPen, self._pens = None, None, None, None, None
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _getBrushPatchColours(self, patch): XXX
|
# {{{ _getBrushPatchColours(self, patch)
|
||||||
def _getBrushPatchColours(self, patch):
|
def _getBrushPatchColours(self, patch):
|
||||||
if (patch[2] != -1) and (patch[3] != -1):
|
if (patch[2] != -1) and (patch[3] != -1):
|
||||||
brushBg, brushFg, pen = self._brushes[patch[2]], self._brushes[patch[3]], self._pens[patch[3]]
|
brushBg, brushFg, pen = self._brushes[patch[2]], self._brushes[patch[3]], self._pens[patch[3]]
|
||||||
@ -47,7 +45,7 @@ class GuiCanvasWxBackend():
|
|||||||
brushBg, brushFg, pen = self._brushes[1], self._brushes[patch[2]], self._pens[1]
|
brushBg, brushFg, pen = self._brushes[1], self._brushes[patch[2]], self._pens[1]
|
||||||
return (brushBg, brushFg, pen)
|
return (brushBg, brushFg, pen)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _getCharPatchColours(self, patch): XXX
|
# {{{ _getCharPatchColours(self, patch)
|
||||||
def _getCharPatchColours(self, patch):
|
def _getCharPatchColours(self, patch):
|
||||||
if (patch[2] != -1) and (patch[3] != -1):
|
if (patch[2] != -1) and (patch[3] != -1):
|
||||||
brushBg, brushFg, pen = self._brushes[patch[3]], self._brushes[patch[2]], self._pens[patch[3]]
|
brushBg, brushFg, pen = self._brushes[patch[3]], self._brushes[patch[2]], self._pens[patch[3]]
|
||||||
@ -59,7 +57,7 @@ class GuiCanvasWxBackend():
|
|||||||
brushBg, brushFg, pen = self._brushes[1], self._brushes[patch[2]], self._pens[1]
|
brushBg, brushFg, pen = self._brushes[1], self._brushes[patch[2]], self._pens[1]
|
||||||
return (brushBg, brushFg, pen)
|
return (brushBg, brushFg, pen)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initBrushesAndPens(self): XXX
|
# {{{ _initBrushesAndPens(self)
|
||||||
def _initBrushesAndPens(self):
|
def _initBrushesAndPens(self):
|
||||||
self._brushes, self._pens = [None for x in range(len(Colours))], [None for x in range(len(Colours))]
|
self._brushes, self._pens = [None for x in range(len(Colours))], [None for x in range(len(Colours))]
|
||||||
for mircColour in range(len(Colours)):
|
for mircColour in range(len(Colours)):
|
||||||
@ -67,7 +65,7 @@ class GuiCanvasWxBackend():
|
|||||||
self._pens[mircColour] = wx.Pen(wx.Colour(Colours[mircColour][:4]), 1)
|
self._pens[mircColour] = wx.Pen(wx.Colour(Colours[mircColour][:4]), 1)
|
||||||
self._lastBrushBg, self._lastBrushFg, self._lastPen = None, None, None
|
self._lastBrushBg, self._lastBrushFg, self._lastPen = None, None, None
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _setBrushDc(self, brushBg, brushFg, dc, pen): XXX
|
# {{{ _setBrushDc(self, brushBg, brushFg, dc, pen)
|
||||||
def _setBrushDc(self, brushBg, brushFg, dc, pen):
|
def _setBrushDc(self, brushBg, brushFg, dc, pen):
|
||||||
if self._lastBrushBg != brushBg:
|
if self._lastBrushBg != brushBg:
|
||||||
dc.SetBackground(brushBg); self._lastBrushBg = brushBg;
|
dc.SetBackground(brushBg); self._lastBrushBg = brushBg;
|
||||||
@ -76,16 +74,16 @@ class GuiCanvasWxBackend():
|
|||||||
if self._lastPen != pen:
|
if self._lastPen != pen:
|
||||||
dc.SetPen(pen); self._lastPen = pen;
|
dc.SetPen(pen); self._lastPen = pen;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _xlatePoint(self, patch): XXX
|
# {{{ _xlatePoint(self, patch)
|
||||||
def _xlatePoint(self, patch):
|
def _xlatePoint(self, patch):
|
||||||
return [a * b for a, b in zip(patch[:2], self.cellSize)]
|
return [a * b for a, b in zip(patch[:2], self.cellSize)]
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ drawCursorMaskWithJournal(self, canvasJournal, eventDc): XXX
|
# {{{ drawCursorMaskWithJournal(self, canvasJournal, eventDc)
|
||||||
def drawCursorMaskWithJournal(self, canvasJournal, eventDc):
|
def drawCursorMaskWithJournal(self, canvasJournal, eventDc):
|
||||||
[self.drawPatch(eventDc, patch) for patch in canvasJournal.popCursor()]
|
[self.drawPatch(eventDc, patch) for patch in canvasJournal.popCursor()]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ drawPatch(self, eventDc, patch): XXX
|
# {{{ drawPatch(self, eventDc, patch)
|
||||||
def drawPatch(self, eventDc, patch):
|
def drawPatch(self, eventDc, patch):
|
||||||
if ((patch[0] >= 0) and (patch[0] < self.canvasSize[0])) \
|
if ((patch[0] >= 0) and (patch[0] < self.canvasSize[0])) \
|
||||||
and ((patch[1] >= 0) and (patch[1] < self.canvasSize[1])):
|
and ((patch[1] >= 0) and (patch[1] < self.canvasSize[1])):
|
||||||
@ -94,13 +92,13 @@ class GuiCanvasWxBackend():
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ getDeviceContext(self, parentWindow): XXX
|
# {{{ getDeviceContext(self, parentWindow)
|
||||||
def getDeviceContext(self, parentWindow):
|
def getDeviceContext(self, parentWindow):
|
||||||
eventDc = wx.BufferedDC(wx.ClientDC(parentWindow), self.canvasBitmap)
|
eventDc = wx.BufferedDC(wx.ClientDC(parentWindow), self.canvasBitmap)
|
||||||
self._lastBrushBg, self._lastBrushFg, self._lastPen = None, None, None
|
self._lastBrushBg, self._lastBrushFg, self._lastPen = None, None, None
|
||||||
return eventDc
|
return eventDc
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelPaintEvent(self, panelEvent, panelWindow): XXX
|
# {{{ onPanelPaintEvent(self, panelEvent, panelWindow)
|
||||||
def onPanelPaintEvent(self, panelEvent, panelWindow):
|
def onPanelPaintEvent(self, panelEvent, panelWindow):
|
||||||
if self.canvasBitmap != None:
|
if self.canvasBitmap != None:
|
||||||
eventDc = wx.BufferedPaintDC(panelWindow, self.canvasBitmap)
|
eventDc = wx.BufferedPaintDC(panelWindow, self.canvasBitmap)
|
||||||
@ -123,7 +121,7 @@ class GuiCanvasWxBackend():
|
|||||||
self.canvasSize, self.cellSize = canvasSize, cellSize
|
self.canvasSize, self.cellSize = canvasSize, cellSize
|
||||||
self._font = wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
self._font = wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ xlateEventPoint(self, event, eventDc): XXX
|
# {{{ xlateEventPoint(self, event, eventDc)
|
||||||
def xlateEventPoint(self, event, eventDc):
|
def xlateEventPoint(self, event, eventDc):
|
||||||
eventPoint = event.GetLogicalPosition(eventDc)
|
eventPoint = event.GetLogicalPosition(eventDc)
|
||||||
rectX, rectY = eventPoint.x - (eventPoint.x % self.cellSize[0]), eventPoint.y - (eventPoint.y % self.cellSize[1])
|
rectX, rectY = eventPoint.x - (eventPoint.x % self.cellSize[0]), eventPoint.y - (eventPoint.y % self.cellSize[1])
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# GuiFrame.py -- XXX
|
# GuiFrame.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -18,9 +18,7 @@ NID_MENU_SEP = 0xf000
|
|||||||
NID_TOOLBAR_HSEP = 0xf001
|
NID_TOOLBAR_HSEP = 0xf001
|
||||||
|
|
||||||
class GuiFrame(wx.Frame):
|
class GuiFrame(wx.Frame):
|
||||||
"""XXX"""
|
# {{{ _initAccelTable(self, accels)
|
||||||
|
|
||||||
# {{{ _initAccelTable(self, accels): XXX
|
|
||||||
def _initAccelTable(self, accels):
|
def _initAccelTable(self, accels):
|
||||||
accelTableEntries = []
|
accelTableEntries = []
|
||||||
for accel in accels:
|
for accel in accels:
|
||||||
@ -34,13 +32,13 @@ class GuiFrame(wx.Frame):
|
|||||||
self.Bind(wx.EVT_MENU, self.onInput, id=accel.attrDict["id"])
|
self.Bind(wx.EVT_MENU, self.onInput, id=accel.attrDict["id"])
|
||||||
self.SetAcceleratorTable(wx.AcceleratorTable(accelTableEntries))
|
self.SetAcceleratorTable(wx.AcceleratorTable(accelTableEntries))
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initIcon(self): XXX
|
# {{{ _initIcon(self)
|
||||||
def _initIcon(self):
|
def _initIcon(self):
|
||||||
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
||||||
iconPathName = iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
iconPathName = iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
||||||
icon = wx.Icon(); icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY)); self.SetIcon(icon);
|
icon = wx.Icon(); icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY)); self.SetIcon(icon);
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initMenus(self, menus): XXX
|
# {{{ _initMenus(self, menus)
|
||||||
def _initMenus(self, menus):
|
def _initMenus(self, menus):
|
||||||
menuBar = wx.MenuBar()
|
menuBar = wx.MenuBar()
|
||||||
for menu in menus:
|
for menu in menus:
|
||||||
@ -68,11 +66,11 @@ class GuiFrame(wx.Frame):
|
|||||||
menuBar.Append(menuWindow, menu[0])
|
menuBar.Append(menuWindow, menu[0])
|
||||||
self.SetMenuBar(menuBar)
|
self.SetMenuBar(menuBar)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initStatusBar(self): XXX
|
# {{{ _initStatusBar(self)
|
||||||
def _initStatusBar(self):
|
def _initStatusBar(self):
|
||||||
self.statusBar = self.CreateStatusBar()
|
self.statusBar = self.CreateStatusBar()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initToolBars(self, toolBars, panelSkin): XXX
|
# {{{ _initToolBars(self, toolBars, panelSkin)
|
||||||
def _initToolBars(self, toolBars, panelSkin):
|
def _initToolBars(self, toolBars, panelSkin):
|
||||||
for toolBar in toolBars:
|
for toolBar in toolBars:
|
||||||
self.toolBars.append(wx.ToolBar(panelSkin, -1, style=wx.TB_FLAT | wx.HORIZONTAL | wx.TB_NODIVIDER))
|
self.toolBars.append(wx.ToolBar(panelSkin, -1, style=wx.TB_FLAT | wx.HORIZONTAL | wx.TB_NODIVIDER))
|
||||||
@ -100,7 +98,7 @@ class GuiFrame(wx.Frame):
|
|||||||
self.sizerSkin.Add(toolBar, 0, wx.ALIGN_LEFT | wx.ALL, 3)
|
self.sizerSkin.Add(toolBar, 0, wx.ALIGN_LEFT | wx.ALL, 3)
|
||||||
toolBar.Realize(); toolBar.Fit();
|
toolBar.Realize(); toolBar.Fit();
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initToolBitmaps(self, toolBars): XXX
|
# {{{ _initToolBitmaps(self, toolBars)
|
||||||
def _initToolBitmaps(self, toolBars):
|
def _initToolBitmaps(self, toolBars):
|
||||||
for toolBar in toolBars:
|
for toolBar in toolBars:
|
||||||
for toolBarItem in toolBar:
|
for toolBarItem in toolBar:
|
||||||
@ -122,7 +120,7 @@ class GuiFrame(wx.Frame):
|
|||||||
toolBarItem.attrDict["icon"] = ["", None, toolBitmap]
|
toolBarItem.attrDict["icon"] = ["", None, toolBitmap]
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ onInput(self, event): XXX
|
# {{{ onInput(self, event)
|
||||||
def onInput(self, event):
|
def onInput(self, event):
|
||||||
eventId = event.GetId(); self.itemsById[eventId](self.canvasPanel.interface, event);
|
eventId = event.GetId(); self.itemsById[eventId](self.canvasPanel.interface, event);
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# IrcClient.py -- XXX
|
# IrcClient.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
# This project is licensed under the terms of the MIT licence.
|
# This project is licensed under the terms of the MIT licence.
|
||||||
#
|
#
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Tool.py -- XXX
|
# Tool.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
class Tool():
|
class Tool():
|
||||||
"""XXX"""
|
|
||||||
parentCanvas = None
|
parentCanvas = None
|
||||||
|
|
||||||
# {{{ onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
# {{{ onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
||||||
def onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
def onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# {{{ onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
return ()
|
return ()
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolCircle.py -- XXX
|
# ToolCircle.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tool import Tool
|
from Tool import Tool
|
||||||
|
|
||||||
class ToolCircle(Tool):
|
class ToolCircle(Tool):
|
||||||
"""XXX"""
|
|
||||||
name = "Circle"
|
name = "Circle"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
brushColours = brushColours.copy()
|
brushColours = brushColours.copy()
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolFill.py -- XXX
|
# ToolFill.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tool import Tool
|
from Tool import Tool
|
||||||
|
|
||||||
class ToolFill(Tool):
|
class ToolFill(Tool):
|
||||||
"""XXX"""
|
|
||||||
name = "Fill"
|
name = "Fill"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
pointStack, pointsDone = [list(atPoint)], []
|
pointStack, pointsDone = [list(atPoint)], []
|
||||||
testColour = self.parentCanvas.canvas.map[atPoint[1]][atPoint[0]][0:2]
|
testColour = self.parentCanvas.canvas.map[atPoint[1]][atPoint[0]][0:2]
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolLine.py -- XXX
|
# ToolLine.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tool import Tool
|
from Tool import Tool
|
||||||
|
|
||||||
class ToolLine(Tool):
|
class ToolLine(Tool):
|
||||||
"""XXX"""
|
|
||||||
name = "Line"
|
name = "Line"
|
||||||
TS_NONE = 0
|
TS_NONE = 0
|
||||||
TS_ORIGIN = 1
|
TS_ORIGIN = 1
|
||||||
|
|
||||||
# {{{ _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint): XXX
|
# {{{ _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint)
|
||||||
def _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint):
|
def _getLine(self, brushColours, brushSize, dispatchFn, eventDc, isCursor, originPoint, targetPoint):
|
||||||
originPoint, targetPoint = originPoint.copy(), targetPoint.copy()
|
originPoint, targetPoint = originPoint.copy(), targetPoint.copy()
|
||||||
pointDelta = self._pointDelta(originPoint, targetPoint)
|
pointDelta = self._pointDelta(originPoint, targetPoint)
|
||||||
@ -38,17 +37,17 @@ class ToolLine(Tool):
|
|||||||
lineD -= pointDelta[0]; lineY += 1;
|
lineD -= pointDelta[0]; lineY += 1;
|
||||||
lineD += pointDelta[1]
|
lineD += pointDelta[1]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _pointDelta(self, a, b): XXX
|
# {{{ _pointDelta(self, a, b)
|
||||||
def _pointDelta(self, a, b):
|
def _pointDelta(self, a, b):
|
||||||
return [a2 - a1 for a1, a2 in zip(a, b)]
|
return [a2 - a1 for a1, a2 in zip(a, b)]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _pointSwap(self, a, b): XXX
|
# {{{ _pointSwap(self, a, b)
|
||||||
def _pointSwap(self, a, b):
|
def _pointSwap(self, a, b):
|
||||||
return [b, a]
|
return [b, a]
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
brushColours = brushColours.copy()
|
brushColours = brushColours.copy()
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolRect.py -- XXX
|
# ToolRect.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tool import Tool
|
from Tool import Tool
|
||||||
|
|
||||||
class ToolRect(Tool):
|
class ToolRect(Tool):
|
||||||
"""XXX"""
|
|
||||||
name = "Rectangle"
|
name = "Rectangle"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
brushColours = brushColours.copy()
|
brushColours = brushColours.copy()
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolSelect.py -- XXX
|
# ToolSelect.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tool import Tool
|
from Tool import Tool
|
||||||
|
|
||||||
class ToolSelect(Tool):
|
class ToolSelect(Tool):
|
||||||
"""XXX"""
|
|
||||||
TS_NONE = 0
|
TS_NONE = 0
|
||||||
TS_ORIGIN = 1
|
TS_ORIGIN = 1
|
||||||
TS_SELECT = 2
|
TS_SELECT = 2
|
||||||
TS_TARGET = 3
|
TS_TARGET = 3
|
||||||
|
|
||||||
# {{{ _dispatchSelectEvent(self, atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, selectRect): XXX
|
# {{{ _dispatchSelectEvent(self, atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, selectRect)
|
||||||
def _dispatchSelectEvent(self, atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, selectRect):
|
def _dispatchSelectEvent(self, atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, selectRect):
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
disp, isCursor = [atPoint[m] - self.lastAtPoint[m] for m in [0, 1]], True
|
disp, isCursor = [atPoint[m] - self.lastAtPoint[m] for m in [0, 1]], True
|
||||||
@ -27,7 +26,7 @@ class ToolSelect(Tool):
|
|||||||
self._drawSelectRect(newTargetRect, dispatchFn, eventDc)
|
self._drawSelectRect(newTargetRect, dispatchFn, eventDc)
|
||||||
self.targetRect = newTargetRect
|
self.targetRect = newTargetRect
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _drawSelectRect(self, rect, dispatchFn, eventDc): XXX
|
# {{{ _drawSelectRect(self, rect, dispatchFn, eventDc)
|
||||||
def _drawSelectRect(self, rect, dispatchFn, eventDc):
|
def _drawSelectRect(self, rect, dispatchFn, eventDc):
|
||||||
rectFrame = [[rect[m[0]][n] + m[1] for n in [0, 1]] for m in [[0, -1], [1, +1]]]
|
rectFrame = [[rect[m[0]][n] + m[1] for n in [0, 1]] for m in [[0, -1], [1, +1]]]
|
||||||
if rectFrame[0][0] > rectFrame[1][0]:
|
if rectFrame[0][0] > rectFrame[1][0]:
|
||||||
@ -44,14 +43,14 @@ class ToolSelect(Tool):
|
|||||||
dispatchFn(eventDc, True, [rectFrame[0][0], rectY, *curColours, 0, " "])
|
dispatchFn(eventDc, True, [rectFrame[0][0], rectY, *curColours, 0, " "])
|
||||||
dispatchFn(eventDc, True, [rectFrame[1][0], rectY, *curColours, 0, " "])
|
dispatchFn(eventDc, True, [rectFrame[1][0], rectY, *curColours, 0, " "])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _mouseEventTsNone(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown): XXX
|
# {{{ _mouseEventTsNone(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
def _mouseEventTsNone(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
def _mouseEventTsNone(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
self.targetRect, self.toolState = [list(atPoint), []], self.TS_ORIGIN
|
self.targetRect, self.toolState = [list(atPoint), []], self.TS_ORIGIN
|
||||||
else:
|
else:
|
||||||
dispatchFn(eventDc, True, [*atPoint, *brushColours, 0, " "])
|
dispatchFn(eventDc, True, [*atPoint, *brushColours, 0, " "])
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _mouseEventTsOrigin(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown): XXX
|
# {{{ _mouseEventTsOrigin(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
def _mouseEventTsOrigin(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
def _mouseEventTsOrigin(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
self.targetRect[1] = list(atPoint)
|
self.targetRect[1] = list(atPoint)
|
||||||
@ -72,7 +71,7 @@ class ToolSelect(Tool):
|
|||||||
self.targetRect[1] = list(atPoint)
|
self.targetRect[1] = list(atPoint)
|
||||||
self._drawSelectRect(self.targetRect, dispatchFn, eventDc)
|
self._drawSelectRect(self.targetRect, dispatchFn, eventDc)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _mouseEventTsSelect(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown): XXX
|
# {{{ _mouseEventTsSelect(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
def _mouseEventTsSelect(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
def _mouseEventTsSelect(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
||||||
if isLeftDown \
|
if isLeftDown \
|
||||||
and (atPoint[0] >= (self.targetRect[0][0] - 1)) \
|
and (atPoint[0] >= (self.targetRect[0][0] - 1)) \
|
||||||
@ -86,7 +85,7 @@ class ToolSelect(Tool):
|
|||||||
else:
|
else:
|
||||||
self._dispatchSelectEvent(atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, self.targetRect)
|
self._dispatchSelectEvent(atPoint, dispatchFn, eventDc, isLeftDown, isRightDown, self.targetRect)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _mouseEventTsTarget(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown): XXX
|
# {{{ _mouseEventTsTarget(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
def _mouseEventTsTarget(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
def _mouseEventTsTarget(self, atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown):
|
||||||
if isLeftDown:
|
if isLeftDown:
|
||||||
self.toolState = self.TS_TARGET
|
self.toolState = self.TS_TARGET
|
||||||
@ -99,7 +98,7 @@ class ToolSelect(Tool):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
if self.toolState == self.TS_NONE:
|
if self.toolState == self.TS_NONE:
|
||||||
self._mouseEventTsNone(atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
self._mouseEventTsNone(atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
@ -111,7 +110,7 @@ class ToolSelect(Tool):
|
|||||||
self._mouseEventTsTarget(atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
self._mouseEventTsTarget(atPoint, brushColours, dispatchFn, eventDc, isDragging, isLeftDown, isRightDown)
|
||||||
|
|
||||||
#
|
#
|
||||||
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect): XXX
|
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect)
|
||||||
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect):
|
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newTargetRect, selectRect):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolSelectClone.py -- XXX
|
# ToolSelectClone.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from ToolSelect import ToolSelect
|
from ToolSelect import ToolSelect
|
||||||
|
|
||||||
class ToolSelectClone(ToolSelect):
|
class ToolSelectClone(ToolSelect):
|
||||||
"""XXX"""
|
|
||||||
name = "Clone selection"
|
name = "Clone selection"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect): XXX
|
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect)
|
||||||
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect):
|
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect):
|
||||||
for numRow in range(len(self.toolSelectMap)):
|
for numRow in range(len(self.toolSelectMap)):
|
||||||
for numCol in range(len(self.toolSelectMap[numRow])):
|
for numCol in range(len(self.toolSelectMap[numRow])):
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolSelectMove.py -- XXX
|
# ToolSelectMove.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
from ToolSelect import ToolSelect
|
from ToolSelect import ToolSelect
|
||||||
|
|
||||||
class ToolSelectMove(ToolSelect):
|
class ToolSelectMove(ToolSelect):
|
||||||
"""XXX"""
|
|
||||||
name = "Move selection"
|
name = "Move selection"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect): XXX
|
# onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect)
|
||||||
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect):
|
def onSelectEvent(self, disp, dispatchFn, eventDc, isCursor, newToolRect, selectRect):
|
||||||
for numRow in range(len(self.toolSelectMap)):
|
for numRow in range(len(self.toolSelectMap)):
|
||||||
for numCol in range(len(self.toolSelectMap[numRow])):
|
for numCol in range(len(self.toolSelectMap[numRow])):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# ToolText.py -- XXX
|
# ToolText.py
|
||||||
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -8,11 +8,10 @@ from Tool import Tool
|
|||||||
import wx
|
import wx
|
||||||
|
|
||||||
class ToolText(Tool):
|
class ToolText(Tool):
|
||||||
"""XXX"""
|
|
||||||
name = "Text"
|
name = "Text"
|
||||||
|
|
||||||
#
|
#
|
||||||
# onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc): XXX
|
# onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc)
|
||||||
def onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
def onKeyboardEvent(self, event, atPoint, brushColours, brushSize, keyChar, dispatchFn, eventDc):
|
||||||
keyModifiers = event.GetModifiers()
|
keyModifiers = event.GetModifiers()
|
||||||
if keyModifiers != wx.MOD_NONE \
|
if keyModifiers != wx.MOD_NONE \
|
||||||
@ -31,7 +30,7 @@ class ToolText(Tool):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc): XXX
|
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc)
|
||||||
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown, dispatchFn, eventDc):
|
||||||
if isLeftDown or isRightDown:
|
if isLeftDown or isRightDown:
|
||||||
self.textPos = list(atPoint)
|
self.textPos = list(atPoint)
|
||||||
|
Loading…
Reference in New Issue
Block a user