mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +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
738b1db74e
commit
55dfbbb13f
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
|
5) Client-Server or Peer-to-Peer realtime collaboration
|
||||||
6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
|
6) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.)
|
||||||
7) Incremental auto{load,save} & {backup,restore} (needs Settings window)
|
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, ...)
|
9) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...)
|
||||||
|
|
||||||
High-priority list:
|
High-priority list:
|
||||||
1) unit tools: arrow, {cloud,speech bubble}, curve, measure, pick, polygon, triangle, unicode
|
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
|
2) text tool: a) honour RTL text flow b) navigating w/ cursor keys c) pasting text
|
||||||
3) operators: erase, rotate, scale, shift, slice, tile
|
3) operators: rotate, scale, shift, slice, tile
|
||||||
4) GUI:
|
4) cleanup & refactor, switch to GTK
|
||||||
a) switch to GTK
|
5) GUI:
|
||||||
b) replace logo w/ canvas panel in About dialogue
|
a) replace logo w/ canvas panel in About dialogue
|
||||||
c) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
b) 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)
|
c) 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}}
|
d) {copy,cut,delete,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
|
|
||||||
|
|
||||||
vim:ff=dos tw=0
|
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.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, 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.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
|
# XXX
|
||||||
toolBars.append(
|
toolBars.append(
|
||||||
|
@ -16,21 +16,27 @@ import wx
|
|||||||
class RoarCanvasCommandsTools():
|
class RoarCanvasCommandsTools():
|
||||||
# {{{ canvasTool(self, f, idx)
|
# {{{ canvasTool(self, f, idx)
|
||||||
@GuiSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False)
|
@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(1, "Cursor", "C&ursor", ["toolCursor.png"], [wx.ACCEL_CTRL, ord("U")], False)
|
||||||
@GuiSelectDecorator(2, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False)
|
@GuiSelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False)
|
||||||
@GuiSelectDecorator(3, "Object", "&Object", ["toolObject.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
@GuiSelectDecorator(3, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False)
|
||||||
@GuiSelectDecorator(4, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True)
|
@GuiSelectDecorator(4, "Object", "&Object", ["toolObject.png"], [wx.ACCEL_CTRL, ord("E")], False)
|
||||||
@GuiSelectDecorator(5, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], 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(self, f, idx):
|
||||||
def canvasTool_(event):
|
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)
|
self.parentFrame.menuItemsById[self.canvasTool.attrList[idx]["id"]].Check(True)
|
||||||
toolBar = self.parentFrame.toolBarItemsById[self.canvasTool.attrList[idx]["id"]].GetToolBar()
|
toolBar = self.parentFrame.toolBarItemsById[self.canvasTool.attrList[idx]["id"]].GetToolBar()
|
||||||
toolBar.ToggleTool(self.canvasTool.attrList[idx]["id"], True)
|
toolBar.ToggleTool(self.canvasTool.attrList[idx]["id"], True)
|
||||||
self.update(toolName=self.currentTool.name)
|
if self.currentTool != None:
|
||||||
viewRect = self.parentCanvas.GetViewStart()
|
self.update(toolName=self.currentTool.name)
|
||||||
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
|
viewRect = self.parentCanvas.GetViewStart()
|
||||||
self.parentCanvas.applyTool(eventDc, True, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect)
|
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_, "attrDict", f.attrList[idx])
|
||||||
setattr(canvasTool_, "isSelect", True)
|
setattr(canvasTool_, "isSelect", True)
|
||||||
return canvasTool_
|
return canvasTool_
|
||||||
@ -41,7 +47,7 @@ class RoarCanvasCommandsTools():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.menus = (
|
self.menus = (
|
||||||
("&Tools",
|
("&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 = ()
|
self.toolBars = ()
|
||||||
|
@ -66,9 +66,15 @@ class RoarCanvasWindow(GuiWindow):
|
|||||||
or (self.lastCellState != [list(mapPoint), mouseDragging, mouseLeftDown, mouseRightDown, list(viewRect)])):
|
or (self.lastCellState != [list(mapPoint), mouseDragging, mouseLeftDown, mouseRightDown, list(viewRect)])):
|
||||||
self.brushPos = list(mapPoint)
|
self.brushPos = list(mapPoint)
|
||||||
self.lastCellState = [list(mapPoint), mouseDragging, mouseLeftDown, mouseRightDown, list(viewRect)]
|
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:
|
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:
|
if dirty:
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
self.commands.update(dirty=self.dirty, cellPos=self.brushPos, undoLevel=self.canvas.journal.patchesUndoLevel)
|
self.commands.update(dirty=self.dirty, cellPos=self.brushPos, undoLevel=self.canvas.journal.patchesUndoLevel)
|
||||||
@ -142,13 +148,24 @@ class RoarCanvasWindow(GuiWindow):
|
|||||||
|
|
||||||
# {{{ onKeyboardInput(self, event)
|
# {{{ onKeyboardInput(self, event)
|
||||||
def onKeyboardInput(self, event):
|
def onKeyboardInput(self, event):
|
||||||
if (event.GetKeyCode() == wx.WXK_PAUSE) \
|
keyCode, keyModifiers = event.GetKeyCode(), event.GetModifiers()
|
||||||
and (event.GetModifiers() == wx.MOD_SHIFT):
|
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()
|
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:
|
else:
|
||||||
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
|
if not self.applyTool(eventDc, False, chr(event.GetUnicodeKey()), keyModifiers, None, None, None, None, self.commands.currentTool, viewRect):
|
||||||
keyChar, keyModifiers = chr(event.GetUnicodeKey()), event.GetModifiers()
|
|
||||||
if not self.applyTool(eventDc, False, keyChar, keyModifiers, None, None, None, None, self.commands.currentTool, viewRect):
|
|
||||||
event.Skip()
|
event.Skip()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onEnterWindow(self, event)
|
# {{{ onEnterWindow(self, event)
|
||||||
|
@ -49,7 +49,7 @@ class RoarClient(GuiFrame):
|
|||||||
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
self.loadToolBars(self.canvasPanel.commands.toolBars)
|
||||||
|
|
||||||
self.canvasPanel.commands.canvasNew(None)
|
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.canvasPanel.commands.update(brushSize=self.canvasPanel.brushSize, colours=self.canvasPanel.brushColours)
|
||||||
self.addWindow(self.canvasPanel, expand=True)
|
self.addWindow(self.canvasPanel, expand=True)
|
||||||
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
|
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
|
||||||
|
Loading…
Reference in New Issue
Block a user