draw all line backgrounds first
This commit is contained in:
35
bigtext.py
35
bigtext.py
@@ -373,11 +373,13 @@ class InnerBigText(QWidget):
|
||||
# draws over a character
|
||||
y_line_offset = self.char_height;
|
||||
for l in self.lines:
|
||||
highlight_ranges = []
|
||||
for h in highlighters:
|
||||
optional_highlight_range = h.compute_highlight(l)
|
||||
if optional_highlight_range:
|
||||
for highlight in optional_highlight_range:
|
||||
self.draw_highlight(highlight, painter, y_line_offset)
|
||||
highlight_ranges = highlight_ranges + optional_highlight_range
|
||||
|
||||
self.draw_highlights(highlight_ranges, painter, y_line_offset)
|
||||
y_line_offset = y_line_offset + self.char_height
|
||||
|
||||
left_offset = -1 * self._left_offset * self.char_width
|
||||
@@ -388,21 +390,26 @@ class InnerBigText(QWidget):
|
||||
|
||||
painter.end()
|
||||
|
||||
def draw_highlight(self, highlight: HighlightedRange, painter: QPainter, y_line_offset: int):
|
||||
left_offset = -1 * self._left_offset * self.char_width
|
||||
x1 = highlight.get_start() * self.char_width
|
||||
width = highlight.get_width() * self.char_width
|
||||
def draw_highlights(self, highlights: [HighlightedRange], painter: QPainter, y_line_offset: int):
|
||||
|
||||
y1 = y_line_offset - self.char_height + self.char_height / 7
|
||||
height = self.char_height
|
||||
for highlight in highlights:
|
||||
if highlight.is_highlight_full_line():
|
||||
left_offset = -1 * self._left_offset * self.char_width
|
||||
y1 = y_line_offset - self.char_height + self.char_height / 7
|
||||
height = self.char_height
|
||||
full_width = Settings.max_line_length() * self.char_width
|
||||
rect = QRect(left_offset, y1, full_width, height)
|
||||
self.highlight_background(painter, rect, highlight.get_brush_full_line())
|
||||
|
||||
if highlight.is_highlight_full_line():
|
||||
full_width = Settings.max_line_length() * self.char_width
|
||||
rect = QRect(left_offset, y1, full_width, height)
|
||||
self.highlight_background(painter, rect, highlight.get_brush_full_line())
|
||||
for highlight in highlights:
|
||||
left_offset = -1 * self._left_offset * self.char_width
|
||||
x1 = highlight.get_start() * self.char_width
|
||||
width = highlight.get_width() * self.char_width
|
||||
y1 = y_line_offset - self.char_height + self.char_height / 7
|
||||
height = self.char_height
|
||||
|
||||
rect = QRect(left_offset + x1, y1, width, height)
|
||||
self.highlight_background(painter, rect, highlight.get_brush())
|
||||
rect = QRect(left_offset + x1, y1, width, height)
|
||||
self.highlight_background(painter, rect, highlight.get_brush())
|
||||
|
||||
def highlight_background(self, painter: QPainter, rect: QRect, brush: QBrush):
|
||||
old_brush = painter.brush()
|
||||
|
||||
Reference in New Issue
Block a user