2024-04-15 19:54:25 +00:00
|
|
|
#include "LineArtComponent.h"
|
|
|
|
#include "PluginEditor.h"
|
|
|
|
|
|
|
|
LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) {
|
|
|
|
setText("Line Art Settings");
|
|
|
|
|
|
|
|
|
|
|
|
addAndMakeVisible(animate);
|
|
|
|
addAndMakeVisible(sync);
|
2024-04-17 15:00:59 +00:00
|
|
|
addAndMakeVisible(rateLabel);
|
2024-04-15 19:54:25 +00:00
|
|
|
addAndMakeVisible(rate);
|
2024-04-17 15:00:59 +00:00
|
|
|
addAndMakeVisible(offsetLabel);
|
|
|
|
addAndMakeVisible(offset);
|
|
|
|
|
|
|
|
rateLabel.setText("Framerate: ", juce::dontSendNotification);
|
|
|
|
rate.setText("8", false);
|
2024-04-15 19:54:25 +00:00
|
|
|
rate.setInputRestrictions(6, "0123456789.");
|
|
|
|
|
2024-04-17 15:00:59 +00:00
|
|
|
offsetLabel.setText(" Offset: ", juce::dontSendNotification);
|
|
|
|
offset.setText("0", false);
|
|
|
|
offset.setInputRestrictions(6, "0123456789");
|
|
|
|
|
|
|
|
audioProcessor.openFile(audioProcessor.currentFile);
|
2024-04-15 19:54:25 +00:00
|
|
|
update();
|
|
|
|
|
|
|
|
auto updateAnimation = [this]() {
|
|
|
|
audioProcessor.animateLineArt = animate.getToggleState();
|
|
|
|
audioProcessor.syncMIDIAnimation = sync.getToggleState();
|
|
|
|
try {
|
|
|
|
audioProcessor.animationRate = std::stof(rate.getText().toStdString());
|
|
|
|
}
|
|
|
|
catch (std::exception e) {
|
2024-04-17 15:00:59 +00:00
|
|
|
audioProcessor.animationRate = 8.f;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
audioProcessor.animationOffset = std::stoi(offset.getText().toStdString());
|
|
|
|
}
|
|
|
|
catch (std::exception e) {
|
|
|
|
audioProcessor.animationOffset = 0;
|
2024-04-15 19:54:25 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
animate.onClick = updateAnimation;
|
|
|
|
sync.onClick = updateAnimation;
|
|
|
|
rate.onFocusLost = updateAnimation;
|
2024-04-17 15:00:59 +00:00
|
|
|
offset.onFocusLost = updateAnimation;
|
2024-04-15 19:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineArtComponent::resized() {
|
|
|
|
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
|
|
|
|
double rowHeight = 30;
|
2024-04-17 15:00:59 +00:00
|
|
|
double rowSpace = 5;
|
|
|
|
auto animateBounds = area.removeFromTop(rowHeight);
|
|
|
|
animate.setBounds(animateBounds);
|
|
|
|
area.removeFromTop(rowSpace);
|
|
|
|
|
|
|
|
animateBounds = area.removeFromTop(rowHeight);
|
|
|
|
sync.setBounds(animateBounds);
|
|
|
|
area.removeFromTop(rowSpace);
|
|
|
|
|
|
|
|
animateBounds = area.removeFromTop(rowHeight);
|
|
|
|
rateLabel.setBounds(animateBounds.removeFromLeft(100));
|
|
|
|
rate.setBounds(animateBounds);
|
|
|
|
area.removeFromTop(rowSpace);
|
|
|
|
|
|
|
|
animateBounds = area.removeFromTop(rowHeight);
|
|
|
|
offsetLabel.setBounds(animateBounds.removeFromLeft(100));
|
|
|
|
offset.setBounds(animateBounds);
|
|
|
|
area.removeFromTop(rowSpace);
|
2024-04-15 19:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineArtComponent::update() {
|
|
|
|
rate.setText(juce::String(audioProcessor.animationRate));
|
2024-04-17 15:00:59 +00:00
|
|
|
offset.setText(juce::String(audioProcessor.animationOffset));
|
2024-04-15 19:54:25 +00:00
|
|
|
animate.setToggleState(audioProcessor.animateLineArt, false);
|
|
|
|
sync.setToggleState(audioProcessor.syncMIDIAnimation, false);
|
|
|
|
}
|