fix mouse over in list

This commit is contained in:
Geoffray Levasseur committed 2026-11-09 11:52:17 +01:00
1 parent f7f4e4670b
commit d37a20ce30
1 file changed
+9 -17
+9 -17
View File
@@ -1250,7 +1250,7 @@ void ListDlg::offscreenPaint()
for (int i = -1; i <= dispLines; ++i) for (int i = -1; i <= dispLines; ++i)
if (i + scrollBar->position() >= 0 && i + scrollBar->position() < static_cast<int>(layer->lines().size())) if (i + scrollBar->position() >= 0 && i + scrollBar->position() < static_cast<int>(layer->lines().size()))
paintLine(canvas, i, true, false, false); paintLine(canvas, i, true, i == selected, false);
canvas.end(); canvas.end();
markUsedOffscreen(innerWidth, 8 + 48 + dispLines * lineDistance); markUsedOffscreen(innerWidth, 8 + 48 + dispLines * lineDistance);
@@ -1593,16 +1593,10 @@ void ListDlg::mouseMoveEvent(QMouseEvent *event)
selected + i0 >= static_cast<int>(layer->lines().size())) selected + i0 >= static_cast<int>(layer->lines().size()))
selected = -2; selected = -2;
if (selected != sel0) { if (selected != sel0) {
QPainter painter(this); // Qt doesn't allow painting a widget directly outside paintEvent()
if (!painter.isActive()) // (unlike the original's live Form.Canvas updates) - offscreenPaint()
return; // now paints the hovered line "lit", so just trigger a real repaint.
Dpi::Canvas canvas; update();
canvas.bind(&painter);
if (sel0 != -2)
paintLine(canvas, sel0, false, false, true);
if (selected != -2)
paintLine(canvas, selected, false, true, true);
canvas.unbind();
} }
if (kind == ListKind::Science) { if (kind == ListKind::Science) {
@@ -1615,11 +1609,8 @@ void ListDlg::mouseMoveEvent(QMouseEvent *event)
scienceNation = column[static_cast<std::size_t>(iColumn)]; scienceNation = column[static_cast<std::size_t>(iColumn)];
} }
if (scienceNation != oldScienceNation) { if (scienceNation != oldScienceNation) {
QPainter painter(this); Dpi::Canvas &canvas = offscreen.canvas();
if (!painter.isActive()) canvas.begin();
return;
Dpi::Canvas canvas;
canvas.bind(&painter);
fill(canvas, 9, height() - 29, width() - 18, 24, (MainTexture->width() - width()) / 2, fill(canvas, 9, height() - 29, width() - 18, 24, (MainTexture->width() - width()) / 2,
(MainTexture->height() - height()) / 2); (MainTexture->height() - height()) / 2);
if (scienceNation >= 0) { if (scienceNation >= 0) {
@@ -1639,7 +1630,8 @@ void ListDlg::mouseMoveEvent(QMouseEvent *event)
canvas.fillRect(QRect(xScreen - 10, height() - 27, 17, 17)); canvas.fillRect(QRect(xScreen - 10, height() - 27, 17, 17));
canvas.brush().setStyle(Qt::NoBrush); canvas.brush().setStyle(Qt::NoBrush);
} }
canvas.unbind(); canvas.end();
update(9, height() - 29, width() - 18, 24);
} }
} }
} }