Skip to content

Commit

Permalink
All warnings are errors: types static_cast: doubles to float builds t…
Browse files Browse the repository at this point in the history
…he boat, floats to double get us in trouble
  • Loading branch information
austrianAudioJV committed Dec 13, 2023
1 parent 8ebbd53 commit 6fbd9af
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 281 deletions.
6 changes: 3 additions & 3 deletions resources/Delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Delay : private ProcessorBase


writePosition += L;
writePosition = writePosition % buffer.getNumSamples();
writePosition = writePosition % static_cast<size_t>(buffer.getNumSamples());
}
}

Expand All @@ -138,11 +138,11 @@ class Delay : private ProcessorBase

void getReadWritePositions (bool read, int numSamples, int& startIndex, int& blockSize1, int& blockSize2)
{
const int L = buffer.getNumSamples();
const size_t L = static_cast<size_t>(buffer.getNumSamples());
size_t pos = writePosition;
if (read)
{
pos = static_cast<int> (static_cast<unsigned int> (writePosition) - delayInSamples);
pos = static_cast<size_t> (static_cast<unsigned int> (writePosition) - delayInSamples);
}
if (pos < 0)
pos = pos + L;
Expand Down
10 changes: 5 additions & 5 deletions resources/customComponents/AlertOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class AlertOverlay : public Component, private Button::Listener, private Timer
}


};
}

~AlertOverlay() {
~AlertOverlay() override {
delete tbOkay;
if (type == Type::disturberTracking || type == Type::signalTracking)
{
Expand All @@ -127,7 +127,7 @@ class AlertOverlay : public Component, private Button::Listener, private Timer
stopTimer();
delete ppVisualizer;
}
};
}


void paint (Graphics& g) override
Expand Down Expand Up @@ -164,14 +164,14 @@ class AlertOverlay : public Component, private Button::Listener, private Timer

if (type == Type::errorMessage)
{
tbOkay->setBounds(width / 2.0f - errorButtonWidth / 2.0f, height - buttonHeight - mB, errorButtonWidth, buttonHeight);
tbOkay->setBounds(width / 2 - errorButtonWidth / 2, height - buttonHeight - mB, errorButtonWidth, buttonHeight);
}
else if (type == Type::disturberTracking || type == Type::signalTracking)
{
tbOkay->setBounds(mL + dvWidth + horSpace, height - buttonHeight - mB, trackingButtonWidth, buttonHeight);
tbRatio->setBounds(mL + dvWidth + trackingButtonWidth + buttonMargin + horSpace, height - buttonHeight - mB, trackingButtonWidth, buttonHeight);
tbCancel->setBounds(mL + dvWidth + 2 * trackingButtonWidth + 2 * buttonMargin + horSpace, height - buttonHeight - mB, trackingButtonWidth, buttonHeight);
ppVisualizer->setBounds(mL, mT + titleHeight + textMargin - 10.0f, dvWidth, dvWidth);
ppVisualizer->setBounds(mL, mT + titleHeight + textMargin - 10, dvWidth, dvWidth);
}
}

Expand Down
12 changes: 6 additions & 6 deletions resources/customComponents/AnimatedLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class AnimatedLabel : public juce::Component,

