[JUCE API] Customizing The GUI(2)

SangHoon You·2025년 4월 25일
0

JUCE API

목록 보기
11/17
post-thumbnail

After setting the GUI's color, I changed the text's font and slider image.


namespace BinaryData
{
    extern const char*   LatoMedium_ttf;
    const int            LatoMedium_ttfSize = 663564;
}

If we imported the .ttf file and we can check at BinaryData.header file in JUCE Library Code group.



class MyLookAndFeel  : public juce::LookAndFeel_V4
{
private:
    juce::FontOptions mFontOption;
}
mFontOption(juce::Typeface::createSystemTypefaceFor(BinaryData::LatoMedium_ttf,
                                                    BinaryData::LatoMedium_ttfSize))

I made the juce::FontOptions object and received the font's data as argument.



class JUCE_API  LookAndFeel  :  public Label::LookAndFeelMethods

struct JUCE_API  LookAndFeelMethods
    {
        virtual ~LookAndFeelMethods() = default;

        virtual void drawLabel (Graphics&, Label&) = 0;
        virtual Font getLabelFont (Label&) = 0;
        virtual BorderSize<int> getLabelBorderSize (Label&) = 0;
    };

The LookAndFeel class is derived from Labe::LookAndFeelMethods, which has pure virtual functions.

  • drawLabel() :
    Defines how the Label is drawn.
  • getLabelFont() :
    Determines the font used for the Label.
  • getLabelBorderSize() :
    Specifies the border size around the Label.

getLabelFont() is for handling the label's font.



juce::Font MyLookAndFeel::getLabelFont (juce::Label& inLabel)
{
    // Default
    return  juce::LookAndFeel_V4::getLabelFont(inLabel);
}

If we want to use the default font, just get the juce::LookAndFeel_V4's font.



juce::Font MyLookAndFeel::getLabelFont (juce::Label& inLabel)
{
    // Default
    //return  juce::LookAndFeel_V4::getLabelFont(inLabel);
    return mFontOption.withMetricsKind(juce::TypefaceMetricsKind::legacy).withHeight(MySize::Font::Height);
    
}

As I brought the juce::FontOptions's object, all of the label's font has changed.



void MyLoodAndFeel::drawRotarySlider (juce::Graphics& g,
                                       int x, int y, int width, int height,
                                       float sliderPosProportional,
                                       float rotaryStartAngle,
                                       float rotaryEndAngle,
                                       juce::Slider& s)
{
    
}

There is also pure virtual function drawRotarySlider() in Slider class, but there isn't return type. So if we don't define the function, that gonna show up without image.

profile
Audio Plugin Developer

0개의 댓글