Prepare for three channels STF

This commit is contained in:
2023-10-10 22:48:40 +02:00
parent 0c2c5f908c
commit 0a803ace10
10 changed files with 125 additions and 41 deletions
+21 -5
View File
@@ -10,18 +10,34 @@ static float clamp(float x)
return std::min(std::max(x, 0.0f), 1.0f);
}
STFSlider::STFSlider(QWidget *parent) : QWidget(parent)
STFSlider::STFSlider(const QColor &color, QWidget *parent) : QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumWidth(100);
setMinimumHeight(15);
setMaximumHeight(15);
setMouseTracking(true);
if(color == Qt::white)
{
setMaximumHeight(15);
setMinimumHeight(15);
}
else
{
setMaximumHeight(7);
setMinimumHeight(7);
}
m_blackPoint = 0;
m_midPoint = 0.5;
m_whitePoint = 1;
m_grabbed = -1;
m_fineTune = false;
m_color = color;
if(color == Qt::blue || color == Qt::red)
m_threshold = 1.1f;
else if(color == Qt::green)
m_threshold = 0.8f;
else
m_threshold = 0.4f;
setToolTip(tr("Press Shift for fine tuning"));
}
@@ -60,7 +76,7 @@ void STFSlider::paintEvent(QPaintEvent *event)
{
qreal p = i/32.0f;
qreal c = std::pow(p, 1.0/2.2)*255;
gradient.setColorAt(p, QColor(c, c, c));
gradient.setColorAt(p, QColor(m_color.redF()*c, m_color.greenF()*c, m_color.blueF()*c));
}
QPainterPath tick(QPointF(0, 0));
@@ -75,7 +91,7 @@ void STFSlider::paintEvent(QPaintEvent *event)
auto drawTick = [&](qreal p)
{
painter.setPen(p < 0.4 ? Qt::white : Qt::black);
painter.setPen(p < m_threshold ? Qt::white : Qt::black);
painter.resetTransform();
painter.translate(w*p, 0);
painter.drawPath(tick);