Implements object tool operators context menu.

libgui/GuiFrame.py: _FUCK_ _YOU_ WXPYTHON
libroar/RoarCanvasCommandsOperators.py: I _FUCKING_ _HATE_ WXPYTHON
libroar/RoarCanvasWindow.py: DIE IN A DITCH WXPYTHON YOU ROTTING PILE OF FUCKING HIPPOPOTAMUS SHIT
libroar/RoarClient.py: I HATE WXPYTHON I HATE WXPYTHON I HATE WXPYTHON I HATE WXPYTHON I HATE WXPYTHON
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-15 13:52:44 +02:00
parent 1c7524ba6f
commit a40017b607
4 changed files with 24 additions and 7 deletions

View File

@ -129,7 +129,7 @@ class GuiFrame(wx.Frame):
# }}} # }}}
# {{{ loadMenus(self, menus) # {{{ loadMenus(self, menus)
def loadMenus(self, menus): def loadMenus(self, menus):
menuBar = wx.MenuBar() self.menuBar = wx.MenuBar()
for menu in menus: for menu in menus:
menuWindow = wx.Menu() menuWindow = wx.Menu()
for menuItem in menu[1:]: for menuItem in menu[1:]:
@ -140,8 +140,8 @@ class GuiFrame(wx.Frame):
menuWindow.AppendSubMenu(menuSubWindow, menuItem[0], menuItem[0]) menuWindow.AppendSubMenu(menuSubWindow, menuItem[0], menuItem[0])
else: else:
self._initMenu(menuItem, menuWindow) self._initMenu(menuItem, menuWindow)
menuBar.Append(menuWindow, menu[0]) self.menuBar.Append(menuWindow, menu[0])
self.SetMenuBar(menuBar) self.SetMenuBar(self.menuBar)
# }}} # }}}
# {{{ loadToolBars(self, toolBars) # {{{ loadToolBars(self, toolBars)
def loadToolBars(self, toolBars): def loadToolBars(self, toolBars):

View File

@ -26,12 +26,18 @@ class RoarCanvasCommandsOperators():
if (self.currentTool.__class__ == ToolObject) \ if (self.currentTool.__class__ == ToolObject) \
and (self.currentTool.toolState >= self.currentTool.TS_SELECT): and (self.currentTool.toolState >= self.currentTool.TS_SELECT):
viewRect = self.parentCanvas.GetViewStart() viewRect = self.parentCanvas.GetViewStart()
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) if self.parentCanvas.popupEventDc == None:
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
else:
eventDc = self.parentCanvas.popupEventDc
self.currentTool.setRegion(self.parentCanvas.canvas, None, region, [len(region[0]), len(region)], self.currentTool.external) self.currentTool.setRegion(self.parentCanvas.canvas, None, region, [len(region[0]), len(region)], self.currentTool.external)
self.currentTool.onSelectEvent(self.parentCanvas.canvas, (0, 0), self.parentCanvas.dispatchPatchSingle, eventDc, True, wx.MOD_NONE, None, self.currentTool.targetRect, viewRect) self.currentTool.onSelectEvent(self.parentCanvas.canvas, (0, 0), self.parentCanvas.dispatchPatchSingle, eventDc, True, wx.MOD_NONE, None, self.currentTool.targetRect, viewRect)
else: else:
viewRect = self.parentCanvas.GetViewStart() viewRect = self.parentCanvas.GetViewStart()
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect) if self.parentCanvas.popupEventDc == None:
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
else:
eventDc = self.parentCanvas.popupEventDc
self.parentCanvas.canvas.journal.begin() self.parentCanvas.canvas.journal.begin()
dirty = False dirty = False
for numRow in range(len(region)): for numRow in range(len(region)):

View File

@ -151,7 +151,11 @@ class RoarCanvasWindow(GuiWindow):
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect); viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
mouseDragging, mouseLeftDown, mouseRightDown = event.Dragging(), event.LeftIsDown(), event.RightIsDown() mouseDragging, mouseLeftDown, mouseRightDown = event.Dragging(), event.LeftIsDown(), event.RightIsDown()
mapPoint = self.backend.xlateEventPoint(event, eventDc, viewRect) mapPoint = self.backend.xlateEventPoint(event, eventDc, viewRect)
if not self.applyTool(eventDc, True, None, event.GetModifiers(), mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, self.commands.currentTool, viewRect): if mouseRightDown \
and (self.commands.currentTool.__class__ == ToolObject) \
and (self.commands.currentTool.toolState >= self.commands.currentTool.TS_SELECT):
self.popupEventDc = eventDc; self.PopupMenu(self.operatorsMenu); self.popupEventDc = None;
elif not self.applyTool(eventDc, True, None, event.GetModifiers(), mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, self.commands.currentTool, viewRect):
event.Skip() event.Skip()
# }}} # }}}
# {{{ onMouseWheel(self, event) # {{{ onMouseWheel(self, event)
@ -184,6 +188,7 @@ class RoarCanvasWindow(GuiWindow):
super().__init__(parent, pos, scrollStep, [w * h for w, h in zip(cellSize, size)]) super().__init__(parent, pos, scrollStep, [w * h for w, h in zip(cellSize, size)])
self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame
self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None
self.popupEventDc = None
self.dropTarget = RoarCanvasWindowDropTarget(self) self.dropTarget = RoarCanvasWindowDropTarget(self)
self.SetDropTarget(self.dropTarget) self.SetDropTarget(self.dropTarget)
self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel) self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)

View File

@ -12,7 +12,7 @@ from RoarCanvasCommands import RoarCanvasCommands
from RoarCanvasWindow import RoarCanvasWindow from RoarCanvasWindow import RoarCanvasWindow
from glob import glob from glob import glob
import os, random, sys import os, random, sys, wx
class RoarClient(GuiFrame): class RoarClient(GuiFrame):
# {{{ _getIconPathName(self) # {{{ _getIconPathName(self)
@ -55,4 +55,10 @@ class RoarClient(GuiFrame):
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self) self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
self.canvasPanel.commands.canvasAssetsWindowShow(None) self.canvasPanel.commands.canvasAssetsWindowShow(None)
# XXX
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)
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120 # vim:expandtab foldmethod=marker sw=4 ts=4 tw=120