void paint (juce::Graphics& g) override
{
fontHeight = getTopLevelComponent()->getHeight() * 0.018f;
textArea = getLocalBounds().reduced(getLocalBounds().getWidth() * 0.06f, (getLocalBounds().getHeight() - fontHeight)/2);
fontHeight = static_cast<int>(getTopLevelComponent()->getHeight() * 0.018f);
textArea = getLocalBounds().reduced(static_cast<int>(getLocalBounds().getWidth() * 0.06f), (getLocalBounds().getHeight() - fontHeight)/2);
g.fillAll (mainLaF.labelBackgroundColor);

g.setColour (mainLaF.mainTextColor);
Expand All @@ -91,12 +91,12 @@ class AnimatedLabel : public juce::Component,

void resized() override
{
fontHeight = getTopLevelComponent()->getHeight() * 0.018f;
fontHeight = static_cast<int>(getTopLevelComponent()->getHeight() * 0.018f);

Font font(fontHeight);
textArea = getLocalBounds().reduced(getLocalBounds().getWidth() * 0.06f, (getLocalBounds().getHeight() - fontHeight) / 2);
textArea = getLocalBounds().reduced(static_cast<int>(getLocalBounds().getWidth() * 0.06f), (getLocalBounds().getHeight() - fontHeight) / 2);
auto centredTextArea = Rectangle<int>(textArea.getX(), textArea.getY() - fontHeight/4, textArea.getWidth(), fontHeight);
int equalSignWidth = getLocalBounds().getWidth() * 0.042f;
int equalSignWidth = static_cast<int>(getLocalBounds().getWidth() * 0.042f);
float rowProportion = static_cast<float>(font.getStringWidth(animatedString)) / static_cast<float>(centredTextArea.getWidth());

if (animatedString.length() > 0)
Expand All @@ -105,7 +105,7 @@ class AnimatedLabel : public juce::Component,
equalSignWidth = font.getStringWidth(animatedString) / animatedString.length();
if (font.getStringWidth(animatedString) > centredTextArea.getWidth())
{
int nrOfSignsInNewRow = (rowProportion - 1.f) * (centredTextArea.getWidth()/ equalSignWidth);
int nrOfSignsInNewRow = static_cast<int>((rowProportion - 1.f) * (centredTextArea.getWidth()/ equalSignWidth));
rectArea = centredTextArea.withWidth(equalSignWidth).translated(equalSignWidth * nrOfSignsInNewRow, fontHeight);
}
else
Expand Down
77 changes: 53 additions & 24 deletions resources/customComponents/DirSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class DirSlider : public Slider
DirSlider () :
Slider(),
lastDistanceFromDragStart(0),
reversed(false),
isDual(false),
scrollWheelEnabled(true),
// reversed(false),
// isDual(false),
// scrollWheelEnabled(true),
tooltipActive(false),
tooltipWidth(40),
tooltipHeight(20),
activePolarPatternPath(-1.0f),
// activePolarPatternPath(-1.0f),
patternStripSize(12),
dirStrip(this)
{
Expand All @@ -75,7 +75,7 @@ class DirSlider : public Slider
addAndMakeVisible(&dirStrip);
}

~DirSlider () {}
~DirSlider () override {}

class DirPatternStrip : public Component
{
Expand All @@ -90,10 +90,10 @@ class DirSlider : public Slider
eightPath.loadPathFromData (eightData, sizeof (eightData));
omniPath.loadPathFromData (omniData, sizeof (omniData));
revCardPath.loadPathFromData (cardData, sizeof (cardData));
revCardPath.applyTransform (AffineTransform::rotation(M_PI));
revCardPath.applyTransform (AffineTransform::rotation(static_cast<float> (M_PI)));
}

~DirPatternStrip() {}
~DirPatternStrip() override {}

void paint (Graphics& g) override
{
Expand All @@ -108,22 +108,48 @@ class DirSlider : public Slider
boundsY, dirImgSize, dirImgSize,
true, Justification::centred));
(slider->isEnabled()) ? g.setColour (Colours::white) : g.setColour (Colours::white.withMultipliedAlpha(0.5f));
g.strokePath (revCardPath, PathStrokeType (activePatternPath == revCardFact ? 2.0f : 1.0f));

omniPath.applyTransform (omniPath.getTransformToScaleToFit(boundsX + 0.33 * width - dirImgSize/2.0f + 2.0f ,
if (floatsEquivalent(activePatternPath, revCardFact))
{
g.strokePath (revCardPath, PathStrokeType (2.0f));
}
else
{
g.strokePath (revCardPath, PathStrokeType (1.0f));
}

omniPath.applyTransform (omniPath.getTransformToScaleToFit(static_cast<float> (boundsX + 0.33 * width - dirImgSize / 2.0f + 2.0f),
boundsY, dirImgSize, dirImgSize,
true, Justification::centred));
g.strokePath (omniPath, PathStrokeType (activePatternPath == omniFact ? 2.0f : 1.0f));
if (floatsEquivalent(activePatternPath, omniFact))
{
g.strokePath (omniPath, PathStrokeType (2.0f));
}
else
{
g.strokePath (omniPath, PathStrokeType (1.0f));
}

cardPath.applyTransform (cardPath.getTransformToScaleToFit(boundsX + 0.66 * width - dirImgSize/2.0f - 1.0f,
cardPath.applyTransform (cardPath.getTransformToScaleToFit(static_cast<float> (boundsX + 0.66 * width - dirImgSize / 2.0f - 1.0f),
boundsY, dirImgSize, dirImgSize,
true, Justification::centred));
g.strokePath (cardPath, PathStrokeType (activePatternPath == cardFact ? 2.0f : 1.0f));
if (floatsEquivalent(activePatternPath, cardFact))
{
g.strokePath (cardPath, PathStrokeType (2.0f));
}
else
{
g.strokePath (cardPath, PathStrokeType (1.0f));
}

eightPath.applyTransform (eightPath.getTransformToScaleToFit(boundsX + width - dirImgSize,
boundsY, dirImgSize, dirImgSize,
true, Justification::centred));
g.strokePath (eightPath, PathStrokeType (activePatternPath == eightFact ? 2.0f : 1.0f));
if (floatsEquivalent(activePatternPath, eightFact)) {
g.strokePath (eightPath, PathStrokeType (2.0f));
}
else {
g.strokePath (eightPath, PathStrokeType (1.0f));
}
}

void mouseMove(const MouseEvent &e) override
Expand All @@ -141,23 +167,25 @@ class DirSlider : public Slider
else if (cardPath.getBounds().contains(posf)) activePatternPath = cardFact;
else if (revCardPath.getBounds().contains(posf)) activePatternPath = revCardFact;

if (oldActivePath != activePatternPath)
if (!floatsEquivalent(oldActivePath, activePatternPath))
repaint();
}

void mouseUp (const MouseEvent &e) override
{
(void)e;
if (!slider->isEnabled())
return;

if (activePatternPath != -1)
if (!floatsEquivalent(activePatternPath,-1))
{
slider->setValue (activePatternPath, NotificationType::sendNotification);
}
}

void mouseExit (const MouseEvent& e) override
{
(void)e;
activePatternPath = -1;
repaint();
}
Expand Down Expand Up @@ -225,6 +253,7 @@ class DirSlider : public Slider

void mouseExit (const MouseEvent& e) override
{
(void)e;
tooltipActive = false;

if (tooltipValueBox != nullptr && !tooltipValueBox->isMouseOver() && !tooltipValueBox->isBeingEdited())
Expand All @@ -248,9 +277,9 @@ class DirSlider : public Slider
auto layout = lf.getSliderLayout (*this);

sliderRect = layout.sliderBounds;
sliderRect.removeFromTop(patternStripSize);
sliderRect.removeFromTop(static_cast<int> (patternStripSize));

dirPatternBounds = getLocalBounds().removeFromTop(patternStripSize);
dirPatternBounds = getLocalBounds().removeFromTop(static_cast<int> (patternStripSize));
dirStrip.setBounds(dirPatternBounds);

initValueBox();
Expand Down Expand Up @@ -279,12 +308,12 @@ class DirSlider : public Slider

void tooltipTextChanged()
{
if (getValueFromText (tooltipValueBox->getText()) == getValue())
if (doublesEquivalent(getValueFromText (tooltipValueBox->getText()), getValue()))
return;

double newValue = snapValueToRange (getValueFromText (tooltipValueBox->getText()));

if (newValue != static_cast<double> (getValue()))
if (!doublesEquivalent(newValue, getValue()))
{
setValue (newValue, NotificationType::sendNotification);
tooltipValueBox->setText (getTextFromValue (newValue), NotificationType::dontSendNotification);
Expand All @@ -307,16 +336,16 @@ class DirSlider : public Slider

private:
int lastDistanceFromDragStart;
bool reversed;
bool isDual;
bool scrollWheelEnabled;
// bool reversed;
// bool isDual;
// bool scrollWheelEnabled;
bool tooltipActive;
Rectangle<int> sliderRect;
Rectangle<int> dirPatternBounds;

int tooltipWidth;
int tooltipHeight;
float activePolarPatternPath;
// float activePolarPatternPath;
float patternStripSize;

std::unique_ptr<Label> tooltipValueBox;
Expand Down
Loading

0 comments on commit 6fbd9af

Please sign in to comment.