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.

123 lines
4.3KB

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