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.

143 lines
4.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCETICE project - Copyright 2008 by Lucio Asnaghi.
  4. JUCETICE is based around the JUCE library - "Jules' Utility Class Extensions"
  5. Copyright 2008 by Julian Storer.
  6. ------------------------------------------------------------------------------
  7. JUCE and JUCETICE can be redistributed and/or modified under the terms of
  8. the GNU Lesser General Public License, as published by the Free Software
  9. Foundation; either version 2 of the License, or (at your option) any later
  10. version.
  11. JUCE and JUCETICE are distributed in the hope that they will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public License
  16. along with JUCE and JUCETICE; if not, visit www.gnu.org/licenses or write to
  17. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. Boston, MA 02111-1307 USA
  19. ==============================================================================
  20. @author rockhardbuns
  21. @tweaker Lucio Asnaghi
  22. ==============================================================================
  23. */
  24. #include "MyLookAndFeel.h"
  25. MyLookAndFeel::MyLookAndFeel()
  26. {
  27. MemoryInputStream fontStream (Resources::t_bin, Resources::t_binSize, false);
  28. CustomTypeface* tf = new CustomTypeface (fontStream);
  29. Topaz = new Font (tf);
  30. // delete tf;
  31. Topaz->setHeight (9.0f);
  32. Topaz->setHorizontalScale (1.0f);
  33. // Topaz = new Font (Font::getDefaultMonospacedFontName (), 12.0f, Font::plain);
  34. // Topaz->setHorizontalScale (1.0f);
  35. }
  36. MyLookAndFeel::~MyLookAndFeel()
  37. {
  38. delete Topaz;
  39. }
  40. Font MyLookAndFeel::getComboBoxFont (ComboBox& box)
  41. {
  42. return *Topaz;
  43. }
  44. Font MyLookAndFeel::getPopupMenuFont()
  45. {
  46. return *Topaz;
  47. }
  48. void MyLookAndFeel::getIdealPopupMenuItemSize(const String& text,
  49. const bool isSeparator,
  50. int standardMenuItemHeight,
  51. int& idealWidth,
  52. int& idealHeight)
  53. {
  54. if (isSeparator)
  55. {
  56. idealWidth = 50;
  57. idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight / 2 : 10;
  58. }
  59. else
  60. {
  61. Font font (getPopupMenuFont());
  62. idealHeight = roundFloatToInt (font.getHeight() * 1.3f);
  63. idealWidth = font.getStringWidth (text) + idealHeight * 2;
  64. }
  65. }
  66. void MyLookAndFeel::drawToggleButton(Graphics& g,
  67. ToggleButton& button,
  68. bool isMouseOverButton,
  69. bool isButtonDown)
  70. {
  71. const int tickWidth = jmin (20, button.getHeight() - 4);
  72. drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
  73. tickWidth, tickWidth,
  74. button.getToggleState(),
  75. button.isEnabled(),
  76. isMouseOverButton,
  77. isButtonDown);
  78. g.setColour (button.findColour (ToggleButton::textColourId));
  79. g.setFont (*Topaz);
  80. const int textX = tickWidth + 5;
  81. g.drawFittedText (button.getButtonText(),
  82. textX, 4,
  83. button.getWidth() - textX - 2, button.getHeight() - 8,
  84. Justification::centredLeft, 10);
  85. }
  86. void MyLookAndFeel::drawRotarySlider (Graphics& g,
  87. int x, int y,
  88. int width, int height,
  89. float sliderPos,
  90. const float rotaryStartAngle,
  91. const float rotaryEndAngle,
  92. Slider& slider)
  93. {
  94. const float radius = jmin (width / 2, height / 2) - 2.0f;
  95. const float centreX = x + width * 0.5f;
  96. const float centreY = y + height * 0.5f;
  97. const float rx = centreX - radius;
  98. const float ry = centreY - radius;
  99. const float rw = radius * 2.0f;
  100. const float angle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle);
  101. //const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled();
  102. // const float zeroPos = rotaryStartAngle + fabs((float)slider.getMinimum() / ((float)slider.getMaximum() - (float)slider.getMinimum())) * (rotaryEndAngle - rotaryStartAngle);
  103. Path p;
  104. PathStrokeType (rw * 0.01f).createStrokedPath (p, p);
  105. p.addLineSegment (Line<float>(0.0f, -radius * 0.5f, 0.00f, -radius), rw * 0.08f);
  106. g.setColour (Colours::white.withAlpha (1.0f));
  107. g.fillPath (p, AffineTransform::rotation (angle).translated (centreX, centreY));
  108. g.setColour (Colours::black.withAlpha (0.7f));
  109. g.drawEllipse (rx, ry, rw, rw, 1.0f);
  110. }