25#include "StateManager.h"
26#include <juce_gui_basics/juce_gui_basics.h>
47 , _child(params.child)
49 addAndMakeVisible(_child);
56 void paint(juce::Graphics& g)
override
58 g.setColour(_params.
child.color);
59 g.setFont(_fonts->h4);
61 const auto area = getLocalBounds();
62 const auto margin = 5;
63 const auto childBottomY = _child.getBoundsInParent().getBottom() + margin;
65 const auto text = [
this]()
69 return _child.isMouseButtonDown() ? _child.getTextFromValue(_child.getValue())
70 : _params.
label.toUpperCase();
72 return _params.
label.toUpperCase();
75 g.drawText(text, area.withTop(childBottomY), juce::Justification::centredTop,
true);
78 void resized()
override
80 const auto offsetY = 10;
81 const auto x = getLocalBounds().getCentreX();
82 const auto y = getLocalBounds().getCentreY() - offsetY;
83 const auto childSize = 30;
84 _child.setBounds(x - (childSize / 2), y - (childSize / 2), childSize, childSize);
Custom knob component that displays a label and a value.
Definition Knob.h:35
A component with a label.
Definition Labeled.h:35
void attach(plugin::StateManager &state, juce::ParameterID id)
Attach the child component to a parameter.
Definition Labeled.h:53
Labeled(const Params ¶ms)
Constructor.
Definition Labeled.h:45
Base class for storing plugin state.
Definition StateManager.h:39
juce::SharedResourcePointer< Fonts > Instance
Add this as a member to your component/editor class to access the fonts.
Definition Fonts.h:58
Parameters.
Definition Labeled.h:39
juce::String label
The label to be displayed.
Definition Labeled.h:40
T::Params child
The parameters for the child component.
Definition Labeled.h:41