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.

132 lines
4.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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 addQuotesIfContainsSpaces (const String& text);
  30. StringPairArray parsePreprocessorDefs (const String& defs);
  31. StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const StringPairArray& overridingDefs);
  32. String createGCCPreprocessorFlags (const StringPairArray& defs);
  33. StringArray getCleanedStringArray (StringArray);
  34. StringArray getSearchPathsFromString (const String& searchPath);
  35. StringArray getCommaOrWhitespaceSeparatedItems (const String&);
  36. void setValueIfVoid (Value value, const var& defaultValue);
  37. bool fileNeedsCppSyntaxHighlighting (const File& file);
  38. StringArray getJUCEModules() noexcept;
  39. bool isJUCEModule (const String& moduleID) noexcept;
  40. StringArray getModulesRequiredForConsole() noexcept;
  41. StringArray getModulesRequiredForComponent() noexcept;
  42. StringArray getModulesRequiredForAudioProcessor() noexcept;
  43. bool isPIPFile (const File&) noexcept;
  44. int findBestLineToScrollToForClass (StringArray, const String&, bool isPlugin = false);
  45. bool isValidJUCEExamplesDirectory (const File&) noexcept;
  46. bool isJUCEModulesFolder (const File&);
  47. bool isJUCEFolder (const File&);
  48. //==============================================================================
  49. int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
  50. void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scrollY = true);
  51. //==============================================================================
  52. struct PropertyListBuilder
  53. {
  54. void add (PropertyComponent* propertyComp)
  55. {
  56. components.add (propertyComp);
  57. }
  58. void add (PropertyComponent* propertyComp, const String& tooltip)
  59. {
  60. propertyComp->setTooltip (tooltip);
  61. add (propertyComp);
  62. }
  63. void addSearchPathProperty (const Value& value, const String& name, const String& mainHelpText)
  64. {
  65. add (new TextPropertyComponent (value, name, 16384, true),
  66. mainHelpText + " Use semi-colons or new-lines to separate multiple paths.");
  67. }
  68. void addSearchPathProperty (ValueWithDefault& value, const String& name, const String& mainHelpText)
  69. {
  70. add (new TextPropertyComponent (value, name, 16384, true),
  71. mainHelpText + " Use semi-colons or new-lines to separate multiple paths.");
  72. }
  73. void setPreferredHeight (int height)
  74. {
  75. for (int j = components.size(); --j >= 0;)
  76. components.getUnchecked(j)->setPreferredHeight (height);
  77. }
  78. Array<PropertyComponent*> components;
  79. };
  80. //==============================================================================
  81. // A ValueSource which takes an input source, and forwards any changes in it.
  82. // This class is a handy way to create sources which re-map a value.
  83. class ValueSourceFilter : public Value::ValueSource,
  84. private Value::Listener
  85. {
  86. public:
  87. ValueSourceFilter (const Value& source) : sourceValue (source)
  88. {
  89. sourceValue.addListener (this);
  90. }
  91. protected:
  92. Value sourceValue;
  93. private:
  94. void valueChanged (Value&) override { sendChangeMessage (true); }
  95. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueSourceFilter)
  96. };