mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-15 00:24:19 +00:00
module selection fixes
This commit is contained in:
parent
48d468ddb3
commit
8980ed2b9c
5 changed files with 74 additions and 55 deletions
|
|
@ -45,8 +45,8 @@ public:
|
|||
attributes = nullptr;
|
||||
uniforms = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Matrix3D<float> 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<OpenGLShaderProgram> newShader (new OpenGLShaderProgram (openGLContext));
|
||||
String statusText;
|
||||
|
||||
|
|
@ -181,8 +181,8 @@ private:
|
|||
//==============================================================================
|
||||
|
||||
// private member variables
|
||||
|
||||
struct Vertex
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
float position[3];
|
||||
float normal[3];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
void render() override
|
||||
{
|
||||
OpenGLHelpers::clear (Colours::black);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<int> 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;
|
||||
|
||||
currentPathBox.setText (currentRootName, dontSendNotification);
|
||||
if (selectJuceFolder (result))
|
||||
setModulesFolder (result);
|
||||
}
|
||||
|
||||
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> project (wizard->runWizard (*this, projectName.getText(),
|
||||
fileBrowser.getSelectedFile (0)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue