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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. TextButton::TextButton() : Button (String())
  21. {
  22. }
  23. TextButton::TextButton (const String& name) : Button (name)
  24. {
  25. }
  26. TextButton::TextButton (const String& name, const String& toolTip) : Button (name)
  27. {
  28. setTooltip (toolTip);
  29. }
  30. TextButton::~TextButton()
  31. {
  32. }
  33. void TextButton::paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown)
  34. {
  35. auto& lf = getLookAndFeel();
  36. lf.drawButtonBackground (g, *this,
  37. findColour (getToggleState() ? buttonOnColourId : buttonColourId),
  38. shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
  39. lf.drawButtonText (g, *this, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
  40. }
  41. void TextButton::colourChanged()
  42. {
  43. repaint();
  44. }
  45. void TextButton::changeWidthToFitText()
  46. {
  47. changeWidthToFitText (getHeight());
  48. }
  49. void TextButton::changeWidthToFitText (const int newHeight)
  50. {
  51. setSize (getBestWidthForHeight (newHeight), newHeight);
  52. }
  53. int TextButton::getBestWidthForHeight (int buttonHeight)
  54. {
  55. return getLookAndFeel().getTextButtonWidthToFitText (*this, buttonHeight);
  56. }
  57. } // namespace juce