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.

139 lines
4.9KB

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