diff --git a/examples/OpenGLAppExample/Source/MainComponent.cpp b/examples/OpenGLAppExample/Source/MainComponent.cpp index 78ce8f6e90..e563993b4b 100644 --- a/examples/OpenGLAppExample/Source/MainComponent.cpp +++ b/examples/OpenGLAppExample/Source/MainComponent.cpp @@ -45,8 +45,8 @@ public: attributes = nullptr; uniforms = nullptr; } - - + + Matrix3D getProjectionMatrix() const { float w = 1.0f / (0.5 + 0.1f); @@ -64,7 +64,7 @@ public: void render() override { - + jassert (OpenGLHelpers::isContextActive()); const float desktopScale = (float) openGLContext.getRenderingScale(); @@ -97,7 +97,7 @@ public: { // You can add your component specific drawing code here! // This will draw over the top of the openGL background. - + g.setColour(Colours::white); g.setFont (20); g.drawText ("OpenGL Example", 25, 20, 300, 30, Justification::left); @@ -110,9 +110,9 @@ public: // This is called when the MainContentComponent is resized. // If you add any child components, this is where you should // update their positions. - + } - + void setShaders() { vertexShader = { @@ -147,9 +147,9 @@ public: " vec4 colour = vec4(0.95, 0.57, 0.03, 0.7);\n" " gl_FragColor = colour;\n" "}\n" }; - - - + + + ScopedPointer newShader (new OpenGLShaderProgram (openGLContext)); String statusText; @@ -181,8 +181,8 @@ private: //============================================================================== // private member variables - -struct Vertex + + struct Vertex { float position[3]; float normal[3]; diff --git a/extras/Introjucer/Source/Application/jucer_MainWindow.cpp b/extras/Introjucer/Source/Application/jucer_MainWindow.cpp index eb0ab70adf..f2085c9c3e 100644 --- a/extras/Introjucer/Source/Application/jucer_MainWindow.cpp +++ b/extras/Introjucer/Source/Application/jucer_MainWindow.cpp @@ -562,5 +562,20 @@ File findDefaultModulesFolder (bool mustContainJuceCoreModule) if (mustContainJuceCoreModule) return findDefaultModulesFolder (false); + File f (File::getSpecialLocation (File::currentApplicationFile)); + + for (;;) + { + File parent (f.getParentDirectory()); + + if (parent == f || ! parent.isDirectory()) + break; + + if (isJuceFolder (parent)) + return parent.getChildFile ("modules"); + + f = parent; + } + return File::nonexistent; } diff --git a/extras/Introjucer/Source/BinaryData/jucer_OpenGLComponentTemplate.cpp b/extras/Introjucer/Source/BinaryData/jucer_OpenGLComponentTemplate.cpp index 502221803a..387639acc8 100644 --- a/extras/Introjucer/Source/BinaryData/jucer_OpenGLComponentTemplate.cpp +++ b/extras/Introjucer/Source/BinaryData/jucer_OpenGLComponentTemplate.cpp @@ -41,7 +41,7 @@ public: void render() override { OpenGLHelpers::clear (Colours::black); - + } void paint (Graphics& g) override diff --git a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h index 6e034d6df9..9d42a7ad6a 100644 --- a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h +++ b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h @@ -121,6 +121,11 @@ struct NewProjectWizard WizardComp* ownerWizardComp; StringArray failedFiles; + bool selectJuceFolder() + { + return ModulesFolderPathBox::selectJuceFolder (modulesFolder); + } + //============================================================================== Project* runWizard (WizardComp& wc, const String& projectName, @@ -138,8 +143,9 @@ struct NewProjectWizard else if (FileHelpers::containsAnyNonHiddenFiles (targetFolder)) { if (! AlertWindow::showOkCancelBox (AlertWindow::InfoIcon, - TRANS("New Juce Project"), - TRANS("The folder you chose isn't empty - are you sure you want to create the project there?") + TRANS("New JUCE Project"), + TRANS("You chose the folder:\n\nXFLDRX\n\n").replace ("XFLDRX", targetFolder.getFullPathName()) + + TRANS("This folder isn't empty - are you sure you want to create the project there?") + "\n\n" + TRANS("Any existing files with the same names may be overwritten by the new files."))) return nullptr; diff --git a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h index d4f104fa1e..e9edc2c3a2 100644 --- a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h +++ b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h @@ -25,58 +25,47 @@ #ifndef NEWPROJECTWIZARDCOMPONENTS_H_INCLUDED #define NEWPROJECTWIZARDCOMPONENTS_H_INCLUDED + class ModulesFolderPathBox : public Component, private ButtonListener, private ComboBoxListener { public: - - ModulesFolderPathBox(const File& initialFileOrDirectory) - : currentPathBox ("currentPathBox"), - openFolderButton (TRANS("...")), - modulesLabel (String::empty, TRANS("Modules Folder") + ":") + ModulesFolderPathBox (File initialFileOrDirectory) + : currentPathBox ("currentPathBox"), + openFolderButton (TRANS("...")), + modulesLabel (String::empty, TRANS("Modules Folder") + ":") { - if (initialFileOrDirectory == File::nonexistent) - { - currentPathBox.setText ("couldnt open file", dontSendNotification); - setRoot(findDefaultModulesFolder()); - } - else if (initialFileOrDirectory.isDirectory()) - { - setRoot(initialFileOrDirectory); - } + initialFileOrDirectory = findDefaultModulesFolder(); + + setModulesFolder (initialFileOrDirectory); addAndMakeVisible (currentPathBox); currentPathBox.setEditableText (true); currentPathBox.addListener (this); - + addAndMakeVisible (openFolderButton); openFolderButton.addListener (this); openFolderButton.setTooltip (TRANS ("Select JUCE modules folder")); - + addAndMakeVisible (modulesLabel); modulesLabel.attachToComponent (¤tPathBox, true); - - } - - ~ModulesFolderPathBox() - { } void resized() override { Rectangle bounds = getLocalBounds(); - + modulesLabel.setBounds (bounds.removeFromLeft (110)); - + openFolderButton.setBounds (bounds.removeFromRight (40)); bounds.removeFromRight (5); currentPathBox.setBounds (bounds); } - bool selectJuceFolder() + static bool selectJuceFolder (File& result) { for (;;) { @@ -89,8 +78,7 @@ public: if (isJuceModulesFolder (fc.getResult())) { - modulesFolder = fc.getResult(); - setRoot (modulesFolder); + result = fc.getResult(); return true; } @@ -101,32 +89,37 @@ public: } } - void setRoot (const File& newRootDirectory) + void selectJuceFolder() { - if (currentRoot != newRootDirectory) - { - currentRoot = newRootDirectory; - - String currentRootName (currentRoot.getFullPathName()); - if (currentRootName.isEmpty()) - currentRootName = File::separatorString; + File result; + + if (selectJuceFolder (result)) + setModulesFolder (result); + } - currentPathBox.setText (currentRootName, dontSendNotification); + void setModulesFolder (const File& newFolder) + { + if (modulesFolder != newFolder) + { + modulesFolder = newFolder; + currentPathBox.setText (modulesFolder.getFullPathName(), dontSendNotification); } } - + void buttonClicked (Button*) override { selectJuceFolder(); } - void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override + void comboBoxChanged (ComboBox*) override { + setModulesFolder (File::getCurrentWorkingDirectory().getChildFile (currentPathBox.getText())); } - + + File modulesFolder; + private: ComboBox currentPathBox; - File currentRoot, modulesFolder; TextButton openFolderButton; Label modulesLabel; }; @@ -319,10 +312,10 @@ public: cancelButton.addShortcut (KeyPress (KeyPress::escapeKey)); cancelButton.setBounds ("right - 130, createButton.top, createButton.left - 10, createButton.bottom"); cancelButton.addListener (this); - + addChildAndSetID (&modulesPathBox, "modulesPathBox"); modulesPathBox.setBounds ("targetsOutline.left, targetsOutline.top - 45, targetsOutline.right, targetsOutline.top - 20"); - + updateCustomItems(); updateCreateButton(); @@ -381,6 +374,11 @@ public: return; } + wizard->modulesFolder = modulesPathBox.modulesFolder; + + if (! isJuceModulesFolder (wizard->modulesFolder)) + if (! wizard->selectJuceFolder()) + return; ScopedPointer project (wizard->runWizard (*this, projectName.getText(), fileBrowser.getSelectedFile (0)));