Skip to content

Commit

Permalink
Silence some float conversion warnings by making conversion explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed May 31, 2023
1 parent 88e990a commit 1298391
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrenderbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void WaveformRenderBeat::paintGL() {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

m_color.setAlphaF(alpha / 100.0);
m_color.setAlphaF(alpha / 100.0f);

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void WaveformRendererEndOfTrack::paintGL() {

if (alpha != 0.0) {
QColor color = m_color;
color.setAlphaF(alpha);
color.setAlphaF(static_cast<float>(alpha));

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void allshader::WaveformRenderMark::paintGL() {

if (visible || currentMarkEndPoint > 0) {
QColor color = pMark->fillColor();
color.setAlphaF(0.4);
color.setAlphaF(0.4f);

drawMark(
QRectF(QPointF(currentMarkPoint, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void allshader::WaveformRenderMarkRange::paintGL() {
}

QColor color = markRange.enabled() ? markRange.m_activeColor : markRange.m_disabledColor;
color.setAlphaF(0.3);
color.setAlphaF(0.3f);

fillRect(QRectF(startPosition, 0, span, m_waveformRenderer->getBreadth()), color);
}
Expand Down
18 changes: 9 additions & 9 deletions src/waveform/renderers/qtwaveformrendererfilteredsignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ void QtWaveformRendererFilteredSignal::onSetup(const QDomNode& /*node*/) {
QColor midCenter = mid;
QColor highCenter = high;

low.setAlphaF(0.9);
mid.setAlphaF(0.9);
high.setAlphaF(0.9);
low.setAlphaF(0.9f);
mid.setAlphaF(0.9f);
high.setAlphaF(0.9f);

lowCenter.setAlphaF(0.5);
midCenter.setAlphaF(0.5);
highCenter.setAlphaF(0.5);
lowCenter.setAlphaF(0.5f);
midCenter.setAlphaF(0.5f);
highCenter.setAlphaF(0.5f);

QLinearGradient gradientLow(QPointF(0.0,-255.0/2.0),QPointF(0.0,255.0/2.0));
gradientLow.setColorAt(0.0, low);
Expand All @@ -60,9 +60,9 @@ void QtWaveformRendererFilteredSignal::onSetup(const QDomNode& /*node*/) {
gradientHigh.setColorAt(1.0, high);
m_highBrush = QBrush(gradientHigh);

low.setAlphaF(0.3);
mid.setAlphaF(0.3);
high.setAlphaF(0.3);
low.setAlphaF(0.3f);
mid.setAlphaF(0.3f);
high.setAlphaF(0.3f);

QLinearGradient gradientKilledLow(QPointF(0.0,-255.0/2.0),QPointF(0.0,255.0/2.0));
gradientKilledLow.setColorAt(0.0,low.darker(80));
Expand Down
6 changes: 3 additions & 3 deletions src/waveform/renderers/qtwaveformrenderersimplesignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ void QtWaveformRendererSimpleSignal::onSetup(const QDomNode& node) {
Q_UNUSED(node);

QColor borderColor = m_pColors->getSignalColor().lighter(125);
borderColor.setAlphaF(0.5);
borderColor.setAlphaF(0.5f);
m_borderPen.setColor(borderColor);
m_borderPen.setWidthF(1.25);
m_borderPen.setWidthF(1.25f);

QColor signalColor = m_pColors->getSignalColor();
signalColor.setAlphaF(0.8);
signalColor.setAlphaF(0.8f);
m_brush = QBrush(signalColor);
}

Expand Down
4 changes: 2 additions & 2 deletions src/waveform/renderers/waveformmarkrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void WaveformMarkRange::generateImage(int weidth, int height) {
m_disabledImage.fill(QColor(0,0,0,0).rgba());

QColor activeColor = m_activeColor;
activeColor.setAlphaF(0.3);
activeColor.setAlphaF(0.3f);
QBrush brush(activeColor);

QPainter painter;
Expand All @@ -131,7 +131,7 @@ void WaveformMarkRange::generateImage(int weidth, int height) {
painter.end();

QColor disabledColor = m_disabledColor;
disabledColor.setAlphaF(0.3);
disabledColor.setAlphaF(0.3f);
brush = QBrush(disabledColor);

painter.begin(&m_disabledImage);
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/renderers/waveformrendererhsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ void WaveformRendererHSV::draw(
lo = (maxLow[0] + maxLow[1]) / total;
hi = (maxHigh[0] + maxHigh[1]) / total;
} else {
lo = hi = 0.0;
lo = hi = 0.0f;
}

// Set color
color.setHsvF(h, 1.0-hi, 1.0-lo);
color.setHsvF(h, 1.0f - hi, 1.0f - lo);

pen.setColor(color);

Expand Down
4 changes: 2 additions & 2 deletions src/waveform/renderers/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) {
sampleEndPosition);
if (visible || currentMarkEndPoint > 0) {
QColor color = pMark->fillColor();
color.setAlphaF(0.4);
color.setAlphaF(0.4f);

QLinearGradient gradient(QPointF(0, 0),
QPointF(0, m_waveformRenderer->getHeight()));
Expand Down Expand Up @@ -131,7 +131,7 @@ void WaveformRenderMark::draw(QPainter* painter, QPaintEvent* /*event*/) {
sampleEndPosition);
if (currentMarkEndPoint < m_waveformRenderer->getHeight()) {
QColor color = pMark->fillColor();
color.setAlphaF(0.4);
color.setAlphaF(0.4f);

QLinearGradient gradient(QPointF(0, 0),
QPointF(m_waveformRenderer->getWidth(), 0));
Expand Down
32 changes: 22 additions & 10 deletions src/waveform/renderers/waveformsignalcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,41 @@ void WaveformSignalColors::fallBackFromSignalColor() {
if (s < 0.1) { // gray
const float sMax = 1.0f - h;
m_lowColor.setHslF(h,s,l);
m_midColor.setHslF(h,s+sMax*0.2,l);
m_highColor.setHslF(h,s+sMax*0.4,l);
m_midColor.setHslF(h, s + sMax * 0.2f, l);
m_highColor.setHslF(h, s + sMax * 0.4f, l);
} else {
if (l < 0.1) { // ~white
const float lMax = 1.0f - l;
m_lowColor.setHslF(h,s,l);
m_midColor.setHslF(h,s,l+lMax*0.2);
m_highColor.setHslF(h,s,l+lMax*0.4);
m_midColor.setHslF(h, s, l + lMax * 0.2f);
m_highColor.setHslF(h, s, l + lMax * 0.4f);
} else if (l < 0.5) {
const float lMax = 1.0f - l;
m_lowColor.setHslF(h,s,l);
m_midColor.setHslF(stableHue(h-analogousAngle*0.3),s,l+lMax*0.1);
m_highColor.setHslF(stableHue(h+analogousAngle*0.3),s,l+lMax*0.4);
m_midColor.setHslF(
static_cast<float>(stableHue(h - analogousAngle * 0.3)),
s,
l + lMax * 0.1f);
m_highColor.setHslF(
static_cast<float>(stableHue(h + analogousAngle * 0.3)),
s,
l + lMax * 0.4f);
} else if (l < 0.9) {
const float lMin = l;
m_lowColor.setHslF(h,s,l);
m_midColor.setHslF(stableHue(h-analogousAngle*0.3),s,l-lMin*0.1);
m_highColor.setHslF(stableHue(h+analogousAngle*0.3),s,l-lMin*0.4);
m_midColor.setHslF(
static_cast<float>(stableHue(h - analogousAngle * 0.3)),
s,
l - lMin * 0.1f);
m_highColor.setHslF(
static_cast<float>(stableHue(h + analogousAngle * 0.3)),
s,
l - lMin * 0.4f);
} else { // ~black
const float lMin = l;
m_lowColor.setHslF(h,s,l);
m_midColor.setHslF(h,s,l-lMin*0.2);
m_highColor.setHslF(h,s,l-lMin*0.4);
m_midColor.setHslF(h, s, l - lMin * 0.2f);
m_highColor.setHslF(h, s, l - lMin * 0.4f);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga

if (rect.isValid()) {
QColor loopColor = pMark->fillColor();
loopColor.setAlphaF(0.5);
loopColor.setAlphaF(0.5f);
pPainter->fillRect(rect, loopColor);
}

Expand Down Expand Up @@ -1260,7 +1260,7 @@ void WOverview::drawPassthroughOverlay(QPainter* pPainter) {

void WOverview::paintText(const QString& text, QPainter* pPainter) {
PainterScope painterScope(pPainter);
m_lowColor.setAlphaF(0.5);
m_lowColor.setAlphaF(0.5f);
QPen lowColorPen(
QBrush(m_lowColor), 1.25 * m_scaleFactor, Qt::SolidLine, Qt::RoundCap);
pPainter->setPen(lowColorPen);
Expand Down
2 changes: 1 addition & 1 deletion src/widget/woverviewhsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool WOverviewHSV::drawNextPixmapPart() {
}

// Set color
color.setHsvF(h, 1.0-hi, 1.0-lo);
color.setHsvF(h, 1.0f - hi, 1.0f - lo);

painter.setPen(color);
painter.drawLine(QPoint(currentCompletion / 2, -maxAll[0]),
Expand Down
8 changes: 4 additions & 4 deletions src/widget/wspinnybase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ void WSpinnyBase::updateSlipEnabled(double enabled) {

void WSpinnyBase::mouseMoveEvent(QMouseEvent* e) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int y = e->position().y();
int x = e->position().x();
int y = static_cast<int>(e->position().y());
int x = static_cast<int>(e->position().x());
#else
int y = e->y();
int x = e->x();
Expand Down Expand Up @@ -577,8 +577,8 @@ void WSpinnyBase::mousePressEvent(QMouseEvent* e) {
}

if (e->button() == Qt::LeftButton) {
int y = e->y();
int x = e->x();
int y = static_cast<int>(e->position().x());
int x = static_cast<int>(e->position().y());

m_iStartMouseX = x;
m_iStartMouseY = y;
Expand Down

0 comments on commit 1298391

Please sign in to comment.