mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-21 23:06:38 +00:00
Implements cursor tool & arrow keys navigation.
assets/images/toolCursor.png: added. libroar/Roar{CanvasCommands{,Tools},Client}.py: adds cursor tool. libroar/RoarCanvasWindow.py:applyTool(): dummy-handle cursor tool. libroar/RoarCanvasWindow.py:onKeyboardInput(): update cursor position & cursor on {down,left,right,up} arrow key input. assets/text/TODO: updated.
This commit is contained in:
parent
aed3f7157c
commit
df8ee6fedf
BIN
assets/images/toolCursor.png
Executable file
BIN
assets/images/toolCursor.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 203 B |
@ -5,20 +5,18 @@
|
||||
5) Client-Server or Peer-to-Peer realtime collaboration
|
||||
6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
|
||||
7) Incremental auto{load,save} & {backup,restore} (needs Settings window)
|
||||
8) Composition, parametrisation & keying of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools
|
||||
8) Composition, parametrisation & keying of tools from higher-order operators (brushes, functions, filters, outlines, patterns & shaders) and unit tools
|
||||
9) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...)
|
||||
|
||||
High-priority list:
|
||||
1) unit tools: arrow, {cloud,speech bubble}, curve, measure, pick, polygon, triangle, unicode
|
||||
2) text tool: a) honour RTL text flow b) navigating w/ cursor keys c) pasting text
|
||||
3) operators: erase, rotate, scale, shift, slice, tile
|
||||
4) GUI:
|
||||
a) switch to GTK
|
||||
b) replace logo w/ canvas panel in About dialogue
|
||||
c) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
||||
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
|
||||
6) object tool: reset {clone,move} state on each transition to target state
|
||||
3) operators: rotate, scale, shift, slice, tile
|
||||
4) cleanup & refactor, switch to GTK
|
||||
5) GUI:
|
||||
a) replace logo w/ canvas panel in About dialogue
|
||||
b) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
||||
c) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3)
|
||||
d) {copy,cut,delete,insert from,paste}, {edit asset in new canvas,import from {canvas,object}}
|
||||
|
||||
vim:ff=dos tw=0
|
||||
|
@ -112,7 +112,7 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
|
||||
self.canvasCut, self.canvasCopy, self.canvasPaste, self.canvasDelete, NID_TOOLBAR_HSEP,
|
||||
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_TOOLBAR_HSEP,
|
||||
self.canvasCanvasSize(self.canvasCanvasSize, 2, True), self.canvasCanvasSize(self.canvasCanvasSize, 2, False), NID_TOOLBAR_HSEP,
|
||||
self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 3),
|
||||
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),
|
||||
])
|
||||
# XXX
|
||||
toolBars.append(
|
||||
|
@ -16,21 +16,27 @@ import wx
|
||||
class RoarCanvasCommandsTools():
|
||||
# {{{ canvasTool(self, f, idx)
|
||||
@GuiSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False)
|
||||
@GuiSelectDecorator(1, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False)
|
||||
@GuiSelectDecorator(2, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False)
|
||||
@GuiSelectDecorator(3, "Object", "&Object", ["toolObject.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
||||
@GuiSelectDecorator(4, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True)
|
||||
@GuiSelectDecorator(5, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False)
|
||||
@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)
|
||||
def canvasTool(self, f, idx):
|
||||
def canvasTool_(event):
|
||||
self.lastTool, self.currentTool = self.currentTool, [ToolCircle, ToolFill, ToolLine, ToolObject, ToolRect, ToolText][idx]()
|
||||
self.lastTool, self.currentTool = self.currentTool, [ToolCircle, None, ToolFill, ToolLine, ToolObject, ToolRect, ToolText][idx]
|
||||
if self.currentTool != None:
|
||||
self.currentTool = self.currentTool()
|
||||
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)
|
||||
self.update(toolName=self.currentTool.name)
|
||||
viewRect = self.parentCanvas.GetViewStart()
|
||||
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
|
||||
self.parentCanvas.applyTool(eventDc, True, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect)
|
||||
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)
|
||||
self.parentCanvas.applyTool(eventDc, True, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect)
|
||||
else:
|
||||
self.update(toolName="Cursor")
|
||||
setattr(canvasTool_, "attrDict", f.attrList[idx])
|
||||
setattr(canvasTool_, "isSelect", True)
|
||||
return canvasTool_
|
||||
@ -41,7 +47,7 @@ class RoarCanvasCommandsTools():
|
||||
def __init__(self):
|
||||
self.menus = (
|
||||
("&Tools",
|
||||
self.canvasTool(self.canvasTool, 4), self.canvasTool(self.canvasTool, 0), self.canvasTool(self.canvasTool, 1), self.canvasTool(self.canvasTool, 2), self.canvasTool(self.canvasTool, 5), self.canvasTool(self.canvasTool, 3),
|
||||
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),
|
||||
),
|
||||
)
|
||||
self.toolBars = ()
|
||||
|
@ -66,9 +66,15 @@ class RoarCanvasWindow(GuiWindow):
|
||||
or (self.lastCellState != [list(mapPoint), mouseDragging, mouseLeftDown, mouseRightDown, list(viewRect)])):
|
||||
self.brushPos = list(mapPoint)
|
||||
self.lastCellState = [list(mapPoint), mouseDragging, mouseLeftDown, mouseRightDown, list(viewRect)]
|
||||
rc, dirty = tool.onMouseEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyModifiers, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
|
||||
if tool != None:
|
||||
rc, dirty = tool.onMouseEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyModifiers, self.brushPos, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
|
||||
else:
|
||||
self.dispatchPatchSingle(eventDc, True, [*mapPoint, self.brushColours[0], self.brushColours[0], 0, " "] , viewRect)
|
||||
else:
|
||||
rc, dirty = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyChar, keyModifiers, self.brushPos, viewRect)
|
||||
if tool != None:
|
||||
rc, dirty = tool.onKeyboardEvent(self.brushColours, self.brushSize, self.canvas, self.dispatchPatchSingle, eventDc, keyChar, keyModifiers, self.brushPos, viewRect)
|
||||
else:
|
||||
self.dispatchPatchSingle(eventDc, True, [*mapPoint, self.brushColours[0], self.brushColours[0], 0, " "] , viewRect)
|
||||
if dirty:
|
||||
self.dirty = True
|
||||
self.commands.update(dirty=self.dirty, cellPos=self.brushPos, undoLevel=self.canvas.journal.patchesUndoLevel)
|
||||
@ -142,13 +148,24 @@ class RoarCanvasWindow(GuiWindow):
|
||||
|
||||
# {{{ onKeyboardInput(self, event)
|
||||
def onKeyboardInput(self, event):
|
||||
if (event.GetKeyCode() == wx.WXK_PAUSE) \
|
||||
and (event.GetModifiers() == wx.MOD_SHIFT):
|
||||
keyCode, keyModifiers = event.GetKeyCode(), event.GetModifiers()
|
||||
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
|
||||
if (keyCode == wx.WXK_PAUSE) \
|
||||
and (keyModifiers == wx.MOD_SHIFT):
|
||||
import pdb; pdb.set_trace()
|
||||
elif keyCode in (wx.WXK_DOWN, wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_UP):
|
||||
if (keyCode == wx.WXK_DOWN) and (self.brushPos[1] < (self.canvas.size[1] - 1)):
|
||||
self.brushPos = [self.brushPos[0], self.brushPos[1] + 1]
|
||||
elif (keyCode == wx.WXK_LEFT) and (self.brushPos[0] > 0):
|
||||
self.brushPos = [self.brushPos[0] - 1, self.brushPos[1]]
|
||||
elif (keyCode == wx.WXK_RIGHT) and (self.brushPos[0] < (self.canvas.size[0] - 1)):
|
||||
self.brushPos = [self.brushPos[0] + 1, self.brushPos[1]]
|
||||
elif (keyCode == wx.WXK_UP) and (self.brushPos[1] > 0):
|
||||
self.brushPos = [self.brushPos[0], self.brushPos[1] - 1]
|
||||
self.commands.update(cellPos=self.brushPos)
|
||||
self.applyTool(eventDc, True, None, None, self.brushPos, False, False, False, self.commands.currentTool, viewRect)
|
||||
else:
|
||||
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
|
||||
keyChar, keyModifiers = chr(event.GetUnicodeKey()), event.GetModifiers()
|
||||
if not self.applyTool(eventDc, False, keyChar, keyModifiers, None, None, None, None, self.commands.currentTool, viewRect):
|
||||
if not self.applyTool(eventDc, False, chr(event.GetUnicodeKey()), keyModifiers, None, None, None, None, self.commands.currentTool, viewRect):
|
||||
event.Skip()
|
||||
# }}}
|
||||
# {{{ onEnterWindow(self, event)
|
||||
|
@ -49,7 +49,7 @@ class RoarClient(GuiFrame):
|
||||
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
||||
|
||||
self.canvasPanel.commands.canvasNew(None)
|
||||
self.canvasPanel.commands.canvasTool(self.canvasPanel.commands.canvasTool, 4)(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, expand=True)
|
||||
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
|
||||
|
Loading…
Reference in New Issue
Block a user