Added preview to circle counter and auto adjust circle count font color.

This commit is contained in:
Jeremy Borgman
2020-09-19 20:38:06 -05:00
committed by borgmanJeremy
parent c7d557e387
commit c56bb78cf3

View File

@@ -95,8 +95,14 @@ CircleCountTool::process(QPainter& painter,
painter.boundingRect(textRect, Qt::AlignCenter, QString::number(m_count));
}
painter.drawText(textRect, Qt::AlignCenter, QString::number(m_count));
// Lightness value ranges from 0-255, we split at 75 as this looks best
if (m_color.lightness() <= 75) {
painter.setPen(Qt::white);
} else {
painter.setPen(Qt::black);
}
painter.drawText(textRect, Qt::AlignCenter, QString::number(m_count));
painter.setFont(orig_font);
}
@@ -104,11 +110,17 @@ void
CircleCountTool::paintMousePreview(QPainter& painter,
const CaptureContext& context)
{
painter.setPen(QPen(context.color,
PADDING_VALUE + context.thickness,
Qt::SolidLine,
Qt::RoundCap));
painter.drawLine(context.mousePos, context.mousePos);
m_thickness = context.thickness + PADDING_VALUE;
if (m_thickness < 15) {
m_thickness = 15;
}
// Thickness for pen is *2 to range from radius to diameter to match the
// ellipse draw function
painter.setPen(
QPen(context.color, m_thickness * 2, Qt::SolidLine, Qt::RoundCap));
painter.drawLine(context.mousePos,
{ context.mousePos.x() + 1, context.mousePos.y() + 1 });
}
void