From 1c82e723c171408d32cc6692e29b47382898d972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Mon, 16 Sep 2019 17:13:55 +0200 Subject: [PATCH] Implements foreground colour accelerators. libgui/GuiFrame.py:onMenu(): don't call wx.SafeYield() because wxPython doesn't actually know what it wants from you EVER. libroar/RoarCanvasCommands.py:update(): select tool corresponding to new foreground colour on change thereof. libroar/RoarCanvasCommandsEdit.py:canvasColour(): specify <[0-9]> & <[0-5]> accelerators. libroar/RoarCanvasCommandsEdit.py:canvasColourAlpha(): specify 6 accelerator. --- libgui/GuiFrame.py | 2 +- libroar/RoarCanvasCommands.py | 2 ++ libroar/RoarCanvasCommandsEdit.py | 34 +++++++++++++++---------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libgui/GuiFrame.py b/libgui/GuiFrame.py index d5793ce..1cdc681 100644 --- a/libgui/GuiFrame.py +++ b/libgui/GuiFrame.py @@ -184,7 +184,7 @@ class GuiFrame(wx.Frame): def onMenu(self, event): eventId = event.GetId() if eventId in self.itemsById: - self.itemsById[eventId](event); wx.SafeYield(); + self.itemsById[eventId](event) else: event.Skip() # }}} diff --git a/libroar/RoarCanvasCommands.py b/libroar/RoarCanvasCommands.py index 2d0e44d..2a48c29 100644 --- a/libroar/RoarCanvasCommands.py +++ b/libroar/RoarCanvasCommands.py @@ -53,6 +53,8 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan textItems.append("{} on {}".format( Colours[self.lastPanelState["colours"][0]][4] if self.lastPanelState["colours"][0] != -1 else "Transparent", Colours[self.lastPanelState["colours"][1]][4] if self.lastPanelState["colours"][1] != -1 else "Transparent")) + toolBar = self.parentFrame.toolBarItemsById[self.canvasColour(self.canvasColour, self.lastPanelState["colours"][0]).attrDict["id"]].GetToolBar() + toolBar.ToggleTool(self.canvasColour(self.canvasColour, self.lastPanelState["colours"][0]).attrDict["id"], True) if "pathName" in self.lastPanelState: if self.lastPanelState["pathName"] != None: basePathName = os.path.basename(self.lastPanelState["pathName"]) diff --git a/libroar/RoarCanvasCommandsEdit.py b/libroar/RoarCanvasCommandsEdit.py index 6a12d39..4475bd7 100644 --- a/libroar/RoarCanvasCommandsEdit.py +++ b/libroar/RoarCanvasCommandsEdit.py @@ -79,22 +79,22 @@ class RoarCanvasCommandsEdit(): return canvasCanvasSize_ # }}} # {{{ canvasColour(self, f, idx) - @GuiSelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, None, False) - @GuiSelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, None, False) - @GuiSelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, None, False) - @GuiSelectDecorator(3, "Colour #03", "Colour #03 (Green)", None, None, False) - @GuiSelectDecorator(4, "Colour #04", "Colour #04 (Red)", None, None, False) - @GuiSelectDecorator(5, "Colour #05", "Colour #05 (Light Red)", None, None, False) - @GuiSelectDecorator(6, "Colour #06", "Colour #06 (Pink)", None, None, False) - @GuiSelectDecorator(7, "Colour #07", "Colour #07 (Yellow)", None, None, False) - @GuiSelectDecorator(8, "Colour #08", "Colour #08 (Light Yellow)", None, None, False) - @GuiSelectDecorator(9, "Colour #09", "Colour #09 (Light Green)", None, None, False) - @GuiSelectDecorator(10, "Colour #10", "Colour #10 (Cyan)", None, None, False) - @GuiSelectDecorator(11, "Colour #11", "Colour #11 (Light Cyan)", None, None, False) - @GuiSelectDecorator(12, "Colour #12", "Colour #12 (Light Blue)", None, None, False) - @GuiSelectDecorator(13, "Colour #13", "Colour #13 (Light Pink)", None, None, False) - @GuiSelectDecorator(14, "Colour #14", "Colour #14 (Grey)", None, None, False) - @GuiSelectDecorator(15, "Colour #15", "Colour #15 (Light Grey)", None, None, False) + @GuiSelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, [wx.ACCEL_CTRL, ord("0")], False) + @GuiSelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, [wx.ACCEL_CTRL, ord("1")], False) + @GuiSelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, [wx.ACCEL_CTRL, ord("2")], False) + @GuiSelectDecorator(3, "Colour #03", "Colour #03 (Green)", None, [wx.ACCEL_CTRL, ord("3")], False) + @GuiSelectDecorator(4, "Colour #04", "Colour #04 (Red)", None, [wx.ACCEL_CTRL, ord("4")], False) + @GuiSelectDecorator(5, "Colour #05", "Colour #05 (Light Red)", None, [wx.ACCEL_CTRL, ord("5")], False) + @GuiSelectDecorator(6, "Colour #06", "Colour #06 (Pink)", None, [wx.ACCEL_CTRL, ord("6")], False) + @GuiSelectDecorator(7, "Colour #07", "Colour #07 (Yellow)", None, [wx.ACCEL_CTRL, ord("7")], False) + @GuiSelectDecorator(8, "Colour #08", "Colour #08 (Light Yellow)", None, [wx.ACCEL_CTRL, ord("8")], False) + @GuiSelectDecorator(9, "Colour #09", "Colour #09 (Light Green)", None, [wx.ACCEL_CTRL, ord("9")], False) + @GuiSelectDecorator(10, "Colour #10", "Colour #10 (Cyan)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("0")], False) + @GuiSelectDecorator(11, "Colour #11", "Colour #11 (Light Cyan)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("1")], False) + @GuiSelectDecorator(12, "Colour #12", "Colour #12 (Light Blue)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("2")], False) + @GuiSelectDecorator(13, "Colour #13", "Colour #13 (Light Pink)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("3")], False) + @GuiSelectDecorator(14, "Colour #14", "Colour #14 (Grey)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("4")], False) + @GuiSelectDecorator(15, "Colour #15", "Colour #15 (Light Grey)", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("5")], False) def canvasColour(self, f, idx): def canvasColour_(event): if event.GetEventType() == wx.wxEVT_TOOL: @@ -107,7 +107,7 @@ class RoarCanvasCommandsEdit(): return canvasColour_ # }}} # {{{ canvasColourAlpha(self, f, idx) - @GuiSelectDecorator(0, "Transparent colour", "Transparent colour", None, None, False) + @GuiSelectDecorator(0, "Transparent colour", "Transparent colour", None, [wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord("6")], False) def canvasColourAlpha(self, f, idx): def canvasColourAlpha_(event): if event.GetEventType() == wx.wxEVT_TOOL: