horizont/Source/Knob.h
2026-08-10 12:55:02 +02:00

31 lines
795 B
C++

#pragma once
#include <JuceHeader.h>
class Knob : public juce::Component
{
public:
Knob (const juce::String& title,
juce::AudioProcessorValueTreeState& apvts,
const juce::String& paramID,
float defaultValue,
std::function<juce::String (float)> format,
const juce::String& tooltip);
void paint (juce::Graphics&) override;
void resized() override;
void setScaleFactor (float scale);
private:
void updateValueLabel();
std::function<juce::String (float)> format;
juce::Label nameLabel;
juce::Label valueLabel;
juce::Slider slider;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> attachment;
float scaleFactor = 1.0f;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Knob)
};