From 5f9c066626d5e23db324986f70160e7cc80b6c83 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Fri, 2 Jul 2021 14:52:56 +0200 Subject: [PATCH] [LYN-4437] Added 30% opaque overlay to the background image of the Project Manager * 30% opaque overlay image to darken down the colors and increase usability and accessibility. * Some code cleaning. Signed-off-by: Benjamin Jillich --- .../ProjectManager/Source/ProjectsScreen.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index 80fb5dcb71..b3ecd96e43 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -269,21 +269,30 @@ namespace O3DE::ProjectManager // we paint the background here because qss does not support background cover scaling QPainter painter(this); - auto winSize = size(); - auto pixmapRatio = (float)m_background.width() / m_background.height(); - auto windowRatio = (float)winSize.width() / winSize.height(); + const QSize winSize = size(); + const float pixmapRatio = (float)m_background.width() / m_background.height(); + const float windowRatio = (float)winSize.width() / winSize.height(); + QRect backgroundRect; if (pixmapRatio > windowRatio) { - auto newWidth = (int)(winSize.height() * pixmapRatio); - auto offset = (newWidth - winSize.width()) / -2; - painter.drawPixmap(offset, 0, newWidth, winSize.height(), m_background); + const int newWidth = (int)(winSize.height() * pixmapRatio); + const int offset = (newWidth - winSize.width()) / -2; + backgroundRect = QRect(offset, 0, newWidth, winSize.height()); } else { - auto newHeight = (int)(winSize.width() / pixmapRatio); - painter.drawPixmap(0, 0, winSize.width(), newHeight, m_background); + const int newHeight = (int)(winSize.width() / pixmapRatio); + backgroundRect = QRect(0, 0, winSize.width(), newHeight); } + + // Draw the background image. + painter.drawPixmap(backgroundRect, m_background); + + // Draw a semi-transparent overlay to darken down the colors. + painter.setCompositionMode (QPainter::CompositionMode_DestinationIn); + const float overlayTransparency = 0.7f; + painter.fillRect(backgroundRect, QColor(0, 0, 0, static_cast(255.0f * overlayTransparency))); } void ProjectsScreen::HandleNewProjectButton()