Fix issue with one frame flicker in the transition between paint modes.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
Danilo Aimini
2021-09-15 14:44:27 -07:00
parent f6def71088
commit f111b67df6
@@ -48,7 +48,7 @@ namespace AzQtComponents
void FancyDockingGhostWidget::setPixmap(const QPixmap& pixmap, const QRect& targetRect, QScreen* screen) void FancyDockingGhostWidget::setPixmap(const QPixmap& pixmap, const QRect& targetRect, QScreen* screen)
{ {
const bool needsRepaint = m_pixmap.cacheKey() != pixmap.cacheKey() || m_clipToWidgets; bool needsRepaint = m_pixmap.cacheKey() != pixmap.cacheKey() || m_clipToWidgets;
m_pixmap = pixmap; m_pixmap = pixmap;
if (pixmap.isNull() || targetRect.isNull() || !screen) if (pixmap.isNull() || targetRect.isNull() || !screen)
@@ -80,6 +80,7 @@ namespace AzQtComponents
QPoint midPoint = targetRect.topLeft() + QPoint(targetRect.width() / 2, targetRect.height() / 2); QPoint midPoint = targetRect.topLeft() + QPoint(targetRect.width() / 2, targetRect.height() / 2);
QScreen* pointScreen = QApplication::screenAt(midPoint); QScreen* pointScreen = QApplication::screenAt(midPoint);
QRect rect(targetRect); QRect rect(targetRect);
PaintMode paintMode = PaintMode::FULL;
if (!pointScreen || pointScreen != screen) if (!pointScreen || pointScreen != screen)
{ {
@@ -87,26 +88,28 @@ namespace AzQtComponents
{ {
rect.setLeft(rect.left() - rect.width()); rect.setLeft(rect.left() - rect.width());
rect.setTop(rect.top() - rect.height()); rect.setTop(rect.top() - rect.height());
m_paintMode = PaintMode::BOTTOMRIGHT; paintMode = PaintMode::BOTTOMRIGHT;
} }
else else
{ {
rect.setRight(rect.right() + rect.width()); rect.setRight(rect.right() + rect.width());
rect.setTop(rect.top() - rect.height()); rect.setTop(rect.top() - rect.height());
m_paintMode = PaintMode::BOTTOMLEFT; paintMode = PaintMode::BOTTOMLEFT;
} }
} }
else
if (m_paintMode != paintMode)
{ {
m_paintMode = PaintMode::FULL; needsRepaint = true;
} }
setGeometry(rect); setGeometry(rect);
m_paintMode = paintMode;
setPixmapVisible(true); setPixmapVisible(true);
if (needsRepaint) if (needsRepaint)
{ {
update(); repaint();
} }
} }