From da15324fee4f6f882b152a663e77fb8e61412557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Mon, 16 Sep 2019 08:39:55 +0200 Subject: [PATCH] Fix underlined cells rendering. libgui/GuiCanvasWxBackend.py: FUCK YOU WXPYTHON assets/text/TODO: updated. --- assets/text/TODO | 5 ++--- libgui/GuiCanvasWxBackend.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/assets/text/TODO b/assets/text/TODO index 5d96ce1..45390fa 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -24,8 +24,7 @@ Queue: 2) text tool: impl. backspace & enter, update internal brushPos if updated w/ arrow keys 3) text tool: a) honour RTL text flow b) navigating w/ cursor keys c) pasting text 4) scroll down, apply operator to entire canvas, scroll up -5) underline FUCKING BROKEN _AGAIN_ -6) select-related {re,un}do bugs -7) clone selection lag +5) select-related {re,un}do bugs +6) clone selection lag vim:ff=dos tw=0 diff --git a/libgui/GuiCanvasWxBackend.py b/libgui/GuiCanvasWxBackend.py index 204a8fc..70d4cc4 100644 --- a/libgui/GuiCanvasWxBackend.py +++ b/libgui/GuiCanvasWxBackend.py @@ -27,6 +27,14 @@ class GuiBufferedDC(wx.MemoryDC): # }}} class GuiCanvasWxBackend(): + # {{{ _CellState(): Cell state + class _CellState(): + CS_NONE = 0x00 + CS_BOLD = 0x01 + CS_ITALIC = 0x02 + CS_UNDERLINE = 0x04 + # }}} + # {{{ _drawBrushPatch(self, eventDc, patch, point) def _drawBrushPatch(self, eventDc, patch, point): absPoint = self._xlatePoint(point) @@ -43,10 +51,11 @@ class GuiCanvasWxBackend(): fontDc.SetTextForeground(wx.Colour(Colours[patch[0]][:4])) fontDc.SetTextBackground(wx.Colour(Colours[patch[1]][:4])) fontDc.DrawRectangle(0, 0, *self.cellSize) - if patch[3] == "_": - fontDc.SetPen(self._pens[patch[0]]) + fontDc.SetPen(self._pens[patch[0]]) + if (patch[2] & self._CellState.CS_UNDERLINE) \ + or (patch[3] == "_"): fontDc.DrawLine(0, self.cellSize[1] - 1, self.cellSize[0], self.cellSize[1] - 1) - else: + if patch[3] != "_": fontDc.DrawText(patch[3], 0, 0) eventDc.Blit(*absPoint, *self.cellSize, fontDc, 0, 0) # }}} @@ -115,6 +124,8 @@ class GuiCanvasWxBackend(): if patch[5] == " ": if patch[3] == -1: self._drawCharPatch(eventDc, [*patch[2:-1], "░"], point) + elif patch[4] & self._CellState.CS_UNDERLINE: + self._drawCharPatch(eventDc, patch[2:], point) else: self._drawBrushPatch(eventDc, patch[2:], point) else: