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.

102 lines
3.5KB

  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. void valueTreePropertyChanged (ValueTree&, const Identifier&) override { changed(); }
  33. void valueTreeChildAdded (ValueTree&, ValueTree&) override { changed(); }
  34. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override { changed(); }
  35. void valueTreeChildOrderChanged (ValueTree&, int, int) override { changed(); }
  36. void valueTreeParentChanged (ValueTree&) override { changed(); }
  37. //==============================================================================
  38. RecentlyOpenedFilesList recentFiles;
  39. Array<File> getLastProjects();
  40. void setLastProjects (const Array<File>& files);
  41. //==============================================================================
  42. Array<Colour> swatchColours;
  43. struct ColourSelectorWithSwatches : public ColourSelector
  44. {
  45. ColourSelectorWithSwatches() {}
  46. int getNumSwatches() const override;
  47. Colour getSwatchColour (int index) const override;
  48. void setSwatchColour (int index, const Colour& newColour) const override;
  49. };
  50. //==============================================================================
  51. AppearanceSettings appearance;
  52. StringArray monospacedFontNames;
  53. ValueTree projectDefaults;
  54. std::map<String, Value> pathValues;
  55. private:
  56. OwnedArray<PropertiesFile> propertyFiles;
  57. void changed()
  58. {
  59. ScopedPointer<XmlElement> data (projectDefaults.createXml());
  60. propertyFiles.getUnchecked (0)->setValue ("PROJECT_DEFAULT_SETTINGS", data);
  61. }
  62. void updateGlobalPreferences();
  63. void updateAppearanceSettings();
  64. void updateRecentFiles();
  65. void updateKeyMappings();
  66. void loadSwatchColours();
  67. void saveSwatchColours();
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StoredSettings)
  69. };
  70. StoredSettings& getAppSettings();
  71. PropertiesFile& getGlobalProperties();
  72. #endif // JUCER_STOREDSETTINGS_H_INCLUDED