aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominik Kaiser2025-10-07 11:27:18 +0200
committerDominik Kaiser2025-10-07 11:27:18 +0200
commitdf4c72f990bc8f293af417bef893ee340874882a (patch)
treef333afef3e52e6074aeaa2050b35a30c7cf9103f /src
parentc52f9a8babfffef1413df3e03dc6f16d5ffa2c85 (diff)
downloadSchroederReverb-df4c72f990bc8f293af417bef893ee340874882a.tar.gz
SchroederReverb-df4c72f990bc8f293af417bef893ee340874882a.zip
Add KnobWithLabel class
Diffstat (limited to 'src')
-rw-r--r--src/UI/KnobWithLabel.cpp34
-rw-r--r--src/UI/KnobWithLabel.h20
2 files changed, 54 insertions, 0 deletions
diff --git a/src/UI/KnobWithLabel.cpp b/src/UI/KnobWithLabel.cpp
new file mode 100644
index 0000000..9a09307
--- /dev/null
+++ b/src/UI/KnobWithLabel.cpp
@@ -0,0 +1,34 @@
+#include "KnobWithLabel.h"
+
+KnobWithLabel::KnobWithLabel(const juce::String& text, juce::AudioParameterFloat* param)
+ : param(param)
+{
+ addAndMakeVisible(label);
+ label.setText(text, juce::dontSendNotification);
+ label.setJustificationType(juce::Justification::centred);
+ label.setFont(juce::Font(juce::FontOptions().withHeight(10.0f)));
+ addAndMakeVisible(knob);
+ knob.setSliderStyle(juce::Slider::Rotary);
+ knob.setTextBoxStyle(juce::Slider::TextBoxBelow, false, 50, 20);
+ knob.setValue(param->get());
+
+ auto range = param->getNormalisableRange();
+ knob.setRange(range.start, range.end, range.interval);
+
+ knob.onValueChange = [this]()
+ {
+ if (this->param != nullptr)
+ {
+ *this->param = (float) knob.getValue();
+ }
+ };
+}
+
+KnobWithLabel::~KnobWithLabel() {}
+
+void
+KnobWithLabel::resized()
+{
+ knob.setBounds(0, 0, getWidth(), getHeight());
+ label.setBounds(0, -10, getWidth(), getHeight());
+}
diff --git a/src/UI/KnobWithLabel.h b/src/UI/KnobWithLabel.h
new file mode 100644
index 0000000..6be2316
--- /dev/null
+++ b/src/UI/KnobWithLabel.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <juce_audio_processors/juce_audio_processors.h>
+#include <juce_gui_basics/juce_gui_basics.h>
+
+class KnobWithLabel : public juce::Component
+{
+ public:
+ KnobWithLabel(const juce::String& text, juce::AudioParameterFloat* param);
+ ~KnobWithLabel();
+
+ void resized() override;
+
+ private:
+ juce::Slider knob;
+ juce::Label label;
+ juce::AudioParameterFloat* param = nullptr;
+
+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(KnobWithLabel);
+};