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.

juce_GroupComponent.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 component that draws an outline around itself and has an optional title at
  23. the top, for drawing an outline around a group of controls.
  24. @tags{GUI}
  25. */
  26. class JUCE_API GroupComponent : public Component
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a GroupComponent.
  31. @param componentName the name to give the component
  32. @param labelText the text to show at the top of the outline
  33. */
  34. GroupComponent (const String& componentName = {},
  35. const String& labelText = {});
  36. /** Destructor. */
  37. ~GroupComponent() override;
  38. //==============================================================================
  39. /** Changes the text that's shown at the top of the component. */
  40. void setText (const String& newText);
  41. /** Returns the currently displayed text label. */
  42. String getText() const;
  43. /** Sets the positioning of the text label.
  44. (The default is Justification::left)
  45. @see getTextLabelPosition
  46. */
  47. void setTextLabelPosition (Justification justification);
  48. /** Returns the current text label position.
  49. @see setTextLabelPosition
  50. */
  51. Justification getTextLabelPosition() const noexcept { return justification; }
  52. //==============================================================================
  53. /** A set of colour IDs to use to change the colour of various aspects of the component.
  54. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  55. methods.
  56. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  57. */
  58. enum ColourIds
  59. {
  60. outlineColourId = 0x1005400, /**< The colour to use for drawing the line around the edge. */
  61. textColourId = 0x1005410 /**< The colour to use to draw the text label. */
  62. };
  63. //==============================================================================
  64. /** This abstract base class is implemented by LookAndFeel classes. */
  65. struct JUCE_API LookAndFeelMethods
  66. {
  67. virtual ~LookAndFeelMethods() = default;
  68. virtual void drawGroupComponentOutline (Graphics&, int w, int h, const String& text,
  69. const Justification&, GroupComponent&) = 0;
  70. };
  71. //==============================================================================
  72. /** @internal */
  73. void paint (Graphics&) override;
  74. /** @internal */
  75. void enablementChanged() override;
  76. /** @internal */
  77. void colourChanged() override;
  78. private:
  79. std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
  80. String text;
  81. Justification justification;
  82. JUCE_DECLARE_NON_COPYABLE (GroupComponent)
  83. };
  84. } // namespace juce