Change RenderDoc style checkboxes to use checks for low contrast themes

* Deliberately low contrast themes like the dark theme can have issues showing a
  box that is filled vs just a plain rectangle which is harder to read at a
  glance. Changing the fill to an X icon gives extra readability on the dark
  theme.
This commit is contained in:
baldurk
2023-07-26 14:40:23 +01:00
parent db6dadad6c
commit 7452e29cec
+84 -1
View File
@@ -44,6 +44,7 @@ static const int HighlightBorder = 2;
static const int CheckWidth = 14;
static const int CheckHeight = 14;
static float CheckCornerSize = 2.0f;
static const int CheckMargin = 3;
static const int GroupHMargin = 8;
@@ -1567,7 +1568,89 @@ void RDStyle::drawControl(ControlElement control, const QStyleOption *opt, QPain
if(opt->state & State_On)
{
p->fillRect(rect, opt->palette.brush(QPalette::ButtonText));
QPainterPath checkpath;
QPolygonF poly;
// Left side:
//
// X
// | CheckCornerSize
// X
// \\ innerSize (width and height)
// \\
// CheckHeight X
// /
// /
// X
// | CheckCornerSize
// X
// Top side:
//
// X---X X----X
// \\ /
// \\ /
// X
Q_ASSERT(rect.height() == rect.width());
const float innerSize = float(rect.height() - Constants::CheckCornerSize * 2) / 2.0f;
const float totalSize = innerSize * 2 + Constants::CheckCornerSize * 2;
Q_ASSERT(totalSize == rect.height());
// left edge
QPointF pt = rect.topLeft();
poly << pt;
pt.setY(pt.y() + Constants::CheckCornerSize);
poly << pt;
pt.setY(pt.y() + innerSize);
pt.setX(pt.x() + innerSize);
poly << pt;
pt.setY(pt.y() + innerSize);
pt.setX(pt.x() - innerSize);
poly << pt;
pt.setY(pt.y() + Constants::CheckCornerSize);
poly << pt;
// bottom edge
pt.setX(pt.x() + Constants::CheckCornerSize);
poly << pt;
pt.setX(pt.x() + innerSize);
pt.setY(pt.y() - innerSize);
poly << pt;
pt.setX(pt.x() + innerSize);
pt.setY(pt.y() + innerSize);
poly << pt;
pt.setX(pt.x() + Constants::CheckCornerSize);
poly << pt;
// right edge
pt.setY(pt.y() - Constants::CheckCornerSize);
poly << pt;
pt.setX(pt.x() - innerSize);
pt.setY(pt.y() - innerSize);
poly << pt;
pt.setX(pt.x() + innerSize);
pt.setY(pt.y() - innerSize);
poly << pt;
pt.setY(pt.y() - Constants::CheckCornerSize);
poly << pt;
// topt edge
pt.setX(pt.x() - Constants::CheckCornerSize);
poly << pt;
pt.setX(pt.x() - innerSize);
pt.setY(pt.y() + innerSize);
poly << pt;
pt.setX(pt.x() - innerSize);
pt.setY(pt.y() - innerSize);
poly << pt;
pt.setX(pt.x() - Constants::CheckCornerSize);
poly << pt;
checkpath.addPolygon(poly);
p->fillPath(checkpath, opt->palette.brush(QPalette::ButtonText));
}
else if(opt->state & State_NoChange)
{