mirror of
https://github.com/lalbornoz/roar.git
synced 2024-12-22 12:26:37 +00:00
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:
parent
1c7524ba6f
commit
a40017b607
@ -129,7 +129,7 @@ class GuiFrame(wx.Frame):
|
||||
# }}}
|
||||
# {{{ loadMenus(self, menus)
|
||||
def loadMenus(self, menus):
|
||||
menuBar = wx.MenuBar()
|
||||
self.menuBar = wx.MenuBar()
|
||||
for menu in menus:
|
||||
menuWindow = wx.Menu()
|
||||
for menuItem in menu[1:]:
|
||||
@ -140,8 +140,8 @@ class GuiFrame(wx.Frame):
|
||||
menuWindow.AppendSubMenu(menuSubWindow, menuItem[0], menuItem[0])
|
||||
else:
|
||||
self._initMenu(menuItem, menuWindow)
|
||||
menuBar.Append(menuWindow, menu[0])
|
||||
self.SetMenuBar(menuBar)
|
||||
self.menuBar.Append(menuWindow, menu[0])
|
||||
self.SetMenuBar(self.menuBar)
|
||||
# }}}
|
||||
# {{{ loadToolBars(self, toolBars)
|
||||
def loadToolBars(self, toolBars):
|
||||
|
@ -26,12 +26,18 @@ class RoarCanvasCommandsOperators():
|
||||
if (self.currentTool.__class__ == ToolObject) \
|
||||
and (self.currentTool.toolState >= self.currentTool.TS_SELECT):
|
||||
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.onSelectEvent(self.parentCanvas.canvas, (0, 0), self.parentCanvas.dispatchPatchSingle, eventDc, True, wx.MOD_NONE, None, self.currentTool.targetRect, viewRect)
|
||||
else:
|
||||
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()
|
||||
dirty = False
|
||||
for numRow in range(len(region)):
|
||||
|
@ -151,7 +151,11 @@ class RoarCanvasWindow(GuiWindow):
|
||||
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
|
||||
mouseDragging, mouseLeftDown, mouseRightDown = event.Dragging(), event.LeftIsDown(), event.RightIsDown()
|
||||
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()
|
||||
# }}}
|
||||
# {{{ onMouseWheel(self, event)
|
||||
@ -184,6 +188,7 @@ class RoarCanvasWindow(GuiWindow):
|
||||
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.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.SetDropTarget(self.dropTarget)
|
||||
self.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)
|
||||
|
@ -12,7 +12,7 @@ from RoarCanvasCommands import RoarCanvasCommands
|
||||
from RoarCanvasWindow import RoarCanvasWindow
|
||||
|
||||
from glob import glob
|
||||
import os, random, sys
|
||||
import os, random, sys, wx
|
||||
|
||||
class RoarClient(GuiFrame):
|
||||
# {{{ _getIconPathName(self)
|
||||
@ -55,4 +55,10 @@ class RoarClient(GuiFrame):
|
||||
self.assetsWindow = RoarAssetsWindow(GuiCanvasWxBackend, defaultCellSize, self)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user