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_TextButton.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. }