The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCER_STOREDSETTINGS_H_INCLUDED
  18. #define JUCER_STOREDSETTINGS_H_INCLUDED
  19. #include <map>
  20. #include "../Application/jucer_AppearanceSettings.h"
  21. //==============================================================================
  22. class StoredSettings : public ValueTree::Listener
  23. {
  24. public:
  25. StoredSettings();
  26. ~StoredSettings();
  27. PropertiesFile& getGlobalProperties();
  28. PropertiesFile& getProjectProperties (const String& projectUID);
  29. void flush();
  30. void reload();
  31. //==============================================================================
  32. RecentlyOpenedFilesList recentFiles;
  33. Array<File> getLastProjects();
  34. void setLastProjects (const Array<File>& files);
  35. //==============================================================================
  36. Array<Colour> swatchColours;
  37. struct ColourSelectorWithSwatches : public ColourSelector
  38. {
  39. ColourSelectorWithSwatches() {}
  40. int getNumSwatches() const override;
  41. Colour getSwatchColour (int index) const override;
  42. void setSwatchColour (int index, const Colour& newColour) const override;
  43. };
  44. //==============================================================================
  45. AppearanceSettings appearance;
  46. StringArray monospacedFontNames;
  47. //==============================================================================
  48. Value getGlobalPath (const Identifier& key, DependencyPathOS);
  49. String getFallbackPath (const Identifier& key, DependencyPathOS);
  50. bool isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path);
  51. private:
  52. OwnedArray<PropertiesFile> propertyFiles;
  53. ValueTree projectDefaults;
  54. void changed()
  55. {
  56. ScopedPointer<XmlElement> data (projectDefaults.createXml());
  57. propertyFiles.getUnchecked (0)->setValue ("PROJECT_DEFAULT_SETTINGS", data);
  58. }
  59. void updateGlobalPreferences();
  60. void updateAppearanceSettings();
  61. void updateRecentFiles();
  62. void updateKeyMappings();
  63. void loadSwatchColours();
  64. void saveSwatchColours();
  65. //==============================================================================
  66. void valueTreePropertyChanged (ValueTree&, const Identifier&) override { changed(); }
  67. void valueTreeChildAdded (ValueTree&, ValueTree&) override { changed(); }
  68. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override { changed(); }
  69. void valueTreeChildOrderChanged (ValueTree&, int, int) override { changed(); }
  70. void valueTreeParentChanged (ValueTree&) override { changed(); }
  71. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StoredSettings)
  72. };
  73. StoredSettings& getAppSettings();
  74. PropertiesFile& getGlobalProperties();
  75. #endif // JUCER_STOREDSETTINGS_H_INCLUDED