mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
libgui/GuiFrame.py:{_init,load}Menu(): split from loadMenu(), implement nested (sub)menus.
libroar/RoarCanvasCommandsEdit.py: put {brush,canvas} size commands into submenu. libroar/RoarCanvasCommandsFile.py: put {ex,im}port commands into submenu. assets/text/TODO: updated.
This commit is contained in:
parent
7226639977
commit
245925406e
@ -15,8 +15,9 @@ High-priority list:
|
|||||||
4) GUI:
|
4) GUI:
|
||||||
a) switch to GTK
|
a) switch to GTK
|
||||||
b) replace logo w/ canvas panel in About dialogue
|
b) replace logo w/ canvas panel in About dialogue
|
||||||
c) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3)
|
c) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
||||||
d) {copy,cut,insert from,paste}, {edit asset in new canvas,import from {canvas,object}}
|
d) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3)
|
||||||
|
e) {copy,cut,insert from,paste}, {edit asset in new canvas,import from {canvas,object}}
|
||||||
5) cleanup & refactor
|
5) cleanup & refactor
|
||||||
6) object tool: reset {clone,move} state on each transition to target state
|
6) object tool: reset {clone,move} state on each transition to target state
|
||||||
|
|
||||||
|
@ -63,12 +63,43 @@ class GuiFrame(wx.Frame):
|
|||||||
icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY))
|
icon.CopyFromBitmap(wx.Bitmap(iconPathName, wx.BITMAP_TYPE_ANY))
|
||||||
self.SetIcon(icon)
|
self.SetIcon(icon)
|
||||||
# }}}
|
# }}}
|
||||||
|
# {{{ _initMenu(self, menuItem, menuWindow)
|
||||||
|
def _initMenu(self, menuItem, menuWindow):
|
||||||
|
if menuItem == NID_MENU_SEP:
|
||||||
|
menuWindow.AppendSeparator()
|
||||||
|
else:
|
||||||
|
if menuItem.attrDict["id"] == None:
|
||||||
|
menuItem.attrDict["id"] = wx.NewId()
|
||||||
|
self.itemsById[menuItem.attrDict["id"]] = menuItem
|
||||||
|
if hasattr(menuItem, "isSelect"):
|
||||||
|
menuItemWindow = menuWindow.AppendRadioItem(menuItem.attrDict["id"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
||||||
|
elif hasattr(menuItem, "isSubMenu"):
|
||||||
|
menuItem.attrDict["menu"] = wx.Menu()
|
||||||
|
menuItemWindow = menuWindow.AppendSubMenu(menuItem.attrDict["menu"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
||||||
|
else:
|
||||||
|
menuItemWindow = menuWindow.Append(menuItem.attrDict["id"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
||||||
|
if menuItem.attrDict["accel"] != None:
|
||||||
|
menuItemWindow.SetAccel(menuItem.attrDict["accelEntry"])
|
||||||
|
self.menuItemsById[menuItem.attrDict["id"]] = menuItemWindow
|
||||||
|
self.Bind(wx.EVT_MENU, self.onMenu, menuItemWindow)
|
||||||
|
if menuItem.attrDict["initialState"] != None:
|
||||||
|
if hasattr(menuItem, "isSelect"):
|
||||||
|
menuItemWindow.Check(menuItem.attrDict["initialState"])
|
||||||
|
else:
|
||||||
|
menuItemWindow.Enable(menuItem.attrDict["initialState"])
|
||||||
|
# }}}
|
||||||
|
|
||||||
# {{{ loadAccels(self, menus, toolBars)
|
# {{{ loadAccels(self, menus, toolBars)
|
||||||
def loadAccels(self, menus, toolBars):
|
def loadAccels(self, menus, toolBars):
|
||||||
def loadAccels_(accels):
|
def loadAccels_(accels):
|
||||||
nonlocal accelTableEntries
|
nonlocal accelTableEntries
|
||||||
|
accels_ = []
|
||||||
for accel in accels:
|
for accel in accels:
|
||||||
|
if type(accel) == tuple:
|
||||||
|
accels_ += accel[1:]
|
||||||
|
else:
|
||||||
|
accels_ += [accel]
|
||||||
|
for accel in accels_:
|
||||||
if (not accel in [NID_MENU_SEP, NID_TOOLBAR_HSEP]) \
|
if (not accel in [NID_MENU_SEP, NID_TOOLBAR_HSEP]) \
|
||||||
and (accel.attrDict["accel"] != None):
|
and (accel.attrDict["accel"] != None):
|
||||||
accelTableEntries += [wx.AcceleratorEntry()]
|
accelTableEntries += [wx.AcceleratorEntry()]
|
||||||
@ -102,28 +133,13 @@ class GuiFrame(wx.Frame):
|
|||||||
for menu in menus:
|
for menu in menus:
|
||||||
menuWindow = wx.Menu()
|
menuWindow = wx.Menu()
|
||||||
for menuItem in menu[1:]:
|
for menuItem in menu[1:]:
|
||||||
if menuItem == NID_MENU_SEP:
|
if type(menuItem) == tuple:
|
||||||
menuWindow.AppendSeparator()
|
menuSubWindow = wx.Menu()
|
||||||
|
for menuSubItem in menuItem[1:]:
|
||||||
|
self._initMenu(menuSubItem, menuSubWindow)
|
||||||
|
menuWindow.AppendSubMenu(menuSubWindow, menuItem[0], menuItem[0])
|
||||||
else:
|
else:
|
||||||
if menuItem.attrDict["id"] == None:
|
self._initMenu(menuItem, menuWindow)
|
||||||
menuItem.attrDict["id"] = wx.NewId()
|
|
||||||
self.itemsById[menuItem.attrDict["id"]] = menuItem
|
|
||||||
if hasattr(menuItem, "isSelect"):
|
|
||||||
menuItemWindow = menuWindow.AppendRadioItem(menuItem.attrDict["id"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
|
||||||
elif hasattr(menuItem, "isSubMenu"):
|
|
||||||
menuItem.attrDict["menu"] = wx.Menu()
|
|
||||||
menuItemWindow = menuWindow.AppendSubMenu(menuItem.attrDict["menu"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
|
||||||
else:
|
|
||||||
menuItemWindow = menuWindow.Append(menuItem.attrDict["id"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
|
||||||
if menuItem.attrDict["accel"] != None:
|
|
||||||
menuItemWindow.SetAccel(menuItem.attrDict["accelEntry"])
|
|
||||||
self.menuItemsById[menuItem.attrDict["id"]] = menuItemWindow
|
|
||||||
self.Bind(wx.EVT_MENU, self.onMenu, menuItemWindow)
|
|
||||||
if menuItem.attrDict["initialState"] != None:
|
|
||||||
if hasattr(menuItem, "isSelect"):
|
|
||||||
menuItemWindow.Check(menuItem.attrDict["initialState"])
|
|
||||||
else:
|
|
||||||
menuItemWindow.Enable(menuItem.attrDict["initialState"])
|
|
||||||
menuBar.Append(menuWindow, menu[0])
|
menuBar.Append(menuWindow, menu[0])
|
||||||
self.SetMenuBar(menuBar)
|
self.SetMenuBar(menuBar)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -160,10 +160,11 @@ class RoarCanvasCommandsEdit():
|
|||||||
self.canvasUndo, self.canvasRedo, NID_MENU_SEP,
|
self.canvasUndo, self.canvasRedo, NID_MENU_SEP,
|
||||||
self.canvasCut, self.canvasCopy, self.canvasPaste,
|
self.canvasCut, self.canvasCopy, self.canvasPaste,
|
||||||
self.canvasDelete, NID_MENU_SEP,
|
self.canvasDelete, NID_MENU_SEP,
|
||||||
self.canvasCanvasSize(self.canvasCanvasSize, 1, True), self.canvasCanvasSize(self.canvasCanvasSize, 1, False), self.canvasCanvasSize(self.canvasCanvasSize, 0, True), self.canvasCanvasSize(self.canvasCanvasSize, 0, False), NID_MENU_SEP,
|
("Canvas size", self.canvasCanvasSize(self.canvasCanvasSize, 1, True), self.canvasCanvasSize(self.canvasCanvasSize, 1, False), self.canvasCanvasSize(self.canvasCanvasSize, 0, True), self.canvasCanvasSize(self.canvasCanvasSize, 0, False), NID_MENU_SEP,
|
||||||
self.canvasCanvasSize(self.canvasCanvasSize, 2, True), self.canvasCanvasSize(self.canvasCanvasSize, 2, False), NID_MENU_SEP,
|
self.canvasCanvasSize(self.canvasCanvasSize, 2, True), self.canvasCanvasSize(self.canvasCanvasSize, 2, False),),
|
||||||
self.canvasBrushSize(self.canvasBrushSize, 0, True), self.canvasBrushSize(self.canvasBrushSize, 0, False), self.canvasBrushSize(self.canvasBrushSize, 1, True), self.canvasBrushSize(self.canvasBrushSize, 1, False), NID_MENU_SEP,
|
("Brush size", self.canvasBrushSize(self.canvasBrushSize, 0, True), self.canvasBrushSize(self.canvasBrushSize, 0, False), self.canvasBrushSize(self.canvasBrushSize, 1, True), self.canvasBrushSize(self.canvasBrushSize, 1, False), NID_MENU_SEP,
|
||||||
self.canvasBrushSize(self.canvasBrushSize, 2, True), self.canvasBrushSize(self.canvasBrushSize, 2, False), NID_MENU_SEP,
|
self.canvasBrushSize(self.canvasBrushSize, 2, True), self.canvasBrushSize(self.canvasBrushSize, 2, False),),
|
||||||
|
NID_MENU_SEP,
|
||||||
self.canvasBrush(self.canvasBrush, 0), NID_MENU_SEP,
|
self.canvasBrush(self.canvasBrush, 0), NID_MENU_SEP,
|
||||||
self.canvasAssetsWindowHide, self.canvasAssetsWindowShow,
|
self.canvasAssetsWindowHide, self.canvasAssetsWindowShow,
|
||||||
),
|
),
|
||||||
|
@ -103,8 +103,9 @@ class RoarCanvasCommandsFile():
|
|||||||
if self._promptSaveChanges():
|
if self._promptSaveChanges():
|
||||||
self.parentFrame.Close(True)
|
self.parentFrame.Close(True)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasExportAsAnsi(self, event)
|
# {{{ canvasExportAsAnsi(self, event)
|
||||||
@GuiCommandDecorator("Export as ANSI...", "Export as ANSI...", None, None, None)
|
@GuiCommandDecorator("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:
|
||||||
if self.lastDir != None:
|
if self.lastDir != None:
|
||||||
@ -163,7 +164,7 @@ class RoarCanvasCommandsFile():
|
|||||||
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)
|
# {{{ canvasExportToClipboard(self, event)
|
||||||
@GuiCommandDecorator("Export to clipboard", "&Export to clipboard", None, None, None)
|
@GuiCommandDecorator("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))
|
||||||
rc, outBuffer = self.parentCanvas.canvas.exportStore.exportTextBuffer(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size)
|
rc, outBuffer = self.parentCanvas.canvas.exportStore.exportTextBuffer(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size)
|
||||||
@ -173,8 +174,9 @@ class RoarCanvasCommandsFile():
|
|||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
return True
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasImportAnsi(self, event)
|
# {{{ canvasImportAnsi(self, event)
|
||||||
@GuiCommandDecorator("Import ANSI...", "Import ANSI...", None, None, None)
|
@GuiCommandDecorator("Import ANSI...", "Import &ANSI...", None, None, None)
|
||||||
def canvasImportAnsi(self, event):
|
def canvasImportAnsi(self, event):
|
||||||
def canvasImportAnsi_(pathName):
|
def canvasImportAnsi_(pathName):
|
||||||
rc, error = self.parentCanvas.canvas.importStore.importAnsiFile(pathName)
|
rc, error = self.parentCanvas.canvas.importStore.importAnsiFile(pathName)
|
||||||
@ -182,7 +184,7 @@ class RoarCanvasCommandsFile():
|
|||||||
self._importFile(canvasImportAnsi_, True, "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
self._importFile(canvasImportAnsi_, True, "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasImportFromClipboard(self, event)
|
# {{{ canvasImportFromClipboard(self, event)
|
||||||
@GuiCommandDecorator("Import from clipboard", "&Import from clipboard", None, None, None)
|
@GuiCommandDecorator("Import from clipboard", "Import from &clipboard", None, None, None)
|
||||||
def canvasImportFromClipboard(self, event):
|
def canvasImportFromClipboard(self, event):
|
||||||
def canvasImportFromClipboard_(pathName):
|
def canvasImportFromClipboard_(pathName):
|
||||||
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \
|
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \
|
||||||
@ -199,13 +201,14 @@ class RoarCanvasCommandsFile():
|
|||||||
self._import(canvasImportFromClipboard_, True, None)
|
self._import(canvasImportFromClipboard_, True, None)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasImportSauce(self, event)
|
# {{{ canvasImportSauce(self, event)
|
||||||
@GuiCommandDecorator("Import SAUCE...", "Import SAUCE...", None, None, None)
|
@GuiCommandDecorator("Import SAUCE...", "Import &SAUCE...", None, None, None)
|
||||||
def canvasImportSauce(self, event):
|
def canvasImportSauce(self, event):
|
||||||
def canvasImportSauce_(pathName):
|
def canvasImportSauce_(pathName):
|
||||||
rc, error = self.parentCanvas.canvas.importStore.importSauceFile(pathName)
|
rc, error = self.parentCanvas.canvas.importStore.importSauceFile(pathName)
|
||||||
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
|
||||||
self._importFile(canvasImportSauce_, True, "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
self._importFile(canvasImportSauce_, True, "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# {{{ canvasNew(self, event, newCanvasSize=None)
|
# {{{ canvasNew(self, event, newCanvasSize=None)
|
||||||
@GuiCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
|
@GuiCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
|
||||||
def canvasNew(self, event, newCanvasSize=None):
|
def canvasNew(self, event, newCanvasSize=None):
|
||||||
@ -275,8 +278,9 @@ class RoarCanvasCommandsFile():
|
|||||||
self.menus = (
|
self.menus = (
|
||||||
("&File",
|
("&File",
|
||||||
self.canvasNew, self.canvasOpen, self.canvasOpenRecent, self.canvasSave, self.canvasSaveAs, NID_MENU_SEP,
|
self.canvasNew, self.canvasOpen, self.canvasOpenRecent, self.canvasSave, self.canvasSaveAs, NID_MENU_SEP,
|
||||||
self.canvasExportAsAnsi, self.canvasExportToClipboard, self.canvasExportImgur, self.canvasExportPastebin, self.canvasExportAsPng, NID_MENU_SEP,
|
("&Export...", self.canvasExportAsAnsi, self.canvasExportToClipboard, self.canvasExportImgur, self.canvasExportPastebin, self.canvasExportAsPng,),
|
||||||
self.canvasImportAnsi, self.canvasImportFromClipboard, self.canvasImportSauce, NID_MENU_SEP,
|
("&Import...", self.canvasImportAnsi, self.canvasImportFromClipboard, self.canvasImportSauce,),
|
||||||
|
NID_MENU_SEP,
|
||||||
self.canvasExit,
|
self.canvasExit,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user