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.

135 lines
4.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. const char* getPreferredLineFeed();
  22. String joinLinesIntoSourceFile (StringArray& lines);
  23. String replaceLineFeeds (const String& content, const String& lineFeed);
  24. String getLineFeedForFile (const String& fileContent);
  25. var parseJUCEHeaderMetadata (const File&);
  26. String trimCommentCharsFromStartOfLine (const String& line);
  27. String hexString8Digits (int value);
  28. String createAlphaNumericUID();
  29. String createGUID (const String& seed); // Turns a seed into a windows GUID
  30. String escapeSpaces (const String& text); // replaces spaces with blackslash-space
  31. String addQuotesIfContainsSpaces (const String& text);
  32. StringPairArray parsePreprocessorDefs (const String& defs);
  33. StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const StringPairArray& overridingDefs);
  34. String createGCCPreprocessorFlags (const StringPairArray& defs);
  35. String replacePreprocessorDefs (const StringPairArray& definitions, String sourceString);
  36. StringArray getCleanedStringArray (StringArray);
  37. StringArray getSearchPathsFromString (const String& searchPath);
  38. StringArray getCommaOrWhitespaceSeparatedItems (const String&);
  39. void setValueIfVoid (Value value, const var& defaultValue);
  40. void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& value);
  41. void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, bool value);
  42. void addPlistDictionaryKeyInt (XmlElement* xml, const String& key, int value);
  43. bool fileNeedsCppSyntaxHighlighting (const File& file);
  44. StringArray getJUCEModules() noexcept;
  45. bool isJUCEModule (const String& moduleID) noexcept;
  46. StringArray getModulesRequiredForConsole() noexcept;
  47. StringArray getModulesRequiredForComponent() noexcept;
  48. StringArray getModulesRequiredForAudioProcessor() noexcept;
  49. bool isPIPFile (const File&) noexcept;
  50. bool isValidJUCEExamplesDirectory (const File&) noexcept;
  51. //==============================================================================
  52. int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
  53. void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scrollY = true);
  54. //==============================================================================
  55. struct PropertyListBuilder
  56. {
  57. void add (PropertyComponent* propertyComp)
  58. {
  59. components.add (propertyComp);
  60. }
  61. void add (PropertyComponent* propertyComp, const String& tooltip)
  62. {
  63. propertyComp->setTooltip (tooltip);
  64. add (propertyComp);
  65. }
  66. void addSearchPathProperty (const Value& value, const String& name, const String& mainHelpText)
  67. {
  68. add (new TextPropertyComponent (value, name, 16384, true),
  69. mainHelpText + " Use semi-colons or new-lines to separate multiple paths.");
  70. }
  71. void addSearchPathProperty (ValueWithDefault& value, const String& name, const String& mainHelpText)
  72. {
  73. add (new TextPropertyComponent (value, name, 16384, true),
  74. mainHelpText + " Use semi-colons or new-lines to separate multiple paths.");
  75. }
  76. void setPreferredHeight (int height)
  77. {
  78. for (int j = components.size(); --j >= 0;)
  79. components.getUnchecked(j)->setPreferredHeight (height);
  80. }
  81. Array<PropertyComponent*> components;
  82. };
  83. //==============================================================================
  84. // A ValueSource which takes an input source, and forwards any changes in it.
  85. // This class is a handy way to create sources which re-map a value.
  86. class ValueSourceFilter : public Value::ValueSource,
  87. public Value::Listener
  88. {
  89. public:
  90. ValueSourceFilter (const Value& source) : sourceValue (source)
  91. {
  92. sourceValue.addListener (this);
  93. }
  94. void valueChanged (Value&) override { sendChangeMessage (true); }
  95. protected:
  96. Value sourceValue;
  97. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSourceFilter)
  98. };