Fixes issue with painters being saved and not restored in some cases, which would print numerous warnings in the VS console. (#7296)

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
monroegm-disable-blank-issue-2
Danilo Aimini 4 years ago committed by GitHub
parent 2dbc961ea8
commit e1c7dce7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -306,41 +306,37 @@ namespace AzToolsFramework
{ {
// Only show the close icon if the prefab is expanded. // Only show the close icon if the prefab is expanded.
// This allows the prefab container to be opened if it was collapsed during propagation. // This allows the prefab container to be opened if it was collapsed during propagation.
if (!isExpanded) if (isExpanded)
{ {
return; // Use the same color as the background.
} QColor backgroundColor = m_backgroundColor;
if (isSelected)
// Use the same color as the background. {
QColor backgroundColor = m_backgroundColor; backgroundColor = m_backgroundSelectedColor;
if (isSelected) }
{ else if (isHovered)
backgroundColor = m_backgroundSelectedColor; {
} backgroundColor = m_backgroundHoverColor;
else if (isHovered) }
{
backgroundColor = m_backgroundHoverColor;
}
// Paint a rect to cover up the expander. // Paint a rect to cover up the expander.
QRect rect = QRect(0, 0, 16, 16); QRect rect = QRect(0, 0, 16, 16);
rect.translate(option.rect.topLeft() + offset); rect.translate(option.rect.topLeft() + offset);
painter->fillRect(rect, backgroundColor); painter->fillRect(rect, backgroundColor);
// Paint the icon. // Paint the icon.
QIcon closeIcon = QIcon(m_prefabEditCloseIconPath); QIcon closeIcon = QIcon(m_prefabEditCloseIconPath);
painter->drawPixmap(option.rect.topLeft() + offset, closeIcon.pixmap(iconSize)); painter->drawPixmap(option.rect.topLeft() + offset, closeIcon.pixmap(iconSize));
}
} }
else else
{ {
// Only show the edit icon on hover. // Only show the edit icon on hover.
if (!isHovered) if (isHovered)
{ {
return; QIcon openIcon = QIcon(m_prefabEditOpenIconPath);
painter->drawPixmap(option.rect.topLeft() + offset, openIcon.pixmap(iconSize));
} }
QIcon openIcon = QIcon(m_prefabEditOpenIconPath);
painter->drawPixmap(option.rect.topLeft() + offset, openIcon.pixmap(iconSize));
} }
painter->restore(); painter->restore();

Loading…
Cancel
Save