From 6ef34798cc4b3605a4785613e55953349b591ab4 Mon Sep 17 00:00:00 2001 From: Felix Faire Date: Wed, 12 Nov 2014 13:22:09 +0000 Subject: [PATCH] Modules folder combo box, Introducer Wizard --- .../Introjucer/JuceLibraryCode/BinaryData.cpp | 11 +- .../Introjucer/JuceLibraryCode/BinaryData.h | 2 +- .../Source/Wizards/jucer_NewProjectWizard.h | 24 ---- .../Wizards/jucer_NewProjectWizardComponent.h | 116 +++++++++++++++++- 4 files changed, 119 insertions(+), 34 deletions(-) diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp index a76a85e125..a45c587fa1 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp @@ -1361,15 +1361,14 @@ static const unsigned char temp_binary_data_20[] = "\r\n" " void render() override\r\n" " {\r\n" +" OpenGLHelpers::clear (Colours::black);\r\n" +" \r\n" " }\r\n" "\r\n" " void paint (Graphics& g) override\r\n" " {\r\n" -" // (Our component is opaque, so we must completely fill the background with a solid colour)\r\n" -" g.fillAll (Colours::black);\r\n" -"\r\n" -"\r\n" -" // You can add your drawing code here!\r\n" +" // You can add your component specific drawing code here!\r\n" +" // This will draw over the top of the openGL background.\r\n" " }\r\n" "\r\n" " void resized() override\r\n" @@ -3658,7 +3657,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0x02a2a077: numBytes = 262; return jucer_NewCppFileTemplate_cpp; case 0x0842c43c: numBytes = 308; return jucer_NewCppFileTemplate_h; case 0x36e634a1: numBytes = 1626; return jucer_NewInlineComponentTemplate_h; - case 0x7fbac252: numBytes = 1834; return jucer_OpenGLComponentTemplate_cpp; + case 0x7fbac252: numBytes = 1835; return jucer_OpenGLComponentTemplate_cpp; case 0x44be9398: numBytes = 2922; return AudioPluginXCodeScript_txt; case 0x4a0cfd09: numBytes = 151; return background_tile_png; case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml; diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.h b/extras/Introjucer/JuceLibraryCode/BinaryData.h index 66bafef40f..a522bb6473 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.h +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.h @@ -70,7 +70,7 @@ namespace BinaryData const int jucer_NewInlineComponentTemplate_hSize = 1626; extern const char* jucer_OpenGLComponentTemplate_cpp; - const int jucer_OpenGLComponentTemplate_cppSize = 1834; + const int jucer_OpenGLComponentTemplate_cppSize = 1835; extern const char* AudioPluginXCodeScript_txt; const int AudioPluginXCodeScript_txtSize = 2922; diff --git a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h index 97e4614f13..d83efa4910 100644 --- a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h +++ b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizard.h @@ -208,30 +208,6 @@ struct NewProjectWizard return project.release(); } - bool selectJuceFolder() - { - for (;;) - { - FileChooser fc ("Select your JUCE modules folder...", - findDefaultModulesFolder(), - "*"); - - if (! fc.browseForDirectory()) - return false; - - if (isJuceModulesFolder (fc.getResult())) - { - modulesFolder = fc.getResult(); - return true; - } - - AlertWindow::showMessageBox (AlertWindow::WarningIcon, - "Not a valid JUCE modules folder!", - "Please select the folder containing your juce_* modules!\n\n" - "This is required so that the new project can be given some essential core modules."); - } - } - //============================================================================== File getSourceFilesFolder() const { diff --git a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h index 49a93874b2..9f4f7a5d60 100644 --- a/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h +++ b/extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h @@ -25,6 +25,112 @@ #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") + ":") + { + + if (initialFileOrDirectory == File::nonexistent) + { + currentPathBox.setText ("couldnt open file", dontSendNotification); + setRoot(findDefaultModulesFolder()); + } + else if (initialFileOrDirectory.isDirectory()) + { + setRoot(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() + { + for (;;) + { + FileChooser fc ("Select your JUCE modules folder...", + findDefaultModulesFolder(), + "*"); + + if (! fc.browseForDirectory()) + return false; + + if (isJuceModulesFolder (fc.getResult())) + { + modulesFolder = fc.getResult(); + setRoot (modulesFolder); + return true; + } + + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + "Not a valid JUCE modules folder!", + "Please select the folder containing your juce_* modules!\n\n" + "This is required so that the new project can be given some essential core modules."); + } + } + + void setRoot (const File& newRootDirectory) + { + if (currentRoot != newRootDirectory) + { + currentRoot = newRootDirectory; + + String currentRootName (currentRoot.getFullPathName()); + if (currentRootName.isEmpty()) + currentRootName = File::separatorString; + + currentPathBox.setText (currentRootName, dontSendNotification); + } + } + + void buttonClicked (Button*) override + { + selectJuceFolder(); + } + + void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override + { + } + +private: + ComboBox currentPathBox; + File currentRoot, modulesFolder; + TextButton openFolderButton; + Label modulesLabel; +}; + /** The target platforms chooser for the chosen template. */ class PlatformTargetsComp : public Component, @@ -170,7 +276,8 @@ public: fileOutline (String::empty, TRANS("Project Folder") + ":"), targetsOutline (String::empty, TRANS("Target Platforms") + ":"), createButton (TRANS("Create") + "..."), - cancelButton (TRANS("Cancel")) + cancelButton (TRANS("Cancel")), + modulesPathBox (findDefaultModulesFolder()) { setOpaque (false); @@ -212,6 +319,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(); @@ -270,8 +381,6 @@ public: return; } - if (! wizard->selectJuceFolder()) - return; ScopedPointer project (wizard->runWizard (*this, projectName.getText(), fileBrowser.getSelectedFile (0))); @@ -313,6 +422,7 @@ private: GroupComponent targetsOutline; TextButton createButton, cancelButton; OwnedArray customItems; + ModulesFolderPathBox modulesPathBox; NewProjectWizardClasses::NewProjectWizard* createWizard() {