mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-16 12:36:38 +00:00
Implements {ex,im}port {to,from} clipboard.
libcanvas/CanvasExportStore.py:exportTextBuffer(): cloned from exportTextFile(). libcanvas/CanvasExportStore.py:exportTextFile(): correctly fetch cell colours & text. libcanvas/CanvasImportStore.py:importTextFile{,Buffer}(): split from importTextFile(). libcanvas/CanvasImportStore.py: minor cleanup. libgui/GuiCanvasInterface.py:canvas{ExportTo,ImportFrom}Clipboard(): implemented. libgui/GuiFrame.py: adds CID_{EX,IM}PORT_CLIPB. libgui/GuiFrame.py: minor cleanup. libgui/GuiGeneralFrame.py: minor cleanup. assets/text/TODO: updated.
This commit is contained in:
parent
84126f5d4e
commit
e407ab2d81
@ -1,16 +1,15 @@
|
||||
1) Scrollbar
|
||||
2) Allow {un,re}doing resizing
|
||||
3) {Copy to,Paste from} clipboard
|
||||
4) Incremental auto{load,save} & {backup,restore}
|
||||
5) Open and toggle a reference image in the background
|
||||
6) Client-Server or Peer-to-Peer realtime collaboration
|
||||
7) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
|
||||
8) Hotkey & graphical interfaces to {composed,parametrised} tools
|
||||
9) Layer, layout (e.g. for comics, zines, etc.) & {re,un}do canvas traits
|
||||
10) Im- and exporting from/to ANSI, Blender, GIF, HTML, mIRC, Pastebin/..., PNG, printer, SAUCE, WEBM, etc.
|
||||
11) Asset management (e.g. kade, lion, etc.) & traits w/ simple linking & synchronised editing respecting layers
|
||||
12) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...)
|
||||
13) Composition and parametrisation of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools; unit tools:
|
||||
3) Incremental auto{load,save} & {backup,restore}
|
||||
4) Open and toggle a reference image in the background
|
||||
5) Client-Server or Peer-to-Peer realtime collaboration
|
||||
6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
|
||||
7) Hotkey & graphical interfaces to {composed,parametrised} tools
|
||||
8) Layer, layout (e.g. for comics, zines, etc.) & {re,un}do canvas traits
|
||||
9) Im- and exporting from/to ANSI, Blender, GIF, HTML, mIRC, Pastebin/..., PNG, printer, SAUCE, WEBM, etc.
|
||||
10) Asset management (e.g. kade, lion, etc.) & traits w/ simple linking & synchronised editing respecting layers
|
||||
11) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...)
|
||||
12) Composition and parametrisation of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools; unit tools:
|
||||
a) geometric primitives (arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star)
|
||||
b) regions (crop, duplicate, erase, fill, invert, measure, pick, rotate, scale, select, shift, slice, tile, translate)
|
||||
c) text (edit, Unicode sets)
|
||||
|
@ -87,13 +87,30 @@ class CanvasExportStore():
|
||||
else:
|
||||
return False
|
||||
# }}}
|
||||
# {{{ exportTextBuffer(self, canvasMap, canvasSize): XXX
|
||||
def exportTextBuffer(self, canvasMap, canvasSize):
|
||||
outBuffer = ""
|
||||
for canvasRow in range(canvasSize[1]):
|
||||
canvasLastColours = []
|
||||
for canvasCol in range(canvasSize[0]):
|
||||
canvasColColours = canvasMap[canvasRow][canvasCol][0:2]
|
||||
canvasColText = canvasMap[canvasRow][canvasCol][3]
|
||||
if canvasColColours != canvasLastColours:
|
||||
canvasLastColours = canvasColColours
|
||||
outBuffer += "\x03" + \
|
||||
str(canvasColColours[0]) + \
|
||||
"," + str(canvasColColours[1])
|
||||
outBuffer += canvasColText
|
||||
outBuffer += "\n"
|
||||
return outBuffer
|
||||
# }}}
|
||||
# {{{ exportTextFile(self, canvasMap, canvasSize, outFile): XXX
|
||||
def exportTextFile(self, canvasMap, canvasSize, outFile):
|
||||
for canvasRow in range(canvasSize[1]):
|
||||
canvasLastColours = []
|
||||
for canvasCol in range(canvasSize[0]):
|
||||
canvasColColours = canvasMap[canvasRow][canvasCol][0]
|
||||
canvasColText = canvasMap[canvasRow][canvasCol][2]
|
||||
canvasColColours = canvasMap[canvasRow][canvasCol][0:2]
|
||||
canvasColText = canvasMap[canvasRow][canvasCol][3]
|
||||
if canvasColColours != canvasLastColours:
|
||||
canvasLastColours = canvasColColours
|
||||
outFile.write("\x03" + \
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
class CanvasImportStore():
|
||||
"""XXX"""
|
||||
inFile = inSize = outMap = None
|
||||
parentCanvas = None
|
||||
|
||||
#
|
||||
# _CellState(): Cell state
|
||||
@ -53,11 +51,13 @@ class CanvasImportStore():
|
||||
# }}}
|
||||
# {{{ importTextFile(self, pathName): XXX
|
||||
def importTextFile(self, pathName):
|
||||
self.inFile = open(pathName, "r", encoding="utf-8-sig")
|
||||
self.inSize = self.outMap = None;
|
||||
inCurColourSpec = ""; inCurRow = -1;
|
||||
inLine = self.inFile.readline()
|
||||
inSize = [0, 0]; outMap = []; inMaxCols = 0;
|
||||
return self.importTextFileBuffer(open(pathName, "r", encoding="utf-8-sig"))
|
||||
# }}}
|
||||
# {{{ importTextFileBuffer(self, inFile): XXX
|
||||
def importTextFileBuffer(self, inFile):
|
||||
self.inSize, self.outMap = None, None
|
||||
inCurColourSpec, inCurRow, inMaxCols, inSize, outMap = "", -1, 0, [0, 0], []
|
||||
inLine = inFile.readline()
|
||||
while inLine:
|
||||
inCellState = self._CellState.CS_NONE
|
||||
inParseState = self._ParseState.PS_CHAR
|
||||
@ -95,7 +95,7 @@ class CanvasImportStore():
|
||||
and inParseState == self._ParseState.PS_COLOUR_DIGIT0:
|
||||
if (inCurCol + 1) < inMaxCol \
|
||||
and not inLine[inCurCol + 1] in set("0123456789"):
|
||||
inCurColours = self._parseCharAsColourSpec( \
|
||||
inCurColours = self._parseCharAsColourSpec( \
|
||||
inCurColourSpec, inCurColours)
|
||||
inCurColourDigits = 0; inCurColourSpec = "";
|
||||
inParseState = self._ParseState.PS_CHAR
|
||||
@ -123,9 +123,9 @@ class CanvasImportStore():
|
||||
inCurColourDigits = 0; inCurColourSpec = "";
|
||||
inParseState = self._ParseState.PS_CHAR
|
||||
inMaxCols = max(inMaxCols, inRowCols)
|
||||
inLine = self.inFile.readline()
|
||||
inSize[0] = inMaxCols; self.inSize = inSize; self.outMap = outMap;
|
||||
self.inFile.close()
|
||||
inLine = inFile.readline()
|
||||
inSize[0] = inMaxCols; self.inSize, self.outMap = inSize, outMap;
|
||||
inFile.close()
|
||||
# }}}
|
||||
# {{{ importNew(self, newCanvasSize=None): XXX
|
||||
def importNew(self, newCanvasSize=None):
|
||||
@ -138,8 +138,7 @@ class CanvasImportStore():
|
||||
#
|
||||
# __init__(self, inFile=None, parentCanvas=None): initialisation method
|
||||
def __init__(self, inFile=None, parentCanvas=None):
|
||||
self.inFile = inFile; self.inSize = self.outMap = None;
|
||||
self.parentCanvas = parentCanvas
|
||||
self.inSize, self.outMap, self.parentCanvas = None, None, parentCanvas
|
||||
if inFile != None:
|
||||
self.importTextFile(inFile)
|
||||
|
||||
|
@ -14,7 +14,7 @@ from ToolText import ToolText
|
||||
|
||||
from glob import glob
|
||||
from GuiCanvasInterfaceAbout import GuiCanvasInterfaceAbout
|
||||
import os, random, wx, wx.adv
|
||||
import io, os, random, wx, wx.adv
|
||||
|
||||
class GuiCanvasInterface():
|
||||
"""XXX"""
|
||||
@ -105,6 +105,16 @@ class GuiCanvasInterface():
|
||||
self.canvasSave(event)
|
||||
self.parentFrame.Close(True)
|
||||
# }}}
|
||||
# {{{ canvasExportToClipboard(self, event): XXX
|
||||
def canvasExportToClipboard(self, event):
|
||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||
outBuffer = self.parentCanvas.canvasExportStore.exportTextBuffer(self.parentCanvas.canvasMap, self.parentCanvas.canvasSize)
|
||||
if wx.TheClipboard.Open():
|
||||
wx.TheClipboard.SetData(wx.TextDataObject(outBuffer))
|
||||
wx.TheClipboard.Close()
|
||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||
return True
|
||||
# }}}
|
||||
# {{{ canvasExportAsPng(self, event): XXX
|
||||
def canvasExportAsPng(self, event):
|
||||
with wx.FileDialog(self, "Save As...", os.getcwd(), "", \
|
||||
@ -158,6 +168,33 @@ class GuiCanvasInterface():
|
||||
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, \
|
||||
"Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
||||
# }}}
|
||||
# {{{ canvasImportFromClipboard(self, event): XXX
|
||||
def canvasImportFromClipboard(self, event):
|
||||
rc = False
|
||||
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \
|
||||
and wx.TheClipboard.Open():
|
||||
inBuffer = wx.TextDataObject()
|
||||
if wx.TheClipboard.GetData(inBuffer):
|
||||
if self.canvasPathName != None:
|
||||
saveChanges = self._dialogSaveChanges()
|
||||
if saveChanges == wx.ID_CANCEL:
|
||||
return
|
||||
elif saveChanges == wx.ID_NO:
|
||||
pass
|
||||
elif saveChanges == wx.ID_YES:
|
||||
self.canvasSave(event)
|
||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||
self.parentCanvas.canvasImportStore.importTextFileBuffer(io.StringIO(inBuffer.GetText()))
|
||||
self.parentCanvas.canvasImportStore.importIntoPanel()
|
||||
self.canvasPathName = "(Clipboard)"
|
||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||
self.parentFrame.onCanvasUpdate(pathName="(Clipboard)", undoLevel=-1)
|
||||
rc = True
|
||||
wx.TheClipboard.Close()
|
||||
if not rc:
|
||||
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()
|
||||
# }}}
|
||||
# {{{ canvasIncrBrushHeight(self, event): XXX
|
||||
def canvasIncrBrushHeight(self, event):
|
||||
self.parentCanvas.brushSize[1] += 1
|
||||
|
@ -16,125 +16,107 @@ import os, random, wx
|
||||
|
||||
class GuiFrame(GuiGeneralFrame):
|
||||
"""XXX"""
|
||||
panelCanvas = None; lastPanelState = {};
|
||||
|
||||
# {{{ Commands
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_NEW = [0x100, TID_COMMAND, "New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None, GuiCanvasInterface.canvasNew]
|
||||
CID_OPEN = [0x101, TID_COMMAND, "Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None, GuiCanvasInterface.canvasOpen]
|
||||
CID_SAVE = [0x102, TID_COMMAND, "Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None, GuiCanvasInterface.canvasSave]
|
||||
CID_SAVEAS = [0x103, TID_COMMAND, "Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None, GuiCanvasInterface.canvasSaveAs]
|
||||
CID_EXPORT_AS_PNG = [0x104, TID_COMMAND, "Export as PNG...", \
|
||||
"Export as PN&G...", None, None, None, GuiCanvasInterface.canvasExportAsPng]
|
||||
CID_EXPORT_IMGUR = [0x105, TID_COMMAND, "Export to Imgur...", \
|
||||
"Export to I&mgur...", None, None, haveUrllib, GuiCanvasInterface.canvasExportImgur]
|
||||
CID_EXPORT_PASTEBIN = [0x106, TID_COMMAND, "Export to Pastebin...", \
|
||||
"Export to Pasteb&in...", None, None, haveUrllib, GuiCanvasInterface.canvasExportPastebin]
|
||||
CID_EXIT = [0x107, TID_COMMAND, "Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None, GuiCanvasInterface.canvasExit]
|
||||
CID_UNDO = [0x108, TID_COMMAND, "Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False, GuiCanvasInterface.canvasUndo]
|
||||
CID_REDO = [0x109, TID_COMMAND, "Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False, GuiCanvasInterface.canvasRedo]
|
||||
CID_CUT = [0x10a, TID_COMMAND, "Cut", "Cu&t", ["", wx.ART_CUT], None, False, GuiCanvasInterface.canvasCut]
|
||||
CID_COPY = [0x10b, TID_COMMAND, "Copy", "&Copy", ["", wx.ART_COPY], None, False, GuiCanvasInterface.canvasCopy]
|
||||
CID_PASTE = [0x10c, TID_COMMAND, "Paste", "&Paste", ["", wx.ART_PASTE], None, False, GuiCanvasInterface.canvasPaste]
|
||||
CID_DELETE = [0x10d, TID_COMMAND, "Delete", "De&lete", ["", wx.ART_DELETE], None, False, GuiCanvasInterface.canvasDelete]
|
||||
CID_INCRW_CANVAS = [0x10e, TID_COMMAND, "Increase canvas width", \
|
||||
"Increase canvas width", ["toolIncrCanvasW.png"], None, None, GuiCanvasInterface.canvasIncrCanvasWidth]
|
||||
CID_DECRW_CANVAS = [0x10f, TID_COMMAND, "Decrease canvas width", \
|
||||
"Decrease canvas width", ["toolDecrCanvasW.png"], None, None, GuiCanvasInterface.canvasDecrCanvasWidth]
|
||||
CID_INCRH_CANVAS = [0x110, TID_COMMAND, "Increase canvas height", \
|
||||
"Increase canvas height", ["toolIncrCanvasH.png"], None, None, GuiCanvasInterface.canvasIncrCanvasHeight]
|
||||
CID_DECRH_CANVAS = [0x111, TID_COMMAND, "Decrease canvas height", \
|
||||
"Decrease canvas height", ["toolDecrCanvasH.png"], None, None, GuiCanvasInterface.canvasDecrCanvasHeight]
|
||||
CID_INCRHW_CANVAS = [0x112, TID_COMMAND, "Increase canvas size", \
|
||||
"Increase canvas size", ["toolIncrCanvasHW.png"], None, None, GuiCanvasInterface.canvasIncrCanvasHeightWidth]
|
||||
CID_DECRHW_CANVAS = [0x113, TID_COMMAND, "Decrease canvas size", \
|
||||
"Decrease canvas size", ["toolDecrCanvasHW.png"], None, None, GuiCanvasInterface.canvasDecrCanvasHeightWidth]
|
||||
CID_INCRW_BRUSH = [0x114, TID_COMMAND, "Increase brush width", \
|
||||
"Increase brush width", ["toolIncrBrushW.png"], None, None, GuiCanvasInterface.canvasIncrBrushWidth]
|
||||
CID_DECRW_BRUSH = [0x115, TID_COMMAND, "Decrease brush width", \
|
||||
"Decrease brush width", ["toolDecrBrushW.png"], None, None, GuiCanvasInterface.canvasDecrBrushWidth]
|
||||
CID_INCRH_BRUSH = [0x116, TID_COMMAND, "Increase brush height", \
|
||||
"Increase brush height", ["toolIncrBrushH.png"], None, None, GuiCanvasInterface.canvasIncrBrushHeight]
|
||||
CID_DECRH_BRUSH = [0x117, TID_COMMAND, "Decrease brush height", \
|
||||
"Decrease brush height", ["toolDecrBrushH.png"], None, None, GuiCanvasInterface.canvasDecrBrushHeight]
|
||||
CID_INCRHW_BRUSH = [0x118, TID_COMMAND, "Increase brush size", \
|
||||
"Increase brush size", ["toolIncrBrushHW.png"], None, None, GuiCanvasInterface.canvasIncrBrushHeightWidth]
|
||||
CID_DECRHW_BRUSH = [0x119, TID_COMMAND, "Decrease brush size", \
|
||||
"Decrease brush size", ["toolDecrBrushHW.png"], None, None, GuiCanvasInterface.canvasDecrBrushHeightWidth]
|
||||
CID_SOLID_BRUSH = [0x11a, TID_SELECT, "Solid brush", "Solid brush", None, None, True, GuiCanvasInterface.canvasBrushSolid]
|
||||
# {{{ Commands (0x0100-0x0fff)
|
||||
#
|
||||
# MID_FILE
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_NEW = [0x0100, TID_COMMAND, "New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None, GuiCanvasInterface.canvasNew]
|
||||
CID_OPEN = [0x0101, TID_COMMAND, "Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None, GuiCanvasInterface.canvasOpen]
|
||||
CID_SAVE = [0x0102, TID_COMMAND, "Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None, GuiCanvasInterface.canvasSave]
|
||||
CID_SAVEAS = [0x0103, TID_COMMAND, "Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None, GuiCanvasInterface.canvasSaveAs]
|
||||
CID_EXPORT_CLIPB = [0x0104, TID_COMMAND, "Export to clipboard", "&Export to clipboard", None, None, None, GuiCanvasInterface.canvasExportToClipboard]
|
||||
CID_EXPORT_AS_PNG = [0x0105, TID_COMMAND, "Export as PNG...", "Export as PN&G...", None, None, None, GuiCanvasInterface.canvasExportAsPng]
|
||||
CID_EXPORT_IMGUR = [0x0106, TID_COMMAND, "Export to Imgur...", "Export to I&mgur...", None, None, haveUrllib, GuiCanvasInterface.canvasExportImgur]
|
||||
CID_EXPORT_PASTEBIN = [0x0107, TID_COMMAND, "Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib, GuiCanvasInterface.canvasExportPastebin]
|
||||
CID_IMPORT_CLIPB = [0x0108, TID_COMMAND, "Import from clipboard", "&Import from clipboard", None, None, None, GuiCanvasInterface.canvasImportFromClipboard]
|
||||
CID_EXIT = [0x0109, TID_COMMAND, "Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None, GuiCanvasInterface.canvasExit]
|
||||
|
||||
CID_RECT = [0x150, TID_SELECT, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True, GuiCanvasInterface.canvasToolRect]
|
||||
CID_CIRCLE = [0x151, TID_SELECT, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False, GuiCanvasInterface.canvasToolCircle]
|
||||
CID_FILL = [0x152, TID_SELECT, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False, GuiCanvasInterface.canvasToolFill]
|
||||
CID_LINE = [0x153, TID_SELECT, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False, GuiCanvasInterface.canvasToolLine]
|
||||
CID_TEXT = [0x154, TID_SELECT, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False, GuiCanvasInterface.canvasToolText]
|
||||
CID_CLONE_SELECT = [0x155, TID_SELECT, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False, GuiCanvasInterface.canvasToolSelectClone]
|
||||
CID_MOVE_SELECT = [0x156, TID_SELECT, "Move", "&Move", ["toolMove.png"], [wx.ACCEL_CTRL, ord("M")], False, GuiCanvasInterface.canvasToolSelectMove]
|
||||
#
|
||||
# MID_EDIT
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_UNDO = [0x0200, TID_COMMAND, "Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False, GuiCanvasInterface.canvasUndo]
|
||||
CID_REDO = [0x0201, TID_COMMAND, "Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False, GuiCanvasInterface.canvasRedo]
|
||||
CID_CUT = [0x0202, TID_COMMAND, "Cut", "Cu&t", ["", wx.ART_CUT], None, False, GuiCanvasInterface.canvasCut]
|
||||
CID_COPY = [0x0203, TID_COMMAND, "Copy", "&Copy", ["", wx.ART_COPY], None, False, GuiCanvasInterface.canvasCopy]
|
||||
CID_PASTE = [0x0204, TID_COMMAND, "Paste", "&Paste", ["", wx.ART_PASTE], None, False, GuiCanvasInterface.canvasPaste]
|
||||
CID_DELETE = [0x0205, TID_COMMAND, "Delete", "De&lete", ["", wx.ART_DELETE], None, False, GuiCanvasInterface.canvasDelete]
|
||||
CID_INCRW_CANVAS = [0x0206, TID_COMMAND, "Increase canvas width", "Increase canvas width", ["toolIncrCanvasW.png"], None, None, GuiCanvasInterface.canvasIncrCanvasWidth]
|
||||
CID_DECRW_CANVAS = [0x0207, TID_COMMAND, "Decrease canvas width", "Decrease canvas width", ["toolDecrCanvasW.png"], None, None, GuiCanvasInterface.canvasDecrCanvasWidth]
|
||||
CID_INCRH_CANVAS = [0x0208, TID_COMMAND, "Increase canvas height", "Increase canvas height", ["toolIncrCanvasH.png"], None, None, GuiCanvasInterface.canvasIncrCanvasHeight]
|
||||
CID_DECRH_CANVAS = [0x0209, TID_COMMAND, "Decrease canvas height", "Decrease canvas height", ["toolDecrCanvasH.png"], None, None, GuiCanvasInterface.canvasDecrCanvasHeight]
|
||||
CID_INCRHW_CANVAS = [0x020a, TID_COMMAND, "Increase canvas size", "Increase canvas size", ["toolIncrCanvasHW.png"], None, None, GuiCanvasInterface.canvasIncrCanvasHeightWidth]
|
||||
CID_DECRHW_CANVAS = [0x020b, TID_COMMAND, "Decrease canvas size", "Decrease canvas size", ["toolDecrCanvasHW.png"], None, None, GuiCanvasInterface.canvasDecrCanvasHeightWidth]
|
||||
CID_INCRW_BRUSH = [0x020c, TID_COMMAND, "Increase brush width", "Increase brush width", ["toolIncrBrushW.png"], None, None, GuiCanvasInterface.canvasIncrBrushWidth]
|
||||
CID_DECRW_BRUSH = [0x020d, TID_COMMAND, "Decrease brush width", "Decrease brush width", ["toolDecrBrushW.png"], None, None, GuiCanvasInterface.canvasDecrBrushWidth]
|
||||
CID_INCRH_BRUSH = [0x020e, TID_COMMAND, "Increase brush height", "Increase brush height", ["toolIncrBrushH.png"], None, None, GuiCanvasInterface.canvasIncrBrushHeight]
|
||||
CID_DECRH_BRUSH = [0x020f, TID_COMMAND, "Decrease brush height", "Decrease brush height", ["toolDecrBrushH.png"], None, None, GuiCanvasInterface.canvasDecrBrushHeight]
|
||||
CID_INCRHW_BRUSH = [0x0210, TID_COMMAND, "Increase brush size", "Increase brush size", ["toolIncrBrushHW.png"], None, None, GuiCanvasInterface.canvasIncrBrushHeightWidth]
|
||||
CID_DECRHW_BRUSH = [0x0211, TID_COMMAND, "Decrease brush size", "Decrease brush size", ["toolDecrBrushHW.png"], None, None, GuiCanvasInterface.canvasDecrBrushHeightWidth]
|
||||
CID_SOLID_BRUSH = [0x0212, TID_SELECT, "Solid brush", "Solid brush", None, None, True, GuiCanvasInterface.canvasBrushSolid]
|
||||
|
||||
CID_COLOUR00 = [0x1a0, TID_SELECT, "Colour #00", "Colour #00", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR01 = [0x1a1, TID_SELECT, "Colour #01", "Colour #01", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR02 = [0x1a2, TID_SELECT, "Colour #02", "Colour #02", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR03 = [0x1a3, TID_SELECT, "Colour #03", "Colour #03", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR04 = [0x1a4, TID_SELECT, "Colour #04", "Colour #04", None, None, True, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR05 = [0x1a5, TID_SELECT, "Colour #05", "Colour #05", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR06 = [0x1a6, TID_SELECT, "Colour #06", "Colour #06", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR07 = [0x1a7, TID_SELECT, "Colour #07", "Colour #07", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR08 = [0x1a8, TID_SELECT, "Colour #08", "Colour #08", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR09 = [0x1a9, TID_SELECT, "Colour #09", "Colour #09", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR10 = [0x1aa, TID_SELECT, "Colour #10", "Colour #10", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR11 = [0x1ab, TID_SELECT, "Colour #11", "Colour #11", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR12 = [0x1ac, TID_SELECT, "Colour #12", "Colour #12", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR13 = [0x1ad, TID_SELECT, "Colour #13", "Colour #13", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR14 = [0x1ae, TID_SELECT, "Colour #14", "Colour #14", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR15 = [0x1af, TID_SELECT, "Colour #15", "Colour #15", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
#
|
||||
# MID_TOOLS
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_RECT = [0x0300, TID_SELECT, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True, GuiCanvasInterface.canvasToolRect]
|
||||
CID_CIRCLE = [0x0301, TID_SELECT, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False, GuiCanvasInterface.canvasToolCircle]
|
||||
CID_FILL = [0x0302, TID_SELECT, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False, GuiCanvasInterface.canvasToolFill]
|
||||
CID_LINE = [0x0303, TID_SELECT, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False, GuiCanvasInterface.canvasToolLine]
|
||||
CID_TEXT = [0x0304, TID_SELECT, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False, GuiCanvasInterface.canvasToolText]
|
||||
CID_CLONE_SELECT = [0x0305, TID_SELECT, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False, GuiCanvasInterface.canvasToolSelectClone]
|
||||
CID_MOVE_SELECT = [0x0306, TID_SELECT, "Move", "&Move", ["toolMove.png"], [wx.ACCEL_CTRL, ord("M")], False, GuiCanvasInterface.canvasToolSelectMove]
|
||||
|
||||
CID_ABOUT = [0x1b0, TID_COMMAND, "About", "&About", None, None, True, GuiCanvasInterface.canvasAbout]
|
||||
#
|
||||
# BID_TOOLBAR
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_COLOUR00 = [0x0400, TID_SELECT, "Colour #00", "Colour #00", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR01 = [0x0401, TID_SELECT, "Colour #01", "Colour #01", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR02 = [0x0402, TID_SELECT, "Colour #02", "Colour #02", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR03 = [0x0403, TID_SELECT, "Colour #03", "Colour #03", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR04 = [0x0404, TID_SELECT, "Colour #04", "Colour #04", None, None, True, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR05 = [0x0405, TID_SELECT, "Colour #05", "Colour #05", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR06 = [0x0406, TID_SELECT, "Colour #06", "Colour #06", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR07 = [0x0407, TID_SELECT, "Colour #07", "Colour #07", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR08 = [0x0408, TID_SELECT, "Colour #08", "Colour #08", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR09 = [0x0409, TID_SELECT, "Colour #09", "Colour #09", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR10 = [0x040a, TID_SELECT, "Colour #10", "Colour #10", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR11 = [0x040b, TID_SELECT, "Colour #11", "Colour #11", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR12 = [0x040c, TID_SELECT, "Colour #12", "Colour #12", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR13 = [0x040d, TID_SELECT, "Colour #13", "Colour #13", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR14 = [0x040e, TID_SELECT, "Colour #14", "Colour #14", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
CID_COLOUR15 = [0x040f, TID_SELECT, "Colour #15", "Colour #15", None, None, False, GuiCanvasInterface.canvasColour]
|
||||
|
||||
#
|
||||
# MID_ABOUT
|
||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||
CID_ABOUT = [0x0500, TID_COMMAND, "About", "&About", None, None, True, GuiCanvasInterface.canvasAbout]
|
||||
# }}}
|
||||
# {{{ Menus
|
||||
MID_FILE = (0x300, TID_MENU, "File", "&File", ( \
|
||||
CID_NEW, CID_OPEN, CID_SAVE, CID_SAVEAS, NID_MENU_SEP, \
|
||||
CID_EXPORT_AS_PNG, CID_EXPORT_IMGUR, CID_EXPORT_PASTEBIN, NID_MENU_SEP, \
|
||||
CID_EXIT))
|
||||
MID_EDIT = (0x301, TID_MENU, "Edit", "&Edit", ( \
|
||||
CID_UNDO, CID_REDO, NID_MENU_SEP, \
|
||||
CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_MENU_SEP, \
|
||||
CID_INCRW_CANVAS, CID_DECRW_CANVAS, CID_INCRH_CANVAS, CID_DECRH_CANVAS, NID_MENU_SEP, \
|
||||
CID_INCRHW_CANVAS, CID_DECRHW_CANVAS, NID_MENU_SEP, \
|
||||
CID_INCRW_BRUSH, CID_DECRW_BRUSH, CID_INCRH_BRUSH, CID_DECRH_BRUSH, NID_MENU_SEP, \
|
||||
CID_INCRHW_BRUSH, CID_DECRHW_BRUSH, NID_MENU_SEP, \
|
||||
CID_SOLID_BRUSH))
|
||||
MID_TOOLS = (0x302, TID_MENU, "Tools", "&Tools", ( \
|
||||
CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT))
|
||||
MID_ABOUT = (0x303, TID_MENU, "Help", "&Help", ( \
|
||||
CID_ABOUT,))
|
||||
# {{{ Menus (0x1100-0x1fff)
|
||||
MID_FILE = (0x1100, TID_MENU, "File", "&File", (CID_NEW, CID_OPEN, CID_SAVE, CID_SAVEAS, NID_MENU_SEP, CID_EXPORT_CLIPB, CID_EXPORT_AS_PNG, CID_EXPORT_IMGUR, CID_EXPORT_PASTEBIN, NID_MENU_SEP, CID_IMPORT_CLIPB, NID_MENU_SEP, CID_EXIT))
|
||||
MID_EDIT = (0x1101, TID_MENU, "Edit", "&Edit", (CID_UNDO, CID_REDO, NID_MENU_SEP, CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_MENU_SEP, CID_INCRW_CANVAS, CID_DECRW_CANVAS, CID_INCRH_CANVAS, CID_DECRH_CANVAS, NID_MENU_SEP, CID_INCRHW_CANVAS, CID_DECRHW_CANVAS, NID_MENU_SEP, CID_INCRW_BRUSH, CID_DECRW_BRUSH, CID_INCRH_BRUSH, CID_DECRH_BRUSH, NID_MENU_SEP, CID_INCRHW_BRUSH, CID_DECRHW_BRUSH, NID_MENU_SEP, CID_SOLID_BRUSH))
|
||||
MID_TOOLS = (0x1102, TID_MENU, "Tools", "&Tools", (CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT))
|
||||
MID_HELP = (0x1103, TID_MENU, "Help", "&Help", (CID_ABOUT,))
|
||||
# }}}
|
||||
# {{{ Toolbars
|
||||
BID_TOOLBAR = (0x400, TID_TOOLBAR, ( \
|
||||
CID_NEW, CID_OPEN, CID_SAVE, CID_SAVEAS, NID_TOOLBAR_HSEP, \
|
||||
CID_UNDO, CID_REDO, NID_TOOLBAR_HSEP, \
|
||||
CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_TOOLBAR_HSEP, \
|
||||
CID_INCRW_CANVAS, CID_DECRW_CANVAS, CID_INCRH_CANVAS, CID_DECRH_CANVAS, NID_TOOLBAR_HSEP, \
|
||||
CID_INCRHW_CANVAS, CID_DECRHW_CANVAS, NID_TOOLBAR_HSEP, \
|
||||
CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT, \
|
||||
NID_TOOLBAR_VSEP, \
|
||||
CID_COLOUR00, CID_COLOUR01, CID_COLOUR02, CID_COLOUR03, CID_COLOUR04, \
|
||||
CID_COLOUR05, CID_COLOUR06, CID_COLOUR07, CID_COLOUR08, CID_COLOUR09, \
|
||||
CID_COLOUR10, CID_COLOUR11, CID_COLOUR12, CID_COLOUR13, CID_COLOUR14, \
|
||||
CID_COLOUR15, NID_TOOLBAR_HSEP, \
|
||||
CID_INCRW_BRUSH, CID_DECRW_BRUSH, CID_INCRH_BRUSH, CID_DECRH_BRUSH, NID_TOOLBAR_HSEP, \
|
||||
CID_INCRHW_BRUSH, CID_DECRHW_BRUSH))
|
||||
# {{{ Toolbars (0x2100-0x2fff)
|
||||
BID_TOOLBAR = (0x2100, TID_TOOLBAR, (CID_NEW, CID_OPEN, CID_SAVE, CID_SAVEAS, NID_TOOLBAR_HSEP, CID_UNDO, CID_REDO, NID_TOOLBAR_HSEP, CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_TOOLBAR_HSEP, CID_INCRW_CANVAS, CID_DECRW_CANVAS, CID_INCRH_CANVAS, CID_DECRH_CANVAS, NID_TOOLBAR_HSEP, CID_INCRHW_CANVAS, CID_DECRHW_CANVAS, NID_TOOLBAR_HSEP, CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT, NID_TOOLBAR_VSEP, CID_COLOUR00, CID_COLOUR01, CID_COLOUR02, CID_COLOUR03, CID_COLOUR04, CID_COLOUR05, CID_COLOUR06, CID_COLOUR07, CID_COLOUR08, CID_COLOUR09, CID_COLOUR10, CID_COLOUR11, CID_COLOUR12, CID_COLOUR13, CID_COLOUR14, CID_COLOUR15, NID_TOOLBAR_HSEP, CID_INCRW_BRUSH, CID_DECRW_BRUSH, CID_INCRH_BRUSH, CID_DECRH_BRUSH, NID_TOOLBAR_HSEP, CID_INCRHW_BRUSH, CID_DECRHW_BRUSH))
|
||||
# }}}
|
||||
# {{{ Accelerators (hotkeys)
|
||||
AID_EDIT = (0x500, TID_ACCELS, ( \
|
||||
CID_NEW, CID_OPEN, CID_SAVE, CID_EXIT, CID_UNDO, CID_REDO, \
|
||||
CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT))
|
||||
# {{{ Accelerators (hotkeys) (0x3100-0x3fff)
|
||||
AID_EDIT = (0x3100, TID_ACCELS, (CID_NEW, CID_OPEN, CID_SAVE, CID_EXIT, CID_UNDO, CID_REDO, CID_RECT, CID_CIRCLE, CID_FILL, CID_LINE, CID_TEXT, CID_CLONE_SELECT, CID_MOVE_SELECT))
|
||||
# }}}
|
||||
# {{{ Lists
|
||||
LID_ACCELS = (0x600, TID_LIST, (AID_EDIT))
|
||||
LID_MENUS = (0x601, TID_LIST, (MID_FILE, MID_EDIT, MID_TOOLS, MID_ABOUT))
|
||||
LID_TOOLBARS = (0x602, TID_LIST, (BID_TOOLBAR))
|
||||
# {{{ Lists (0x4100-0x4fff)
|
||||
LID_ACCELS = (0x4100, TID_LIST, (AID_EDIT))
|
||||
LID_MENUS = (0x4101, TID_LIST, (MID_FILE, MID_EDIT, MID_TOOLS, MID_HELP))
|
||||
LID_TOOLBARS = (0x4102, TID_LIST, (BID_TOOLBAR))
|
||||
# }}}
|
||||
|
||||
# {{{ _initIcon(self): XXX
|
||||
def _initIcon(self):
|
||||
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
||||
iconPathName = iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
||||
icon = wx.Icon()
|
||||
icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY))
|
||||
self.SetIcon(icon)
|
||||
# }}}
|
||||
# {{{ _initPaletteToolBitmaps(self): XXX
|
||||
def _initPaletteToolBitmaps(self):
|
||||
paletteDescr = ( \
|
||||
@ -225,21 +207,20 @@ class GuiFrame(GuiGeneralFrame):
|
||||
def __init__(self, parent, appSize=(840, 630), defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14)):
|
||||
self._initPaletteToolBitmaps()
|
||||
self.panelSkin = super().__init__(parent, wx.ID_ANY, "", size=appSize)
|
||||
self.lastPanelState, self.panelCanvas = {}, None
|
||||
self._initIcon()
|
||||
|
||||
self.panelCanvas = Canvas(self.panelSkin, parentFrame=self, \
|
||||
canvasInterface=GuiCanvasInterface, \
|
||||
defaultCanvasPos=defaultCanvasPos, \
|
||||
defaultCanvasSize=defaultCanvasSize, \
|
||||
defaultCellSize=defaultCellSize)
|
||||
self.panelCanvas.canvasInterface.canvasNew(None)
|
||||
|
||||
self.sizerSkin.AddSpacer(5)
|
||||
self.sizerSkin.Add(self.panelCanvas, 0, wx.ALL|wx.EXPAND, 14)
|
||||
self.panelSkin.SetSizer(self.sizerSkin)
|
||||
self.panelSkin.SetAutoLayout(1)
|
||||
self.sizerSkin.Fit(self.panelSkin)
|
||||
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
||||
iconPathName = iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
||||
icon = wx.Icon()
|
||||
icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY))
|
||||
self.SetIcon(icon)
|
||||
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=0
|
||||
|
@ -24,9 +24,6 @@ NID_TOOLBAR_VSEP = (0x202, TID_NOTHING)
|
||||
|
||||
class GuiGeneralFrame(wx.Frame):
|
||||
"""XXX"""
|
||||
accelItemsById = itemsById = menuItemsById = toolBarItemsById = None
|
||||
statusBar = toolBars = None
|
||||
panelSkin = sizerSkin = None
|
||||
|
||||
# {{{ _initAccelTable(self, accelsDescr): XXX
|
||||
def _initAccelTable(self, accelsDescr):
|
||||
|
Loading…
Reference in New Issue
Block a user