osci-render/Source/visualiser/VisualiserSettings.cpp

126 wiersze
4.7 KiB
C++
Czysty Zwykły widok Historia

2024-08-10 19:26:56 +00:00
#include "VisualiserSettings.h"
#include "VisualiserComponent.h"
2024-08-10 19:26:56 +00:00
#include "../PluginEditor.h"
VisualiserSettings::VisualiserSettings(VisualiserParameters& p, int numChannels) : parameters(p), numChannels(numChannels) {
addAndMakeVisible(intensity);
2024-08-10 19:26:56 +00:00
addAndMakeVisible(persistence);
addAndMakeVisible(hue);
addAndMakeVisible(lineSaturation);
2024-09-29 19:36:16 +00:00
addAndMakeVisible(focus);
addAndMakeVisible(noise);
addAndMakeVisible(glow);
addAndMakeVisible(ambient);
2024-11-09 22:51:42 +00:00
addAndMakeVisible(smooth);
addAndMakeVisible(sweepMs);
addAndMakeVisible(triggerValue);
addAndMakeVisible(upsamplingToggle);
2024-11-17 12:18:30 +00:00
addAndMakeVisible(sweepToggle);
addAndMakeVisible(screenOverlayLabel);
addAndMakeVisible(screenOverlay);
2025-01-10 12:41:34 +00:00
#if SOSCI_FEATURES
addAndMakeVisible(screenSaturation);
addAndMakeVisible(xOffset);
addAndMakeVisible(yOffset);
addAndMakeVisible(xScale);
addAndMakeVisible(yScale);
addAndMakeVisible(flipVerticalToggle);
addAndMakeVisible(flipHorizontalToggle);
#endif
for (int i = 1; i <= parameters.screenOverlay->max; i++) {
screenOverlay.addItem(parameters.screenOverlay->getText(parameters.screenOverlay->getNormalisedValue(i)), i);
}
screenOverlay.setSelectedId(parameters.screenOverlay->getValueUnnormalised());
screenOverlay.onChange = [this] {
parameters.screenOverlay->setUnnormalisedValueNotifyingHost(screenOverlay.getSelectedId());
};
intensity.setSliderOnValueChange();
persistence.setSliderOnValueChange();
hue.setSliderOnValueChange();
lineSaturation.setSliderOnValueChange();
2024-09-29 19:36:16 +00:00
focus.setSliderOnValueChange();
noise.setSliderOnValueChange();
glow.setSliderOnValueChange();
ambient.setSliderOnValueChange();
2024-11-09 22:51:42 +00:00
smooth.setSliderOnValueChange();
2024-11-17 12:18:30 +00:00
sweepMs.setSliderOnValueChange();
triggerValue.setSliderOnValueChange();
sweepMs.setEnabled(sweepToggle.getToggleState());
triggerValue.setEnabled(sweepToggle.getToggleState());
sweepMs.slider.setSkewFactorFromMidPoint(100);
2024-11-17 12:18:30 +00:00
sweepToggle.onClick = [this] {
sweepMs.setEnabled(sweepToggle.getToggleState());
triggerValue.setEnabled(sweepToggle.getToggleState());
2024-11-17 12:18:30 +00:00
resized();
};
2025-01-08 13:06:01 +00:00
2025-01-10 12:41:34 +00:00
#if SOSCI_FEATURES
screenSaturation.setSliderOnValueChange();
xOffset.setSliderOnValueChange();
yOffset.setSliderOnValueChange();
xScale.setSliderOnValueChange();
yScale.setSliderOnValueChange();
#endif
2025-01-08 13:06:01 +00:00
parameters.screenOverlay->addListener(this);
2024-08-10 19:26:56 +00:00
}
2025-01-08 13:06:01 +00:00
VisualiserSettings::~VisualiserSettings() {
parameters.screenOverlay->removeListener(this);
}
2024-08-10 19:26:56 +00:00
void VisualiserSettings::paint(juce::Graphics& g) {
g.fillAll(Colours::darker);
}
2024-08-10 19:26:56 +00:00
void VisualiserSettings::resized() {
auto area = getLocalBounds().reduced(20, 0).withTrimmedBottom(20);
2024-08-10 19:26:56 +00:00
double rowHeight = 30;
auto screenOverlayArea = area.removeFromTop(2 * rowHeight);
screenOverlayArea = screenOverlayArea.withSizeKeepingCentre(300, rowHeight);
screenOverlayLabel.setBounds(screenOverlayArea.removeFromLeft(120));
screenOverlay.setBounds(screenOverlayArea.removeFromRight(180));
2024-08-10 19:26:56 +00:00
intensity.setBounds(area.removeFromTop(rowHeight));
persistence.setBounds(area.removeFromTop(rowHeight));
hue.setBounds(area.removeFromTop(rowHeight));
lineSaturation.setBounds(area.removeFromTop(rowHeight));
2025-01-10 12:41:34 +00:00
#if SOSCI_FEATURES
screenSaturation.setBounds(area.removeFromTop(rowHeight));
2025-01-10 12:41:34 +00:00
#endif
2024-09-29 19:36:16 +00:00
focus.setBounds(area.removeFromTop(rowHeight));
noise.setBounds(area.removeFromTop(rowHeight));
glow.setBounds(area.removeFromTop(rowHeight));
ambient.setBounds(area.removeFromTop(rowHeight));
2024-11-09 22:51:42 +00:00
smooth.setBounds(area.removeFromTop(rowHeight));
2025-01-10 12:41:34 +00:00
#if SOSCI_FEATURES
xScale.setBounds(area.removeFromTop(rowHeight));
yScale.setBounds(area.removeFromTop(rowHeight));
xOffset.setBounds(area.removeFromTop(rowHeight));
yOffset.setBounds(area.removeFromTop(rowHeight));
flipVerticalToggle.setBounds(area.removeFromTop(rowHeight));
flipHorizontalToggle.setBounds(area.removeFromTop(rowHeight));
#endif
upsamplingToggle.setBounds(area.removeFromTop(rowHeight));
2024-11-17 12:18:30 +00:00
sweepToggle.setBounds(area.removeFromTop(rowHeight));
sweepMs.setBounds(area.removeFromTop(rowHeight));
triggerValue.setBounds(area.removeFromTop(rowHeight));
2024-08-10 19:26:56 +00:00
}
2025-01-08 13:06:01 +00:00
void VisualiserSettings::parameterValueChanged(int parameterIndex, float newValue) {
if (parameterIndex == parameters.screenOverlay->getParameterIndex()) {
screenOverlay.setSelectedId(parameters.screenOverlay->getValueUnnormalised());
}
}
void VisualiserSettings::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) {}