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.

70 lines
2.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. TextButton::TextButton (const String& name, const String& toolTip)
  18. : Button (name)
  19. {
  20. setTooltip (toolTip);
  21. }
  22. TextButton::~TextButton()
  23. {
  24. }
  25. void TextButton::paintButton (Graphics& g,
  26. bool isMouseOverButton,
  27. bool isButtonDown)
  28. {
  29. LookAndFeel& lf = getLookAndFeel();
  30. lf.drawButtonBackground (g, *this,
  31. findColour (getToggleState() ? buttonOnColourId
  32. : buttonColourId),
  33. isMouseOverButton,
  34. isButtonDown);
  35. lf.drawButtonText (g, *this,
  36. isMouseOverButton,
  37. isButtonDown);
  38. }
  39. void TextButton::colourChanged()
  40. {
  41. repaint();
  42. }
  43. Font TextButton::getFont()
  44. {
  45. return Font (jmin (15.0f, getHeight() * 0.6f));
  46. }
  47. void TextButton::changeWidthToFitText (const int newHeight)
  48. {
  49. if (newHeight >= 0)
  50. setSize (jmax (1, getWidth()), newHeight);
  51. setSize (getFont().getStringWidth (getButtonText()) + getHeight(),
  52. getHeight());
  53. }