2019-09-01 14:34:00 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2019-09-09 10:46:52 +00:00
|
|
|
# GuiCanvasWxBackend.py
|
2019-09-04 14:23:59 +00:00
|
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
2019-09-01 14:34:00 +00:00
|
|
|
#
|
|
|
|
|
2019-09-11 13:33:15 +00:00
|
|
|
from ctypes import *
|
2019-09-07 08:39:26 +00:00
|
|
|
from GuiCanvasColours import Colours
|
2019-09-13 08:03:39 +00:00
|
|
|
import math, os, platform, wx
|
2019-09-01 14:34:00 +00:00
|
|
|
|
2019-09-11 06:28:56 +00:00
|
|
|
class GuiBufferedDC(wx.MemoryDC):
|
|
|
|
def __del__(self):
|
|
|
|
self.dc.Blit(0, 0, *self.viewSize, self, 0, 0)
|
|
|
|
self.SelectObject(wx.NullBitmap)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-11 06:28:56 +00:00
|
|
|
def __init__(self, backend, buffer, clientSize, dc, viewRect):
|
|
|
|
super().__init__()
|
|
|
|
canvasSize = [a - b for a, b in zip(backend.canvasSize, viewRect)]
|
|
|
|
clientSize = [math.ceil(m / n) for m, n in zip(clientSize, backend.cellSize)]
|
|
|
|
viewRect = [m * n for m, n in zip(backend.cellSize, viewRect)]
|
|
|
|
viewSize = [min(m, n) for m, n in zip(canvasSize, clientSize)]
|
|
|
|
viewSize = [m * n for m, n in zip(backend.cellSize, viewSize)]
|
2019-09-13 19:09:51 +00:00
|
|
|
self.SelectObject(buffer); self.SetDeviceOrigin(*viewRect);
|
|
|
|
self.dc, self.viewRect, self.viewSize = dc, viewRect, viewSize
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-07 08:39:26 +00:00
|
|
|
class GuiCanvasWxBackend():
|
2019-09-16 12:13:44 +00:00
|
|
|
arabicShapes = {
|
|
|
|
u'\u0621': (u'\uFE80'),
|
|
|
|
u'\u0622': (u'\uFE81', None, None, u'\uFE82'),
|
|
|
|
u'\u0623': (u'\uFE83', None, None, u'\uFE84'),
|
|
|
|
u'\u0624': (u'\uFE85', None, None, u'\uFE86'),
|
|
|
|
u'\u0625': (u'\uFE87', None, None, u'\uFE88'),
|
|
|
|
u'\u0626': (u'\uFE89', u'\uFE8B', u'\uFE8C', u'\uFE8A'),
|
|
|
|
u'\u0627': (u'\uFE8D', None, None, u'\uFE8E'),
|
|
|
|
u'\u0628': (u'\uFE8F', u'\uFE91', u'\uFE92', u'\uFE90'),
|
|
|
|
u'\u0629': (u'\uFE93', None, None, u'\uFE94'),
|
|
|
|
u'\u062A': (u'\uFE95', u'\uFE97', u'\uFE98', u'\uFE96'),
|
|
|
|
u'\u062B': (u'\uFE99', u'\uFE9B', u'\uFE9C', u'\uFE9A'),
|
|
|
|
u'\u062C': (u'\uFE9D', u'\uFE9F', u'\uFEA0', u'\uFE9E'),
|
|
|
|
u'\u062D': (u'\uFEA1', u'\uFEA3', u'\uFEA4', u'\uFEA2'),
|
|
|
|
u'\u062E': (u'\uFEA5', u'\uFEA7', u'\uFEA8', u'\uFEA6'),
|
|
|
|
u'\u062F': (u'\uFEA9', None, None, u'\uFEAA'),
|
|
|
|
u'\u0630': (u'\uFEAB', None, None, u'\uFEAC'),
|
|
|
|
u'\u0631': (u'\uFEAD', None, None, u'\uFEAE'),
|
|
|
|
u'\u0632': (u'\uFEAF', None, None, u'\uFEB0'),
|
|
|
|
u'\u0633': (u'\uFEB1', u'\uFEB3', u'\uFEB4', u'\uFEB2'),
|
|
|
|
u'\u0634': (u'\uFEB5', u'\uFEB7', u'\uFEB8', u'\uFEB6'),
|
|
|
|
u'\u0635': (u'\uFEB9', u'\uFEBB', u'\uFEBC', u'\uFEBA'),
|
|
|
|
u'\u0636': (u'\uFEBD', u'\uFEBF', u'\uFEC0', u'\uFEBE'),
|
|
|
|
u'\u0637': (u'\uFEC1', u'\uFEC3', u'\uFEC4', u'\uFEC2'),
|
|
|
|
u'\u0638': (u'\uFEC5', u'\uFEC7', u'\uFEC8', u'\uFEC6'),
|
|
|
|
u'\u0639': (u'\uFEC9', u'\uFECB', u'\uFECC', u'\uFECA'),
|
|
|
|
u'\u063A': (u'\uFECD', u'\uFECF', u'\uFED0', u'\uFECE'),
|
|
|
|
u'\u0640': (u'\u0640', None, None, None),
|
|
|
|
u'\u0641': (u'\uFED1', u'\uFED3', u'\uFED4', u'\uFED2'),
|
|
|
|
u'\u0642': (u'\uFED5', u'\uFED7', u'\uFED8', u'\uFED6'),
|
|
|
|
u'\u0643': (u'\uFED9', u'\uFEDB', u'\uFEDC', u'\uFEDA'),
|
|
|
|
u'\u0644': (u'\uFEDD', u'\uFEDF', u'\uFEE0', u'\uFEDE'),
|
|
|
|
u'\u0645': (u'\uFEE1', u'\uFEE3', u'\uFEE4', u'\uFEE2'),
|
|
|
|
u'\u0646': (u'\uFEE5', u'\uFEE7', u'\uFEE8', u'\uFEE6'),
|
|
|
|
u'\u0647': (u'\uFEE9', u'\uFEEB', u'\uFEEC', u'\uFEEA'),
|
|
|
|
u'\u0648': (u'\uFEED', None, None, u'\uFEEE'),
|
|
|
|
u'\u0649': (u'\uFEEF', None, None, u'\uFEF0'),
|
|
|
|
u'\u064A': (u'\uFEF1', u'\uFEF3', u'\uFEF4', u'\uFEF2'),
|
|
|
|
}
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-16 06:39:55 +00:00
|
|
|
class _CellState():
|
|
|
|
CS_NONE = 0x00
|
|
|
|
CS_BOLD = 0x01
|
|
|
|
CS_ITALIC = 0x02
|
|
|
|
CS_UNDERLINE = 0x04
|
|
|
|
|
2019-09-24 12:03:16 +00:00
|
|
|
def _drawBrushPatch(self, eventDc, isCursor, patch, point):
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
absPoint = self._xlatePoint(point)
|
2019-09-24 12:03:16 +00:00
|
|
|
dc = self._setBrushPatchColours(eventDc, isCursor, patch)
|
|
|
|
dc.DrawRectangle(*absPoint, *self.cellSize)
|
|
|
|
|
|
|
|
def _drawCharPatch(self, eventDc, isCursor, patch, point):
|
|
|
|
absPoint = self._xlatePoint(point)
|
|
|
|
dc, pen = self._setCharPatchColours(eventDc, isCursor, patch)
|
|
|
|
dc.DrawRectangle(*absPoint, *self.cellSize)
|
|
|
|
if (patch[2] & self._CellState.CS_UNDERLINE) or (patch[3] == "_"):
|
|
|
|
dc.SetPen(self._pens[patch[0]]);
|
|
|
|
if not isCursor:
|
|
|
|
dc.DrawLine(absPoint[0], absPoint[1] + self.cellSize[1] - 1, absPoint[0] + self.cellSize[0] - 1, absPoint[1] + self.cellSize[1] - 1)
|
|
|
|
else:
|
|
|
|
dc.DrawLines((wx.Point2D(absPoint[0], absPoint[1] + self.cellSize[1] - 1), wx.Point2D(absPoint[0] + self.cellSize[0] - 1, absPoint[1] + self.cellSize[1] - 1),))
|
|
|
|
dc.SetPen(pen)
|
2019-09-16 06:39:55 +00:00
|
|
|
if patch[3] != "_":
|
2019-09-24 12:03:16 +00:00
|
|
|
if not isCursor:
|
|
|
|
oldClippingRegion = dc.GetClippingBox()
|
|
|
|
dc.DestroyClippingRegion(); dc.SetClippingRegion(*absPoint, *self.cellSize);
|
|
|
|
dc.SetTextBackground(wx.Colour(Colours[patch[1]][:4])); dc.SetTextForeground(wx.Colour(Colours[patch[0]][:4]));
|
|
|
|
else:
|
|
|
|
dc.ResetClip(); dc.Clip(wx.Region(*absPoint, *self.cellSize));
|
|
|
|
dc.DrawText(patch[3], *absPoint)
|
|
|
|
if not isCursor:
|
|
|
|
dc.DestroyClippingRegion()
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-01 14:34:00 +00:00
|
|
|
def _finiBrushesAndPens(self):
|
2019-09-06 08:29:45 +00:00
|
|
|
[brush.Destroy() for brush in self._brushes or []]
|
2019-09-24 12:03:16 +00:00
|
|
|
[brushTransp.Destroy() for brushTransp in self._brushesTransp or []]
|
2019-09-06 08:29:45 +00:00
|
|
|
[pen.Destroy() for pen in self._pens or []]
|
2019-09-24 12:03:16 +00:00
|
|
|
[penTransp.Destroy() for penTransp in self._pensTransp or []]
|
|
|
|
self._brushAlpha.Destroy(); self._penAlpha.Destroy();
|
|
|
|
self._brushAlphaTransp.Destroy(); self._penAlphaTransp.Destroy();
|
|
|
|
self._brushes, self._lastBrush, self._lastPen, self._pens = None, None, None, None
|
|
|
|
self._brushesTransp, self._lastBrushTransp, self._lastPenTransp, self._pensTransp = None, None, None, None
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-01 14:34:00 +00:00
|
|
|
def _initBrushesAndPens(self):
|
2019-09-06 08:29:45 +00:00
|
|
|
self._brushes, self._pens = [None for x in range(len(Colours))], [None for x in range(len(Colours))]
|
2019-09-24 12:03:16 +00:00
|
|
|
self._brushesTransp, self._pensTransp = [None for x in range(len(Colours))], [None for x in range(len(Colours))]
|
2019-09-03 16:58:50 +00:00
|
|
|
for mircColour in range(len(Colours)):
|
2019-09-06 08:29:45 +00:00
|
|
|
self._brushes[mircColour] = wx.Brush(wx.Colour(Colours[mircColour][:4]), wx.BRUSHSTYLE_SOLID)
|
2019-09-24 12:03:16 +00:00
|
|
|
self._brushesTransp[mircColour] = wx.Brush(wx.Colour(*Colours[mircColour][:3], 200), wx.BRUSHSTYLE_SOLID)
|
2019-09-06 08:29:45 +00:00
|
|
|
self._pens[mircColour] = wx.Pen(wx.Colour(Colours[mircColour][:4]), 1)
|
2019-09-24 12:03:16 +00:00
|
|
|
self._pensTransp[mircColour] = wx.Pen(wx.Colour(*Colours[mircColour][:3], 200), 1, wx.PENSTYLE_TRANSPARENT)
|
2019-09-12 19:01:06 +00:00
|
|
|
self._brushAlpha = wx.Brush(wx.Colour(Colours[14][:4]), wx.BRUSHSTYLE_SOLID)
|
2019-09-24 12:03:16 +00:00
|
|
|
self._brushAlphaTransp = wx.Brush(wx.Colour(*Colours[14][:3], 200), wx.BRUSHSTYLE_SOLID)
|
2019-09-12 19:01:06 +00:00
|
|
|
self._penAlpha = wx.Pen(wx.Colour(Colours[14][:4]), 1)
|
2019-09-24 12:03:16 +00:00
|
|
|
self._penAlphaTransp = wx.Pen(wx.Colour(*Colours[14][:3], 200), 1, wx.PENSTYLE_TRANSPARENT)
|
|
|
|
self._lastBrush, self._lastPen = None, None
|
|
|
|
self._lastBrushTransp, self._lastPenTransp = None, None
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-24 12:03:16 +00:00
|
|
|
def _reshapeArabic(self, canvas, eventDc, isCursor, patch, point):
|
2019-09-16 12:13:44 +00:00
|
|
|
lastCell = point[0]
|
|
|
|
while True:
|
|
|
|
if ((lastCell + 1) >= (canvas.size[0] - 1)) \
|
|
|
|
or (not canvas.map[point[1]][lastCell + 1][3] in self.arabicShapes):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
lastCell += 1
|
|
|
|
connect = False
|
|
|
|
for runX in range(lastCell, point[0], -1):
|
|
|
|
runCell = list(canvas.map[point[1]][runX])
|
|
|
|
if runX == lastCell:
|
|
|
|
if self.arabicShapes[runCell[3]][1] != None:
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][1]; connect = True;
|
|
|
|
else:
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][0]; connect = False;
|
|
|
|
else:
|
|
|
|
if connect and (self.arabicShapes[runCell[3]][2] != None):
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][2]; connect = True;
|
|
|
|
elif connect and (self.arabicShapes[runCell[3]][3] != None):
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][3]; connect = False;
|
|
|
|
elif not connect and (self.arabicShapes[runCell[3]][1] != None):
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][1]; connect = True;
|
|
|
|
else:
|
|
|
|
runCell[3] = self.arabicShapes[runCell[3]][0]; connect = False;
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawCharPatch(eventDc, isCursor, runCell, [runX, point[1]])
|
2019-09-16 12:13:44 +00:00
|
|
|
runCell = list(patch[2:])
|
|
|
|
if connect and (self.arabicShapes[patch[5]][3] != None):
|
|
|
|
runCell[3] = self.arabicShapes[patch[5]][3]
|
|
|
|
else:
|
|
|
|
runCell[3] = self.arabicShapes[patch[5]][0]
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawCharPatch(eventDc, isCursor, runCell, [point[0], point[1]])
|
|
|
|
|
|
|
|
def _setBrushPatchColours(self, dc, isCursor, patch):
|
|
|
|
if not isCursor:
|
|
|
|
brushAlpha, brushes, dc_, penAlpha, pens = self._brushAlpha, self._brushes, dc, self._penAlpha, self._pens
|
|
|
|
else:
|
|
|
|
brushAlpha, brushes, dc_, penAlpha, pens = self._brushAlphaTransp, self._brushesTransp, wx.GraphicsContext.Create(dc), self._penAlphaTransp, self._pensTransp
|
|
|
|
if ((patch[0] != -1) and (patch[1] != -1)) \
|
|
|
|
or ((patch[0] == -1) and (patch[1] != -1)):
|
|
|
|
brush, pen = brushes[patch[1]], pens[patch[1]]
|
|
|
|
else:
|
|
|
|
brush, pen = brushAlpha, penAlpha
|
|
|
|
if not isCursor:
|
|
|
|
if self._lastBrush != brush:
|
|
|
|
dc_.SetBrush(brush); self._lastBrush = brush;
|
|
|
|
if self._lastPen != pen:
|
|
|
|
dc_.SetPen(pen); self._lastPen = pen;
|
|
|
|
else:
|
|
|
|
dc_.SetBrush(brush); dc_.SetPen(pen);
|
|
|
|
return dc_
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-24 12:03:16 +00:00
|
|
|
def _setCharPatchColours(self, dc, isCursor, patch):
|
|
|
|
if not isCursor:
|
|
|
|
brushAlpha, brushes, dc_, penAlpha, pens = self._brushAlpha, self._brushes, dc, self._penAlpha, self._pens
|
|
|
|
dc_.SetFont(self._font)
|
|
|
|
else:
|
|
|
|
brushAlpha, brushes, dc_, penAlpha, pens = self._brushAlphaTransp, self._brushesTransp, wx.GraphicsContext.Create(dc), self._penAlphaTransp, self._pensTransp
|
|
|
|
if (patch[0] != -1) and (patch[1] != -1):
|
|
|
|
brush, fontColour, pen = brushes[patch[1]], Colours[patch[0]][:3], pens[patch[1]]
|
|
|
|
elif (patch[0] == -1) and (patch[1] == -1):
|
|
|
|
brush, fontColour, pen = brushAlpha, Colours[14][:4], penAlpha
|
|
|
|
elif patch[0] == -1:
|
|
|
|
brush, fontColour, pen = brushes[patch[1]], Colours[14][:3], pens[patch[1]]
|
|
|
|
elif patch[1] == -1:
|
|
|
|
brush, fontColour, pen = brushAlpha, Colours[patch[0]][:3], penAlpha
|
|
|
|
if not isCursor:
|
|
|
|
if self._lastBrush != brush:
|
|
|
|
dc_.SetBrush(brush); self._lastBrush = brush;
|
|
|
|
if self._lastPen != pen:
|
|
|
|
dc_.SetPen(pen); self._lastPen = pen;
|
|
|
|
else:
|
|
|
|
dc_.SetBrush(brush); dc_.SetFont(self._font, wx.Colour(fontColour)); dc_.SetPen(pen);
|
|
|
|
return dc_, pen
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
def _xlatePoint(self, point):
|
|
|
|
return [a * b for a, b in zip(point, self.cellSize)]
|
2019-09-01 14:34:00 +00:00
|
|
|
|
2019-09-16 14:54:07 +00:00
|
|
|
def drawCursorMaskWithJournal(self, canvas, canvasJournal, eventDc):
|
|
|
|
[self.drawPatch(canvas, eventDc, patch) for patch in canvasJournal.popCursor()]
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-24 12:03:16 +00:00
|
|
|
def drawPatch(self, canvas, eventDc, patch, isCursor=False):
|
2019-09-16 14:54:07 +00:00
|
|
|
point = patch[:2]
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
if [(c >= 0) and (c < s) for c, s in zip(point, self.canvasSize)] == [True, True]:
|
|
|
|
if patch[5] == " ":
|
2019-09-12 19:01:06 +00:00
|
|
|
if patch[3] == -1:
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawCharPatch(eventDc, isCursor, [*patch[2:-1], "░"], point)
|
2019-09-16 06:39:55 +00:00
|
|
|
elif patch[4] & self._CellState.CS_UNDERLINE:
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawCharPatch(eventDc, isCursor, patch[2:], point)
|
2019-09-12 19:01:06 +00:00
|
|
|
else:
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawBrushPatch(eventDc, isCursor, patch[2:], point)
|
2019-09-16 12:13:44 +00:00
|
|
|
elif patch[5] in self.arabicShapes:
|
2019-09-24 12:03:16 +00:00
|
|
|
self._reshapeArabic(canvas, eventDc, isCursor, patch, point)
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
else:
|
2019-09-24 12:03:16 +00:00
|
|
|
self._drawCharPatch(eventDc, isCursor, patch[2:], point)
|
2019-09-01 14:34:00 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-16 14:54:07 +00:00
|
|
|
def getDeviceContext(self, clientSize, parentWindow, viewRect=None):
|
|
|
|
if viewRect == None:
|
|
|
|
viewRect = parentWindow.GetViewStart()
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
if viewRect == (0, 0):
|
|
|
|
eventDc = wx.BufferedDC(wx.ClientDC(parentWindow), self.canvasBitmap)
|
|
|
|
else:
|
2019-09-11 06:28:56 +00:00
|
|
|
eventDc = GuiBufferedDC(self, self.canvasBitmap, clientSize, wx.ClientDC(parentWindow), viewRect)
|
2019-09-24 12:03:16 +00:00
|
|
|
self._lastBrush, self._lastPen = None, None
|
2019-09-01 14:34:00 +00:00
|
|
|
return eventDc
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-11 06:28:56 +00:00
|
|
|
def onPaint(self, clientSize, panelWindow, viewRect):
|
2019-09-01 14:34:00 +00:00
|
|
|
if self.canvasBitmap != None:
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
if viewRect == (0, 0):
|
|
|
|
eventDc = wx.BufferedPaintDC(panelWindow, self.canvasBitmap)
|
|
|
|
else:
|
2019-09-11 06:28:56 +00:00
|
|
|
eventDc = GuiBufferedDC(self, self.canvasBitmap, clientSize, wx.PaintDC(panelWindow), viewRect)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-01 14:34:00 +00:00
|
|
|
def resize(self, canvasSize, cellSize):
|
2019-09-03 16:58:50 +00:00
|
|
|
winSize = [a * b for a, b in zip(canvasSize, cellSize)]
|
2019-09-01 14:34:00 +00:00
|
|
|
if self.canvasBitmap == None:
|
|
|
|
self.canvasBitmap = wx.Bitmap(winSize)
|
|
|
|
else:
|
2019-09-06 08:29:45 +00:00
|
|
|
oldDc = wx.MemoryDC(); oldDc.SelectObject(self.canvasBitmap);
|
|
|
|
newDc = wx.MemoryDC(); newBitmap = wx.Bitmap(winSize); newDc.SelectObject(newBitmap);
|
2019-09-01 14:34:00 +00:00
|
|
|
newDc.Blit(0, 0, *self.canvasBitmap.GetSize(), oldDc, 0, 0)
|
|
|
|
oldDc.SelectObject(wx.NullBitmap)
|
|
|
|
self.canvasBitmap.Destroy(); self.canvasBitmap = newBitmap;
|
2019-09-06 08:29:45 +00:00
|
|
|
self.canvasSize, self.cellSize = canvasSize, cellSize
|
2019-09-13 08:03:39 +00:00
|
|
|
if platform.system() == "Windows":
|
2019-09-14 13:44:17 +00:00
|
|
|
self._font = wx.TheFontList.FindOrCreateFont(cellSize[0] + 1, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName)
|
2019-09-13 08:03:39 +00:00
|
|
|
else:
|
2019-09-14 13:44:17 +00:00
|
|
|
self._font = wx.Font(cellSize[0] + 1, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
def xlateEventPoint(self, event, eventDc, viewRect):
|
2019-09-01 14:34:00 +00:00
|
|
|
eventPoint = event.GetLogicalPosition(eventDc)
|
2019-09-06 08:29:45 +00:00
|
|
|
rectX, rectY = eventPoint.x - (eventPoint.x % self.cellSize[0]), eventPoint.y - (eventPoint.y % self.cellSize[1])
|
|
|
|
mapX, mapY = int(rectX / self.cellSize[0] if rectX else 0), int(rectY / self.cellSize[1] if rectY else 0)
|
Initial canvas panel scrollbar implementation.
assets/text/TODO: updated.
libgui/GuiCanvasPanel.py:__init__(): provide self.winSize & call SetScrollRate().
libgui/GuiCanvasPanel.py:{_drawPatch,dispatch{DeltaPatches,Patch},onPanel{Input,LeaveWindow},resize,update}(): receive and/or pass viewRect.
libgui/GuiCanvasPanel.py:onPanelPaint(): updated.
libgui/GuiCanvasPanel.py:resize(): call SetVirtualSize().
libgui/GuiCanvasWxBackend.py:_{draw{Brush,Char}Patch,_get{Brush,Char}PatchColours,xlatePoint}(): updated.
libgui/GuiCanvasWxBackend.py:{draw{CursorMaskWithJournal,Patch},getDeviceContext,xlateEventPoint}(): receive and/or pass viewRect.
libgui/GuiCanvasWxBackend.py:getDeviceContext(): return ClientDC() if viewRect > (0, 0)
libgui/GuiCanvasWxBackend.py:onPanelPaintEvent(): blit subset of canvasBitmap into BufferedPaintDC() if viewRect > (0, 0).
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py: receive & pass viewRect to dispatchFn().
2019-09-09 10:30:25 +00:00
|
|
|
return [m + n for m, n in zip((mapX, mapY), viewRect)]
|
2019-09-01 14:34:00 +00:00
|
|
|
|
|
|
|
def __del__(self):
|
|
|
|
if self.canvasBitmap != None:
|
|
|
|
self.canvasBitmap.Destroy(); self.canvasBitmap = None;
|
|
|
|
self._finiBrushesAndPens()
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-01 14:34:00 +00:00
|
|
|
#
|
2019-09-11 13:33:15 +00:00
|
|
|
# __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")): initialisation method
|
|
|
|
def __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")):
|
2019-09-04 13:52:54 +00:00
|
|
|
self._brushes, self._font, self._lastBrush, self._lastPen, self._pens = None, None, None, None, None
|
2019-09-11 13:33:15 +00:00
|
|
|
self.canvasBitmap, self.cellSize, self.fontName, self.fontPathName = None, None, fontName, fontPathName
|
2019-09-13 08:03:39 +00:00
|
|
|
if platform.system() == "Windows":
|
|
|
|
WinDLL("gdi32.dll").AddFontResourceW(self.fontPathName.encode("utf16"))
|
2019-09-09 15:27:37 +00:00
|
|
|
self._initBrushesAndPens(); self.resize(canvasSize, cellSize);
|
2019-09-01 14:34:00 +00:00
|
|
|
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|