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.

67 lines
2.2KB

  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. class LabelPropertyComponent : public PropertyComponent
  16. {
  17. public:
  18. LabelPropertyComponent (const String& labelText, int propertyHeight = 25,
  19. Font labelFont = Font (16.0f, Font::bold),
  20. Justification labelJustification = Justification::centred)
  21. : PropertyComponent (labelText),
  22. labelToDisplay ({}, labelText)
  23. {
  24. setPreferredHeight (propertyHeight);
  25. labelToDisplay.setJustificationType (labelJustification);
  26. labelToDisplay.setFont (labelFont);
  27. addAndMakeVisible (labelToDisplay);
  28. setLookAndFeel (&lf);
  29. }
  30. ~LabelPropertyComponent() override { setLookAndFeel (nullptr); }
  31. //==============================================================================
  32. void refresh() override {}
  33. void resized() override
  34. {
  35. labelToDisplay.setBounds (getLocalBounds());
  36. }
  37. private:
  38. //==============================================================================
  39. struct LabelLookAndFeel : public ProjucerLookAndFeel
  40. {
  41. void drawPropertyComponentLabel (Graphics&, int, int, PropertyComponent&) {}
  42. };
  43. void lookAndFeelChanged() override
  44. {
  45. labelToDisplay.setColour (Label::textColourId, ProjucerApplication::getApp().lookAndFeel.findColour (defaultTextColourId));
  46. }
  47. //==============================================================================
  48. LabelLookAndFeel lf;
  49. Label labelToDisplay;
  50. };