Browse Source

Added a flag to FileBrowserComponent to allow it to keep the current name when the folder changes, and used this flag in the introjucer's new project wizard.

tags/2021-05-28
jules 10 years ago
parent
commit
d3f76766db
3 changed files with 34 additions and 16 deletions
  1. +17
    -2
      extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h
  2. +4
    -2
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  3. +13
    -12
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h

+ 17
- 2
extras/Introjucer/Source/Wizards/jucer_NewProjectWizardComponent.h View File

@@ -256,7 +256,8 @@ private:
class WizardComp : public Component, class WizardComp : public Component,
private ButtonListener, private ButtonListener,
private ComboBoxListener, private ComboBoxListener,
private TextEditorListener
private TextEditorListener,
private FileBrowserListener
{ {
public: public:
WizardComp() WizardComp()
@@ -264,7 +265,9 @@ public:
projectName (TRANS("Project name")), projectName (TRANS("Project name")),
nameLabel (String::empty, TRANS("Project Name") + ":"), nameLabel (String::empty, TRANS("Project Name") + ":"),
typeLabel (String::empty, TRANS("Project Type") + ":"), typeLabel (String::empty, TRANS("Project Type") + ":"),
fileBrowser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories,
fileBrowser (FileBrowserComponent::saveMode
| FileBrowserComponent::canSelectDirectories
| FileBrowserComponent::doNotClearFileNameOnRootChange,
NewProjectWizardClasses::getLastWizardFolder(), nullptr, nullptr), NewProjectWizardClasses::getLastWizardFolder(), nullptr, nullptr),
fileOutline (String::empty, TRANS("Project Folder") + ":"), fileOutline (String::empty, TRANS("Project Folder") + ":"),
targetsOutline (String::empty, TRANS("Target Platforms") + ":"), targetsOutline (String::empty, TRANS("Target Platforms") + ":"),
@@ -303,6 +306,8 @@ public:
addChildAndSetID (&fileBrowser, "fileBrowser"); addChildAndSetID (&fileBrowser, "fileBrowser");
fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 32"); fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 32");
fileBrowser.setFilenameBoxLabel ("Folder:"); fileBrowser.setFilenameBoxLabel ("Folder:");
fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
fileBrowser.addListener (this);
addChildAndSetID (&createButton, "createButton"); addChildAndSetID (&createButton, "createButton");
createButton.setBounds ("right - 130, bottom - 34, parent.width - 30, parent.height - 30"); createButton.setBounds ("right - 130, bottom - 34, parent.width - 30, parent.height - 30");
@@ -409,6 +414,16 @@ public:
fileBrowser.setFileName (File::createLegalFileName (projectName.getText())); fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
} }
void selectionChanged() override {}
void fileClicked (const File&, const MouseEvent&) override {}
void fileDoubleClicked (const File&) override {}
void browserRootChanged (const File&) override
{
fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
}
ComboBox projectType; ComboBox projectType;
PlatformTargetsComp platformTargets; PlatformTargetsComp platformTargets;


+ 4
- 2
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -387,7 +387,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f)
{ {
setRoot (f); setRoot (f);
if ((flags & canSelectDirectories) != 0)
if ((flags & canSelectDirectories) != 0 && (flags & doNotClearFileNameOnRootChange) == 0)
filenameBox.setText (String::empty); filenameBox.setText (String::empty);
} }
else else
@@ -432,7 +432,9 @@ void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&)
{ {
setRoot (f); setRoot (f);
chosenFiles.clear(); chosenFiles.clear();
filenameBox.setText (String::empty);
if ((flags & doNotClearFileNameOnRootChange) == 0)
filenameBox.setText (String());
} }
else else
{ {


+ 13
- 12
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h View File

@@ -51,18 +51,19 @@ public:
*/ */
enum FileChooserFlags enum FileChooserFlags
{ {
openMode = 1, /**< specifies that the component should allow the user to
choose an existing file with the intention of opening it. */
saveMode = 2, /**< specifies that the component should allow the user to specify
the name of a file that will be used to save something. */
canSelectFiles = 4, /**< specifies that the user can select files (can be used in
conjunction with canSelectDirectories). */
canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in
conjuction with canSelectFiles). */
canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */
useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */
filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */
warnAboutOverwriting = 128 /**< specifies that the dialog should warn about overwriting existing files (if possible). */
openMode = 1, /**< specifies that the component should allow the user to
choose an existing file with the intention of opening it. */
saveMode = 2, /**< specifies that the component should allow the user to specify
the name of a file that will be used to save something. */
canSelectFiles = 4, /**< specifies that the user can select files (can be used in
conjunction with canSelectDirectories). */
canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in
conjuction with canSelectFiles). */
canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */
useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */
filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */
warnAboutOverwriting = 128, /**< specifies that the dialog should warn about overwriting existing files (if possible). */
doNotClearFileNameOnRootChange = 256 /**< specifies that the file name should not be cleared upon root change. */
}; };
//============================================================================== //==============================================================================


Loading…
Cancel
Save