diff --git a/qrenderdoc/Styles/RDStyle/RDStyle.cpp b/qrenderdoc/Styles/RDStyle/RDStyle.cpp index 5f6da9741..9e259a7f1 100644 --- a/qrenderdoc/Styles/RDStyle/RDStyle.cpp +++ b/qrenderdoc/Styles/RDStyle/RDStyle.cpp @@ -27,15 +27,105 @@ #include #include #include +#include "Code/QRDUtils.h" RDStyle::RDStyle(ColorScheme scheme) : RDTweakedNativeStyle() { + m_Scheme = scheme; } RDStyle::~RDStyle() { } +void RDStyle::polish(QPalette &pal) +{ + int h = 0, s = 0, v = 0; + + QColor windowText; + QColor window; + QColor base; + QColor highlight; + QColor tooltip; + + if(m_Scheme == Light) + { + window = QColor(225, 225, 225); + windowText = QColor(Qt::black); + base = QColor(Qt::white); + highlight = QColor(80, 110, 160); + tooltip = QColor(250, 245, 200); + } + else + { + window = QColor(45, 55, 60); + windowText = QColor(225, 225, 225); + base = QColor(22, 27, 30); + highlight = QColor(100, 130, 200); + tooltip = QColor(70, 70, 65); + } + + QColor light = window.lighter(150); + QColor mid = window.darker(150); + QColor dark = mid.darker(150); + + QColor text = windowText; + + pal = QPalette(windowText, window, light, dark, mid, text, base); + + pal.setColor(QPalette::Shadow, Qt::black); + + if(m_Scheme == Light) + pal.setColor(QPalette::AlternateBase, base.darker(110)); + else + pal.setColor(QPalette::AlternateBase, base.lighter(110)); + + pal.setColor(QPalette::ToolTipBase, tooltip); + pal.setColor(QPalette::ToolTipText, text); + + pal.setColor(QPalette::Highlight, highlight); + // inactive highlight is desaturated + highlight.getHsv(&h, &s, &v); + highlight.setHsv(h, int(s * 0.5), v); + pal.setColor(QPalette::Inactive, QPalette::Highlight, highlight); + + pal.setColor(QPalette::HighlightedText, Qt::white); + + // links are based on the highlight colour + QColor link = highlight.lighter(105); + pal.setColor(QPalette::Link, link); + + // visited links are desaturated + QColor linkVisited = link; + linkVisited.getHsv(&h, &s, &v); + linkVisited.setHsv(h, 0, v); + pal.setColor(QPalette::LinkVisited, linkVisited); + + for(int i = 0; i < QPalette::NColorRoles; i++) + { + QPalette::ColorRole role = (QPalette::ColorRole)i; + + // skip tooltip roles entirely + if(role == QPalette::ToolTipBase || role == QPalette::ToolTipText) + continue; + + // with the exception of link text, the disabled version is desaturated + QColor col = pal.color(QPalette::Inactive, role); + + if(role != QPalette::Link) + { + col.getHsv(&h, &s, &v); + col.setHsv(h, 0, v); + } + + // the disabled version is closer to mid grey than inactive + if(getLuminance(col) > 0.5) + pal.setColor(QPalette::Disabled, role, col.darker(125)); + else + pal.setColor(QPalette::Disabled, role, col.lighter(125)); + } +} + QRect RDStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const { return RDTweakedNativeStyle::subElementRect(element, opt, widget); diff --git a/qrenderdoc/Styles/RDStyle/RDStyle.h b/qrenderdoc/Styles/RDStyle/RDStyle.h index fb03b5367..0f7db3840 100644 --- a/qrenderdoc/Styles/RDStyle/RDStyle.h +++ b/qrenderdoc/Styles/RDStyle/RDStyle.h @@ -41,6 +41,8 @@ public: RDStyle(ColorScheme scheme); ~RDStyle(); + void polish(QPalette &pal) override; + QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override; QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, @@ -57,4 +59,5 @@ public: const QWidget *widget = NULL) const override; protected: + ColorScheme m_Scheme = Light; };