Audio plugin host https://kx.studio/carla
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.

121 lines
4.4KB

  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. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A drawable object which renders a line of text.
  23. @see Drawable
  24. @tags{GUI}
  25. */
  26. class JUCE_API DrawableText : public Drawable
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a DrawableText object. */
  31. DrawableText();
  32. DrawableText (const DrawableText&);
  33. /** Destructor. */
  34. ~DrawableText() override;
  35. //==============================================================================
  36. /** Sets the text to display.*/
  37. void setText (const String& newText);
  38. /** Returns the currently displayed text */
  39. const String& getText() const noexcept { return text;}
  40. /** Sets the colour of the text. */
  41. void setColour (Colour newColour);
  42. /** Returns the current text colour. */
  43. Colour getColour() const noexcept { return colour; }
  44. /** Sets the font to use.
  45. Note that the font height and horizontal scale are set using setFontHeight() and
  46. setFontHorizontalScale(). If applySizeAndScale is true, then these height
  47. and scale values will be changed to match the dimensions of the font supplied;
  48. if it is false, then the new font object's height and scale are ignored.
  49. */
  50. void setFont (const Font& newFont, bool applySizeAndScale);
  51. /** Returns the current font. */
  52. const Font& getFont() const noexcept { return font; }
  53. /** Changes the justification of the text within the bounding box. */
  54. void setJustification (Justification newJustification);
  55. /** Returns the current justification. */
  56. Justification getJustification() const noexcept { return justification; }
  57. /** Returns the parallelogram that defines the text bounding box. */
  58. Parallelogram<float> getBoundingBox() const noexcept { return bounds; }
  59. /** Sets the bounding box that contains the text. */
  60. void setBoundingBox (Parallelogram<float> newBounds);
  61. float getFontHeight() const noexcept { return fontHeight; }
  62. void setFontHeight (float newHeight);
  63. float getFontHorizontalScale() const noexcept { return fontHScale; }
  64. void setFontHorizontalScale (float newScale);
  65. //==============================================================================
  66. /** @internal */
  67. void paint (Graphics&) override;
  68. /** @internal */
  69. std::unique_ptr<Drawable> createCopy() const override;
  70. /** @internal */
  71. Rectangle<float> getDrawableBounds() const override;
  72. /** @internal */
  73. Path getOutlineAsPath() const override;
  74. /** @internal */
  75. bool replaceColour (Colour originalColour, Colour replacementColour) override;
  76. private:
  77. //==============================================================================
  78. Parallelogram<float> bounds;
  79. float fontHeight, fontHScale;
  80. Font font, scaledFont;
  81. String text;
  82. Colour colour;
  83. Justification justification;
  84. std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
  85. void refreshBounds();
  86. Rectangle<int> getTextArea (float width, float height) const;
  87. AffineTransform getTextTransform (float width, float height) const;
  88. DrawableText& operator= (const DrawableText&);
  89. JUCE_LEAK_DETECTOR (DrawableText)
  90. };
  91. } // namespace juce