2019-09-10 04:14:12 -04:00
|
|
|
#!/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
|
2019-09-12 06:49:53 -04:00
|
|
|
from RoarAssetsWindow import RoarAssetsWindow
|
2019-09-10 06:06:56 -04:00
|
|
|
from RoarCanvasCommands import RoarCanvasCommands
|
2019-09-10 04:14:12 -04:00
|
|
|
from RoarCanvasWindow import RoarCanvasWindow
|
|
|
|
|
|
|
|
from glob import glob
|
|
|
|
import os, random, sys
|
|
|
|
|
|
|
|
class RoarClient(GuiFrame):
|
|
|
|
# {{{ _getIconPathName(self)
|
|
|
|
def _getIconPathName(self):
|
|
|
|
iconPathNames = glob(os.path.join("assets", "images", "logo*.bmp"))
|
|
|
|
return iconPathNames[random.randint(0, len(iconPathNames) - 1)]
|
|
|
|
# }}}
|
|
|
|
# {{{ _initToolBitmaps(self, toolBars)
|
|
|
|
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"])
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# {{{ onChar(self, event)
|
|
|
|
def onChar(self, event):
|
|
|
|
self.canvasPanel.onKeyboardInput(event)
|
|
|
|
# }}}
|
|
|
|
# {{{ onMouseWheel(self, event)
|
|
|
|
def onMouseWheel(self, event):
|
|
|
|
self.canvasPanel.GetEventHandler().ProcessEvent(event)
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
#
|
|
|
|
# __init__(self, parent, defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14), size=(840, 630), title=""): initialisation method
|
|
|
|
def __init__(self, parent, defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14), size=(840, 630), title=""):
|
|
|
|
super().__init__(self._getIconPathName(), size, parent, title)
|
|
|
|
self.canvas = Canvas(defaultCanvasSize)
|
2019-09-10 06:06:56 -04:00
|
|
|
self.canvasPanel = RoarCanvasWindow(GuiCanvasWxBackend, self.canvas, defaultCellSize, RoarCanvasCommands, self.panelSkin, self, defaultCanvasPos, defaultCellSize, defaultCanvasSize)
|
2019-09-10 06:28:26 -04:00
|
|
|
self.loadAccels(self.canvasPanel.commands.menus, self.canvasPanel.commands.toolBars)
|
2019-09-10 06:06:56 -04:00
|
|
|
self.loadMenus(self.canvasPanel.commands.menus)
|
|
|
|
self._initToolBitmaps(self.canvasPanel.commands.toolBars)
|
|
|
|
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
2019-09-10 04:14:12 -04:00
|
|
|
|
2019-09-10 06:06:56 -04:00
|
|
|
self.canvasPanel.commands.canvasNew(None)
|
Implements merged object tool & flip operators.
assets/images/toolObject.png: added.
liboperators/Operator{,Flip{Horizontal,Vertical}}.py: initial implementation.
libroar/RoarCanvasCommands.py: adds RoarCanvasCommandsOperators.
libroar/RoarCanvasCommandsOperators.py: initial implementation.
libroar/Roar{CanvasCommands{,Tools},Client}.py: replaces ToolSelect{Clone,Move} w/ ToolObject.
libroar/RoarCanvasWindow.py:RoarCanvasWindowDropTarget.OnDropText(): update ToolObject() invocation.
libroar/RoarCanvasWindow.py:{applyTool,onMouseInput}(): pass keyModifiers to Tool.onMouseEvent().
libroar/RoarCanvasWindow.py:applyTool(): only switch back to lastTool if current object tool contains an external object.
libroar/RoarCanvasWindow.py:onLeaveWindow(): disable hiding cursor for now.
libtools/Tool{,Circle,Fill,Line,Rect,Text}.py:onMouseEvent(): update type signature.
libtools/Tool{Object,Select{,Clone,Move}}.py: merged into libtools/ToolObject.py.
roar.py: add liboperators to sys.path[].
assets/text/TODO: updated.
2019-09-15 05:06:25 -04:00
|
|
|
self.canvasPanel.commands.canvasTool(self.canvasPanel.commands.canvasTool, 4)(None)
|
2019-09-10 06:06:56 -04:00
|
|
|
self.canvasPanel.commands.update(brushSize=self.canvasPanel.brushSize, colours=self.canvasPanel.brushColours)
|
2019-09-10 04:14:12 -04:00
|
|
|
self.addWindow(self.canvasPanel, expand=True)
|
2019-09-12 06:49:53 -04:00
|
|
|
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
|
|
|
|
self.canvasPanel.commands.canvasAssetsWindowShow(None)
|
2019-09-10 04:14:12 -04:00
|
|
|
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|