mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-27 02:20:05 +00:00
Projucer: Update to ValueTreePropertyWithDefault class
This commit is contained in:
parent
2b6dc9f7d2
commit
fdcdda3463
17 changed files with 166 additions and 142 deletions
|
|
@ -118,8 +118,8 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class ModuleSettingsPanel : public Component,
|
||||
private Value::Listener,
|
||||
private Timer
|
||||
private ValueTree::Listener,
|
||||
private Value::Listener
|
||||
{
|
||||
public:
|
||||
ModuleSettingsPanel (Project& p, const String& modID, TreeView* tree)
|
||||
|
|
@ -129,10 +129,21 @@ private:
|
|||
modulesTree (tree),
|
||||
moduleID (modID)
|
||||
{
|
||||
auto& appSettings = getAppSettings();
|
||||
appSettings.addProjectDefaultsListener (*this);
|
||||
appSettings.addFallbackPathsListener (*this);
|
||||
|
||||
addAndMakeVisible (group);
|
||||
refresh();
|
||||
}
|
||||
|
||||
~ModuleSettingsPanel() override
|
||||
{
|
||||
auto& appSettings = getAppSettings();
|
||||
appSettings.removeProjectDefaultsListener (*this);
|
||||
appSettings.removeFallbackPathsListener (*this);
|
||||
}
|
||||
|
||||
void refresh()
|
||||
{
|
||||
auto& modules = project.getEnabledModules();
|
||||
|
|
@ -150,21 +161,23 @@ private:
|
|||
props.add (new CppStandardWarningComponent());
|
||||
|
||||
group.clearProperties();
|
||||
exporterModulePathDefaultValues.clear();
|
||||
exporterModulePathValues.clear();
|
||||
globalPathValues.clear();
|
||||
|
||||
for (Project::ExporterIterator exporter (project); exporter.next();)
|
||||
{
|
||||
if (exporter->isCLion())
|
||||
continue;
|
||||
|
||||
exporterModulePathDefaultValues.add (exporter->getPathForModuleValue (moduleID));
|
||||
auto& defaultValue = exporterModulePathDefaultValues.getReference (exporterModulePathDefaultValues.size() - 1);
|
||||
auto modulePathValue = exporter->getPathForModuleValue (moduleID);
|
||||
const auto fallbackPath = getAppSettings().getStoredPath (isJUCEModule (moduleID) ? Ids::defaultJuceModulePath
|
||||
: Ids::defaultUserModulePath,
|
||||
exporter->getTargetOSForExporter()).get().toString();
|
||||
|
||||
exporterModulePathValues.add (defaultValue.getPropertyAsValue());
|
||||
modulePathValue.setDefault (fallbackPath);
|
||||
exporterModulePathValues.add (modulePathValue.getPropertyAsValue());
|
||||
exporterModulePathValues.getReference (exporterModulePathValues.size() - 1).addListener (this);
|
||||
|
||||
auto pathComponent = std::make_unique<FilePathPropertyComponent> (defaultValue,
|
||||
auto pathComponent = std::make_unique<FilePathPropertyComponent> (modulePathValue,
|
||||
"Path for " + exporter->getUniqueName().quoted(),
|
||||
true,
|
||||
exporter->getTargetOSForExporter() == TargetOS::getThisOS(),
|
||||
|
|
@ -179,21 +192,9 @@ private:
|
|||
"This can be an absolute path, or relative to the jucer project folder, but it "
|
||||
"must be valid on the filesystem of the target machine that will be performing this build. If this "
|
||||
"is empty then the global path will be used.");
|
||||
|
||||
globalPathValues.add (getAppSettings().getStoredPath (isJUCEModule (moduleID) ? Ids::defaultJuceModulePath : Ids::defaultUserModulePath,
|
||||
exporter->getTargetOSForExporter()).getPropertyAsValue());
|
||||
}
|
||||
|
||||
for (int i = 0; i < exporterModulePathDefaultValues.size(); ++i)
|
||||
{
|
||||
exporterModulePathDefaultValues.getReference (i).onDefaultChange = [this] { startTimer (50); };
|
||||
|
||||
exporterModulePathValues.getReference (i).addListener (this);
|
||||
globalPathValues.getReference (i).addListener (this);
|
||||
}
|
||||
|
||||
useGlobalPathValue.removeListener (this);
|
||||
useGlobalPathValue.referTo (modules.shouldUseGlobalPathValue (moduleID));
|
||||
useGlobalPathValue = modules.shouldUseGlobalPathValue (moduleID);
|
||||
useGlobalPathValue.addListener (this);
|
||||
|
||||
auto menuItemString = (TargetOS::getThisOS() == TargetOS::osx ? "\"Projucer->Global Paths...\""
|
||||
|
|
@ -242,9 +243,15 @@ private:
|
|||
String getModuleID() const noexcept { return moduleID; }
|
||||
|
||||
private:
|
||||
void valueTreePropertyChanged (ValueTree&, const Identifier& property) override
|
||||
{
|
||||
if (property == Ids::defaultJuceModulePath || property == Ids::defaultUserModulePath)
|
||||
refresh();
|
||||
}
|
||||
|
||||
void valueChanged (Value& v) override
|
||||
{
|
||||
auto isExporterPathValue = [&]
|
||||
auto isExporterPathValue = [this, &v]
|
||||
{
|
||||
for (auto& exporterValue : exporterModulePathValues)
|
||||
if (exporterValue.refersToSameSourceAs (v))
|
||||
|
|
@ -256,18 +263,11 @@ private:
|
|||
if (isExporterPathValue)
|
||||
project.rescanExporterPathModules();
|
||||
|
||||
startTimer (50);
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
stopTimer();
|
||||
refresh();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Array<ValueWithDefault> exporterModulePathDefaultValues;
|
||||
Array<Value> exporterModulePathValues, globalPathValues;
|
||||
Array<Value> exporterModulePathValues;
|
||||
Value useGlobalPathValue;
|
||||
|
||||
OwnedArray<Project::ConfigFlag> configFlags;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue