mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 23:36:36 +00:00
d5935dfbba
1) Assets window: adds clear list context menu item. 2) Assets window: allow deleting multiple selected items. 3) Assets window: fix list view cursor key navigation. 4) Backend: correctly blend transparent background cursor cells with canvas character cells. 5) Backend: correctly determine cell size & set font size. 6) Backend: correctly unmask cursor. 7) Backend: disable font anti-aliasing on Windows. 8) Backend: render transparent background cells as RGBA #303030FF. 9) Canvas window: adds <F1> accelerator for `View melp?' menu item. 10) Canvas window: implement {dockable,floating} toolbars w/ wx' AUI framework. 11) Canvas window: separate tools toolbar from edit commands toolbar & dock both on right-hand side alongside each other. 12) Flip horizontally tool: flip characters, including some Unicode symbols. 13) Flip vertically tool: flip additional Unicode symbols. 14) Text tool: don't process keyboard events w/ either of <{Alt,AltGr,Ctrl}> modifiers. assets/images/roar.png: updated.
70 lines
3.6 KiB
Python
70 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# RoarClient.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
from Canvas import Canvas
|
|
from GuiCanvasWxBackend import GuiCanvasWxBackend
|
|
from GuiFrame import GuiFrame, NID_TOOLBAR_HSEP
|
|
from RoarAssetsWindow import RoarAssetsWindow
|
|
from RoarCanvasCommands import RoarCanvasCommands
|
|
from RoarCanvasWindow import RoarCanvasWindow
|
|
|
|
from glob import glob
|
|
import os, random, sys, wx
|
|
|
|
class RoarClient(GuiFrame):
|
|
def _getIconPathName(self):
|
|
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
|
return iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
|
|
|
def _initToolBitmaps(self, toolBars):
|
|
basePathName = os.path.join(os.path.dirname(sys.argv[0]), "assets", "images")
|
|
for toolBar in toolBars:
|
|
for toolBarItem in [i for i in toolBar if i != NID_TOOLBAR_HSEP]:
|
|
toolBarItem.attrDict["icon"] = self.loadBitmap(basePathName, toolBarItem.attrDict["icon"])
|
|
|
|
def onChar(self, event):
|
|
self.canvasPanel.onKeyboardInput(event)
|
|
|
|
def onMouseWheel(self, event):
|
|
self.canvasPanel.GetEventHandler().ProcessEvent(event)
|
|
|
|
def onClose(self, event):
|
|
if not self.canvasPanel.commands.exiting:
|
|
closeFlag = self.canvasPanel.commands._promptSaveChanges()
|
|
else:
|
|
closeFlag = True
|
|
if closeFlag:
|
|
event.Skip();
|
|
|
|
def __init__(self, parent, defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), size=(840, 640), title=""):
|
|
super().__init__(self._getIconPathName(), size, parent, title)
|
|
self.canvas = Canvas(defaultCanvasSize)
|
|
self.canvasPanel = RoarCanvasWindow(GuiCanvasWxBackend, self.canvas, RoarCanvasCommands, self, defaultCanvasPos, defaultCanvasSize)
|
|
self.loadAccels(self.canvasPanel.commands.accels, self.canvasPanel.commands.menus, self.canvasPanel.commands.toolBars)
|
|
self.loadMenus(self.canvasPanel.commands.menus)
|
|
self._initToolBitmaps(self.canvasPanel.commands.toolBars)
|
|
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
|
|
|
self.canvasPanel.commands.canvasNew(None)
|
|
self.canvasPanel.commands.canvasTool(self.canvasPanel.commands.canvasTool, 1)(None)
|
|
self.canvasPanel.commands.update(brushSize=self.canvasPanel.brushSize, colours=self.canvasPanel.brushColours)
|
|
self.addWindow(self.canvasPanel)
|
|
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, self)
|
|
self.canvasPanel.commands.canvasAssetsWindowShow(None)
|
|
|
|
self.canvasPanel.operatorsMenu = wx.Menu()
|
|
for menuItem in self.canvasPanel.commands.menus[3][1:]:
|
|
menuItemWindow = self.canvasPanel.operatorsMenu.Append(menuItem.attrDict["id"], menuItem.attrDict["label"], menuItem.attrDict["caption"])
|
|
self.Bind(wx.EVT_MENU, self.onMenu, menuItemWindow)
|
|
self.canvasPanel.commands.canvasOpenRecent.attrDict["menu"].AppendSeparator()
|
|
self.canvasPanel.commands.canvasClearRecent.attrDict["id"] = wx.NewId()
|
|
menuItemWindow = self.canvasPanel.commands.canvasOpenRecent.attrDict["menu"].Append(self.canvasPanel.commands.canvasClearRecent.attrDict["id"], self.canvasPanel.commands.canvasClearRecent.attrDict["label"], self.canvasPanel.commands.canvasClearRecent.attrDict["caption"])
|
|
self.canvasPanel.commands.canvasOpenRecent.attrDict["menu"].Bind(wx.EVT_MENU, self.canvasPanel.commands.canvasClearRecent, menuItemWindow)
|
|
self.Bind(wx.EVT_CLOSE, self.onClose)
|
|
self.toolBarPanes[0].BestSize(0, 0).Right(); self.toolBarPanes[1].BestSize(0, 0).Right(); self.auiManager.Update();
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|