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.

208 lines
6.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. //==============================================================================
  19. // String::hashCode64 actually hit some dupes, so this is a more powerful version.
  20. const int64 hashCode64 (const String& s);
  21. const String randomHexString (Random& random, int numChars);
  22. const String hexString8Digits (int value);
  23. const String createAlphaNumericUID();
  24. const String createGUID (const String& seed); // Turns a seed into a windows GUID
  25. //==============================================================================
  26. int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
  27. void autoScrollForMouseEvent (const MouseEvent& e, bool scrollX = true, bool scrollY = true);
  28. void drawComponentPlaceholder (Graphics& g, int w, int h, const String& text);
  29. void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize);
  30. //==============================================================================
  31. class PropertyPanelWithTooltips : public Component,
  32. public Timer
  33. {
  34. public:
  35. PropertyPanelWithTooltips();
  36. ~PropertyPanelWithTooltips();
  37. PropertyPanel* getPanel() const { return panel; }
  38. void paint (Graphics& g);
  39. void resized();
  40. void timerCallback();
  41. private:
  42. PropertyPanel* panel;
  43. TextLayout layout;
  44. Component* lastComp;
  45. String lastTip;
  46. const String findTip (Component* c);
  47. };
  48. //==============================================================================
  49. class FloatingLabelComponent : public Component
  50. {
  51. public:
  52. FloatingLabelComponent();
  53. void remove();
  54. void update (Component* parent, const String& text, const Colour& textColour, int x, int y, bool toRight, bool below);
  55. void paint (Graphics& g);
  56. private:
  57. Font font;
  58. Colour colour;
  59. GlyphArrangement glyphs;
  60. };
  61. //==============================================================================
  62. class JucerToolbarButton : public ToolbarItemComponent
  63. {
  64. public:
  65. //==============================================================================
  66. JucerToolbarButton (int itemId_, const String& labelText)
  67. : ToolbarItemComponent (itemId_, labelText, true)
  68. {
  69. setClickingTogglesState (false);
  70. }
  71. ~JucerToolbarButton()
  72. {
  73. }
  74. //==============================================================================
  75. bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize, int& minSize, int& maxSize)
  76. {
  77. preferredSize = minSize = maxSize = 50;
  78. return true;
  79. }
  80. void paintButton (Graphics& g, bool over, bool down)
  81. {
  82. Path p;
  83. p.addRoundedRectangle (1.5f, 2.5f, getWidth() - 3.0f, getHeight() - 5.0f, 3.0f);
  84. if (getToggleState())
  85. {
  86. g.setColour (Colours::grey.withAlpha (0.5f));
  87. g.fillPath (p);
  88. }
  89. g.setColour (Colours::darkgrey.withAlpha (0.3f));
  90. g.strokePath (p, PathStrokeType (1.0f));
  91. g.setFont (11.0f);
  92. g.setColour (Colours::black.withAlpha ((over || down) ? 1.0f : 0.7f));
  93. g.drawFittedText (getButtonText(), 2, 2, getWidth() - 4, getHeight() - 4, Justification::centred, 2);
  94. }
  95. void paintButtonArea (Graphics& g, int width, int height, bool isMouseOver, bool isMouseDown)
  96. {
  97. }
  98. void contentAreaChanged (const Rectangle<int>& newBounds)
  99. {
  100. }
  101. juce_UseDebuggingNewOperator
  102. private:
  103. JucerToolbarButton (const JucerToolbarButton&);
  104. JucerToolbarButton& operator= (const JucerToolbarButton&);
  105. };
  106. //==============================================================================
  107. /**
  108. */
  109. class RelativeRectangleLayoutManager : public ComponentListener,
  110. public Expression::EvaluationContext,
  111. public AsyncUpdater
  112. {
  113. public:
  114. //==============================================================================
  115. /**
  116. */
  117. RelativeRectangleLayoutManager (Component* parentComponent);
  118. /** Destructor. */
  119. ~RelativeRectangleLayoutManager();
  120. //==============================================================================
  121. /**
  122. */
  123. void setMarker (const String& name, const RelativeCoordinate& coord);
  124. /**
  125. */
  126. void setComponentBounds (Component* component, const String& componentName, const RelativeRectangle& bounds);
  127. /**
  128. */
  129. void applyLayout();
  130. //==============================================================================
  131. /** @internal */
  132. const Expression getSymbolValue (const String& symbol) const;
  133. /** @internal */
  134. void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized);
  135. /** @internal */
  136. void componentBeingDeleted (Component& component);
  137. /** @internal */
  138. void handleAsyncUpdate();
  139. juce_UseDebuggingNewOperator
  140. private:
  141. //==============================================================================
  142. struct ComponentPosition
  143. {
  144. ComponentPosition (Component* component, const String& name, const RelativeRectangle& coords);
  145. Component* component;
  146. String name;
  147. RelativeRectangle coords;
  148. };
  149. struct MarkerPosition
  150. {
  151. MarkerPosition (const String& name, const RelativeCoordinate& coord);
  152. String markerName;
  153. RelativeCoordinate position;
  154. };
  155. Component* parent;
  156. OwnedArray <ComponentPosition> components;
  157. OwnedArray <MarkerPosition> markers;
  158. RelativeRectangleLayoutManager (const RelativeRectangleLayoutManager&);
  159. RelativeRectangleLayoutManager& operator= (const RelativeRectangleLayoutManager&);
  160. };