Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove VS warning #28

Open
damiensellier opened this issue Jun 29, 2024 · 2 comments
Open

Remove VS warning #28

damiensellier opened this issue Jun 29, 2024 · 2 comments

Comments

@damiensellier
Copy link
Owner

1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrApplicationWindow\CtrlrDocumentPanel.cpp(19,56):

warning C4305: 'argument': truncation from 'double' to 'float'
setBackgroundColour((Colours::lightgrey).darker(0.2));

becomes:
setBackgroundColour((Colours::lightgrey).darker(0.2f));

1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(357,35): warning C4458: declaration of 'canvasHeight' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(82,16): message : see declaration of 'CtrlrPanelEditor::canvasHeight' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(358,34): warning C4458: declaration of 'canvasWidth' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(83,16): message : see declaration of 'CtrlrPanelEditor::canvasWidth' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(359,40): warning C4458: declaration of 'canvasAspectRatio' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(84,16): message : see declaration of 'CtrlrPanelEditor::canvasAspectRatio' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)

            double canvasHeight = getCanvas()->getHeight();
            double canvasWidth = getCanvas()->getWidth();
            double canvasAspectRatio = double(canvasWidth) / double(canvasHeight);

becomes:

            canvasHeight = getCanvas()->getHeight();
            canvasWidth = getCanvas()->getWidth();
            canvasAspectRatio = canvasWidth / canvasHeight;

because they are already declared as double in CtrlrPanelEditor.h

!!! To get confirmation from Damien if those are not local variables rather than class variables (then do not change but use other variable names)

1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.cpp(92,20): warning C4458: declaration of 'constrainer' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.h(169,30): message : see declaration of 'CtrlrEditor::constrainer' (compiling source file ....\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.cpp)

            `if (auto* constrainer = getConstrainer())`

becomes

           ` if (constrainer = getConstrainer())`

because they are already declared in CtrlrEditor.h

!!! To get confirmation from Damien if those are not local variables rather than class variables (then do not change but use other variable names)

Why auto*?

@damiensellier
Copy link
Owner Author

damiensellier commented Jun 29, 2024

FIXED: CtrlrDocumentPanel.cpp

CtrlrDocumentPanel::CtrlrDocumentPanel (CtrlrManager &_owner)
    : ctrlrEditor(0), owner(_owner)
{
	/* Full screen mode is not completely implemented in JUCE 6
	   we get some assertions when adding the first Tab to an invisble
	   panel, as it wants to grep the focus, which is not possible at this stage.
	*/
	// useFullscreenWhenOneDocument (true);
    setSize (600, 400);
    setBackgroundColour((Colours::lightgrey).darker(0.2f)); // Added v.6.30. Updated v5.6.31 for (0.2f). Sets background colour behind main window by default on grey to please everyone :)
}

FIXED: CtrlrPanelEditor.cpp

 else if (property == Ids::uiPanelCanvasRectangle)
        {
            getCanvas()->setBounds(VAR2RECT(getProperty(property))); // update canvas size if values in the property field are changed
            canvasHeight = getCanvas()->getHeight(); // Updated v5.6.31 by GoodWeather. Removed type double(canvasHeight)
            canvasWidth = getCanvas()->getWidth(); // Updated v5.6.31 by GoodWeather. Removed type double(canvasWidth)
            canvasAspectRatio = canvasWidth / canvasHeight; // Updated v5.6.31 by GoodWeather. Removed type double(canvasAspectRatio) = double(canvasWidth) / double(canvasHeight)
            setProperty(Ids::uiViewPortFixedAspectRatio, canvasAspectRatio); // update canvas aspect ratio if canvas is resized
            resized();
        }

CHECK :
DECLARING TYPE IS MANDATORY
auto* var = getFunction() // auto* stresses better the intent that var is a pointer.
Both should work though it can be
auto var = getFunction()

if (auto constrainer = getConstrainer())

Needs to be checked with VS if the warning goes away with that mod.

if (!JUCEApplication::isStandaloneApp() && owner.getInstanceMode() == InstanceSingleRestriced)
            {
                setResizable(vpResizable, true);
                
                if (auto constrainer = getConstrainer()) // According to GoodWeather, it *auto returns type warning in VS
                {
                    if (vpEnableFixedAspectRatio == true)
                    {
                        constrainer->setFixedAspectRatio(vpFixedAspectRatio);
                        
                        if (vpEnableResizableLimits == true)
                        {
                            if (vpMinWidth != 0 && vpMaxWidth != 0)
                            {
                                setResizeLimits(vpMinWidth, round(vpMinWidth/vpFixedAspectRatio), vpMaxWidth, round(vpMaxWidth/vpFixedAspectRatio));
                            }
                            else if (vpMinWidth != 0 && vpMinHeight != 0 && vpMaxWidth != 0 && vpMaxHeight != 0)
                            {
                                setResizeLimits(vpMinWidth, vpMinHeight, vpMaxWidth, vpMaxHeight);
                            }
                        }
                        else
                        {
                            constrainer->setMinimumSize(editorRect.getWidth(), editorRect.getHeight());
                        }
                    }
                    else if (vpEnableResizableLimits == true && vpMinWidth != 0 && vpMinHeight != 0 && vpMaxWidth != 0 && vpMaxHeight != 0)
                    {
                        setResizeLimits(vpMinWidth, vpMinHeight, vpMaxWidth, vpMaxHeight);
                    }
                }
            }

@dobo365
Copy link
Collaborator

dobo365 commented Jul 3, 2024

Some other ones to fix. The issue comes that there is one declaration in the header file (at class level) then another one in the .cpp file (my interpretation, I'm not a C++ specialist).

CtrlrPanelEditor
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(408,35): warning C4458: declaration of 'canvasHeight' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(109,16): message : see declaration of 'CtrlrPanelEditor::canvasHeight' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(409,34): warning C4458: declaration of 'canvasWidth' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(110,16): message : see declaration of 'CtrlrPanelEditor::canvasWidth' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp(410,40): warning C4458: declaration of 'canvasAspectRatio' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.h(111,16): message : see declaration of 'CtrlrPanelEditor::canvasAspectRatio' (compiling source file ....\Source\UIComponents\CtrlrPanel\CtrlrPanelEditor.cpp)

CtrlrEditor:
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.cpp(92,20): warning C4458: declaration of 'constrainer' hides class member
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.h(169,30): message : see declaration of 'CtrlrEditor::constrainer' (compiling source file ....\Source\UIComponents\CtrlrApplicationWindow\CtrlrEditor.cpp)

CtrlrStandaloneWindow.cpp
1>G:\2. Source code for build\CtrlrX 5.6.30.1\Source\Core\StandaloneWrapper\CtrlrStandaloneWindow.cpp(118,12): warning C4458: declaration of 'constrainer' hides class member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants