2019-09-10 10:06:56 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# RoarCanvasCommandsTools.py
|
|
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
|
|
#
|
|
|
|
|
|
|
|
from GuiFrame import GuiSelectDecorator
|
|
|
|
from ToolCircle import ToolCircle
|
|
|
|
from ToolFill import ToolFill
|
|
|
|
from ToolLine import ToolLine
|
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 09:06:25 +00:00
|
|
|
from ToolObject import ToolObject
|
2019-09-10 10:06:56 +00:00
|
|
|
from ToolRect import ToolRect
|
|
|
|
from ToolText import ToolText
|
|
|
|
import wx
|
|
|
|
|
|
|
|
class RoarCanvasCommandsTools():
|
|
|
|
# {{{ canvasTool(self, f, idx)
|
|
|
|
@GuiSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False)
|
2019-09-15 19:33:19 +00:00
|
|
|
@GuiSelectDecorator(1, "Cursor", "C&ursor", ["toolCursor.png"], [wx.ACCEL_CTRL, ord("U")], False)
|
|
|
|
@GuiSelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False)
|
|
|
|
@GuiSelectDecorator(3, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False)
|
|
|
|
@GuiSelectDecorator(4, "Object", "&Object", ["toolObject.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
|
|
|
@GuiSelectDecorator(5, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True)
|
|
|
|
@GuiSelectDecorator(6, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasTool(self, f, idx):
|
|
|
|
def canvasTool_(event):
|
2019-09-15 19:33:19 +00:00
|
|
|
self.lastTool, self.currentTool = self.currentTool, [ToolCircle, None, ToolFill, ToolLine, ToolObject, ToolRect, ToolText][idx]
|
|
|
|
if self.currentTool != None:
|
|
|
|
self.currentTool = self.currentTool()
|
2019-09-10 10:06:56 +00:00
|
|
|
self.parentFrame.menuItemsById[self.canvasTool.attrList[idx]["id"]].Check(True)
|
|
|
|
toolBar = self.parentFrame.toolBarItemsById[self.canvasTool.attrList[idx]["id"]].GetToolBar()
|
|
|
|
toolBar.ToggleTool(self.canvasTool.attrList[idx]["id"], True)
|
2019-09-15 19:33:19 +00:00
|
|
|
if self.currentTool != None:
|
|
|
|
self.update(toolName=self.currentTool.name)
|
|
|
|
viewRect = self.parentCanvas.GetViewStart()
|
|
|
|
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
|
Fully implement {{arrow keys,backspace,enter},arrow keys} in {text,} tool{,s}.
libroar/RoarCanvasWindow.py:applyTool(): delegate updating of brushPos to ToolText if current tool.
libroar/RoarCanvasWindow.py:applyTool(): fix function result.
libroar/RoarCanvasWindow.py:applyTool(): pass updated set of arguments to on{Keyboard,Mouse}Event().
libroar/RoarCanvasWindow.py:onKeyboardInput(): allow wrapping around canvas when receiving cursor key input.
libroar/RoarCanvasWindow.py:onKeyboardInput(): supply keyCode or None to applyTool().
libroar/RoarCanvas{CommandsTools,Window}.py: supply keyCode or None to applyTool().
libtools/Tool{,Circle,Fill,Line,Object,Rect}.py:on{Keyboard,Mouse}Event(): update type signature.
libtools/ToolText.py:onKeyboardEvent(): fully implement {arrow keys,backspace,enter}.
libtools/ToolText.py:onKeyboardEvent(): update cursor when necessary.
libtools/ToolText.py:onMouseEvent(): correctly set brushPos if mouseLeftDown or mouseRightDown.
libtools/ToolText.py:__init__(): removed.
assets/text/TODO: updated.
2019-09-16 07:55:30 +00:00
|
|
|
self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect)
|
2019-09-15 19:33:19 +00:00
|
|
|
else:
|
|
|
|
self.update(toolName="Cursor")
|
2019-09-10 10:06:56 +00:00
|
|
|
setattr(canvasTool_, "attrDict", f.attrList[idx])
|
|
|
|
setattr(canvasTool_, "isSelect", True)
|
|
|
|
return canvasTool_
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
#
|
|
|
|
# __init__(self)
|
|
|
|
def __init__(self):
|
|
|
|
self.menus = (
|
|
|
|
("&Tools",
|
2019-09-15 19:33:19 +00:00
|
|
|
self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 3), self.canvasTool(self.canvasTool, 6), self.canvasTool(self.canvasTool, 4),
|
2019-09-10 10:06:56 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
self.toolBars = ()
|
2019-09-12 10:49:53 +00:00
|
|
|
self.currentTool, self.lastTool = None, None
|
2019-09-10 10:06:56 +00:00
|
|
|
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=0
|