|
|
|
@@ -39,25 +39,23 @@ class FilePathPropertyComponent : public PropertyComponent, |
|
|
|
{
|
|
|
|
public:
|
|
|
|
FilePathPropertyComponent (Value valueToControl, const String& propertyName, bool isDir, bool thisOS = true,
|
|
|
|
const String& wildcardsToUse = "*", const File& relativeRoot = File(), bool multiPath = false)
|
|
|
|
const String& wildcardsToUse = "*", const File& relativeRoot = File())
|
|
|
|
: PropertyComponent (propertyName),
|
|
|
|
text (valueToControl, propertyName, 1024, false),
|
|
|
|
isDirectory (isDir), isThisOS (thisOS), supportsMultiplePaths (multiPath), wildcards (wildcardsToUse), root (relativeRoot)
|
|
|
|
isDirectory (isDir), isThisOS (thisOS), wildcards (wildcardsToUse), root (relativeRoot)
|
|
|
|
{
|
|
|
|
textValue.referTo (valueToControl);
|
|
|
|
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Displays a default value when no value is specified by the user. */
|
|
|
|
FilePathPropertyComponent (ValueWithDefault& valueToControl, const String& propertyName, bool isDir, bool thisOS = true,
|
|
|
|
const String& wildcardsToUse = "*", const File& relativeRoot = File(), bool multiPath = false)
|
|
|
|
const String& wildcardsToUse = "*", const File& relativeRoot = File())
|
|
|
|
: PropertyComponent (propertyName),
|
|
|
|
text (valueToControl, propertyName, 1024, false),
|
|
|
|
isDirectory (isDir), isThisOS (thisOS), supportsMultiplePaths (multiPath), wildcards (wildcardsToUse), root (relativeRoot)
|
|
|
|
isDirectory (isDir), isThisOS (thisOS), wildcards (wildcardsToUse), root (relativeRoot)
|
|
|
|
{
|
|
|
|
textValue = valueToControl.getPropertyAsValue();
|
|
|
|
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -89,15 +87,8 @@ public: |
|
|
|
|
|
|
|
void filesDropped (const StringArray& selectedFiles, int, int) override
|
|
|
|
{
|
|
|
|
if (supportsMultiplePaths)
|
|
|
|
{
|
|
|
|
for (auto& f : selectedFiles)
|
|
|
|
setTo (f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setTo (selectedFiles[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTo (selectedFiles[0]);
|
|
|
|
|
|
|
|
highlightForDragAndDrop = false;
|
|
|
|
repaint();
|
|
|
|
@@ -126,11 +117,6 @@ private: |
|
|
|
auto pathName = (root == File()) ? f.getFullPathName()
|
|
|
|
: f.getRelativePathFrom (root);
|
|
|
|
|
|
|
|
auto currentPath = text.getText();
|
|
|
|
|
|
|
|
if (supportsMultiplePaths && currentPath.isNotEmpty())
|
|
|
|
pathName = currentPath.trimCharactersAtEnd (" ;") + "; " + pathName;
|
|
|
|
|
|
|
|
text.setText (pathName);
|
|
|
|
updateEditorColour();
|
|
|
|
}
|
|
|
|
@@ -160,24 +146,24 @@ private: |
|
|
|
|
|
|
|
void updateEditorColour()
|
|
|
|
{
|
|
|
|
if (supportsMultiplePaths || ! isThisOS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
text.setColour (TextPropertyComponent::textColourId, findColour (widgetTextColourId));
|
|
|
|
if (isThisOS)
|
|
|
|
{
|
|
|
|
text.setColour (TextPropertyComponent::textColourId, findColour (widgetTextColourId));
|
|
|
|
|
|
|
|
auto pathToCheck = text.getText();
|
|
|
|
auto pathToCheck = text.getText();
|
|
|
|
|
|
|
|
if (pathToCheck.isNotEmpty())
|
|
|
|
{
|
|
|
|
pathToCheck.replace ("${user.home}", "~");
|
|
|
|
if (pathToCheck.isNotEmpty())
|
|
|
|
{
|
|
|
|
pathToCheck.replace ("${user.home}", "~");
|
|
|
|
|
|
|
|
#if JUCE_WINDOWS
|
|
|
|
if (pathToCheck.startsWith ("~"))
|
|
|
|
pathToCheck = pathToCheck.replace ("~", File::getSpecialLocation (File::userHomeDirectory).getFullPathName());
|
|
|
|
#endif
|
|
|
|
#if JUCE_WINDOWS
|
|
|
|
if (pathToCheck.startsWith ("~"))
|
|
|
|
pathToCheck = pathToCheck.replace ("~", File::getSpecialLocation (File::userHomeDirectory).getFullPathName());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (! root.getChildFile (pathToCheck).exists())
|
|
|
|
text.setColour (TextPropertyComponent::textColourId, Colours::red);
|
|
|
|
if (! root.getChildFile (pathToCheck).exists())
|
|
|
|
text.setColour (TextPropertyComponent::textColourId, Colours::red);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -200,7 +186,7 @@ private: |
|
|
|
TextPropertyComponent text;
|
|
|
|
TextButton browseButton { "..." };
|
|
|
|
|
|
|
|
bool isDirectory, isThisOS, supportsMultiplePaths, highlightForDragAndDrop = false;
|
|
|
|
bool isDirectory, isThisOS, highlightForDragAndDrop = false;
|
|
|
|
String wildcards;
|
|
|
|
File root;
|
|
|
|
|
|
|
|
|