Why is paint trying to convert Rectangle int to float when using live build?

I am getting this error using live build and don’t quite know how to translate it as the code compiles just fine in xCode and the plug does what I expect it to.

projucer_LiveComponentUtils.cpp: no viable conversion from ‘Rectangle<int>’ to ‘Rectangle<float>’

The viewport bounds are all ints in resized()…

component1->setBounds (20, 72, 224, 288);

The error shows itself as being related to visibleArea in the paint method…

void paint (Graphics& g) override
    auto visibleArea = viewport.getBounds();
    g.fillCheckerBoard (visibleArea, 24, 24, Colour (0xffeeeeee), Colour (0xffffffff));
    drawInnerShadow (g, visibleArea, 8);

I am sure I am doing something that is quite simple, quite simply wrong, but I have no earthly idea what that might be. Any help you can offer would be much appreciated.

Thank you very much!

I don’t know the method drawInnerShadow, but I assume it expects a Rectangle<float>.
The visibleArea is of type Rectangle<int>. But you can easily convert that by replacing the call:

drawInnerShadow (g, visibleArea.toFloat(), 8);

Good luck.

Thank you for the response Daniel; I appreciate that.

Still, I am hesitant to modify juce code & it seems likely that it is something that i am doing in my code coupled with some change made to dev recently that causes this.

This is in the LiveCompHolder class. Here is the definition of drawInnerShadow:

static void drawInnerShadow (Graphics& g, const Rectangle<int>& area, const int shadowSize)
    auto x = area.getX(), y = area.getY();
    auto r = area.getRight(), b = area.getBottom();

    ColourGradient cg (Colours::black.withAlpha (0.2f), 0.0f, (float) y,
                       Colours::transparentBlack, 0.0f, (float) (y + shadowSize), false);
    cg.addColour (0.3, Colours::black.withAlpha (0.1f));

    g.setGradientFill (cg);
    g.fillRect (x, y, r - x, shadowSize);

    cg.point1.setXY (0.0f, (float) b);
    cg.point2.setXY (0.0f, (float) (b - shadowSize));
    g.setGradientFill (cg);
    g.fillRect (x, b - shadowSize, r - x, shadowSize);

    cg.point1.setXY ((float) x, 0.0f);
    cg.point2.setXY ((float) (x + shadowSize), 0.0f);
    g.setGradientFill (cg);
    g.fillRect (x, y, shadowSize, b - y);

    cg.point1.setXY ((float) r, 0.0f);
    cg.point2.setXY ((float) r - shadowSize, 0.0f);
    g.setGradientFill (cg);
    g.fillRect (r - shadowSize, y, shadowSize, b - y);

This has not happened before, which makes me suspect that this could be some kind of revenge for not buying better holiday gifts. Seems outside of the spirit of the whole thing, really. Perhaps my wife did this somehow. I really must get her better gifts.

Ah, in this case I assumed wrong. So it seems to be not as easy as I thought.

Unfortunately I can’t find the source file you mentioned… and you are right, patching a juce file is not the proper solution.

Haha, I love that! :slight_smile:

It is bizarre. I can’t find the file in the repo either.

According to the errors, it is named “projucer_LiveComponentHolder.h” & Projucer even shows it to me, but I can’t find a file with that name (in fact, I can’t find any files with that prefix). And, if that weren’t enough, I scanned the repo for “ComponentViewportContent” (the class name) & cannot find that either. But, there it is…

Clearly, this is revenge on me for something; I would rather figure that out after I have solved this problem (which, if that is the cause of the problem, then I am really in trouble).

Then again, maybe I just did something stupid. That is my preference.

Ok, I downloaded the live build engine and can see now the error.
The problem was introduced 20 days ago:

I think this needs an update to projucer’s live build engine, @jules.

1 Like

Ah, yes, that looks like a job for @ed95

Yes, the error is in the live-build engine code which unfortunately means that it will have to wait until we do a point release before the version that gets downloaded by the Projucer is fixed. In the meantime, I’ve uploaded the fixed builds of the live-build engine for mac and windows to Dropbox.

If you’re on mac, you need to replace JUCECompileEngine.dylib in Projucer/Contents and also user/Library/Application Support/Projucer with the new one and if you’re on Windows you need to replace the JUCECompileEngine.dll from next to your Projucer.exe file (if it’s there) and \Users\username\AppData\Roaming\Projucer-version number.

That works on mac - did not try windows.

Thank you Ed :slight_smile:

I tried on macs and it works very well.
but not work on win10, the error is : C:\Users****\AppData\Local\Temp\com.juce.projucer\Intermediate Files\HelloWorld_tTAKTK1s_debug\projucer_LiveComponentUtils.cpp: no viable conversion from ‘Rectangle’ to ‘Rectangle’ .
I’ve replace the newest JUCECompileEngine.dll {size 42.6 MB (44,745,216 bytes) , size on disk 42.6 MB (44,748,800 bytes) }

I use JUCECompileEngine.dll (size 42.7 MB (44,851,712 bytes) ) which is downloaded by Projucer 5.2 is work quit well!!!
but the JUCECompileEngine.dll download by 5.1 cannot work, and the one in dropbox can not work too.
finally , my problem is solved! thank you for the JUCECompileEngine.dll, it make me develop quite fast and easy !

EDIT : i was actually refering to an ‘outdated’ 5.2.0 modules-folder.
after changing that to the appropiate 5.2.1 modules-folder and calling ‘clean all’
in the projucer build menu, it worked ! :slight_smile:

I’ running into the same error right now.
Unfortunately i didn’t get the solution to be honest.
What do i have to do ?

Any help greatly appreciated :slight_smile:

Btw: I’m running into it on Mac 10.12.5 with installed Xcode 8.3.2
and also on Windows 10 with Visual Studio 2017
I used the latest official release of the projucer 5.2.1 from the juce website,
and a freshly compiled version of the latest ‘develop’ version from github.

I got the same error in all constellations.