Add basic tooltips to effect component

pull/170/head
James Ball 2023-12-12 22:54:36 +00:00
rodzic a7e7ea8122
commit f310e98d6b
7 zmienionych plików z 67 dodań i 33 usunięć

Wyświetl plik

@ -58,6 +58,8 @@ private:
juce::StretchableLayoutManager layout; juce::StretchableLayoutManager layout;
juce::StretchableLayoutResizerBar resizerBar{&layout, 1, true}; juce::StretchableLayoutResizerBar resizerBar{&layout, 1, true};
juce::TooltipWindow tooltipWindow{this};
std::atomic<bool> updatingDocumentsWithParserLock = false; std::atomic<bool> updatingDocumentsWithParserLock = false;
void codeDocumentTextInserted(const juce::String& newText, int insertIndex) override; void codeDocumentTextInserted(const juce::String& newText, int insertIndex) override;

Wyświetl plik

@ -36,46 +36,56 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<BitCrushEffect>(), std::make_shared<BitCrushEffect>(),
new EffectParameter("Bit Crush", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Bit Crush", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0),
"bitCrush"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<BulgeEffect>(), std::make_shared<BulgeEffect>(),
new EffectParameter("Bulge", "bulge", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Bulge", "bulge", VERSION_HINT, 0.0, 0.0, 1.0),
"bulge"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<RotateEffect>(), std::make_shared<RotateEffect>(),
new EffectParameter("2D Rotate", "2DRotateSpeed", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("2D Rotate", "2DRotateSpeed", VERSION_HINT, 0.0, 0.0, 1.0),
"2DRotate"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<VectorCancellingEffect>(), std::make_shared<VectorCancellingEffect>(),
new EffectParameter("Vector Cancelling", "vectorCancelling", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Vector Cancelling", "vectorCancelling", VERSION_HINT, 0.0, 0.0, 1.0),
"vectorCancelling"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<DistortEffect>(false), std::make_shared<DistortEffect>(false),
new EffectParameter("Distort X", "distortX", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Distort X", "distortX", VERSION_HINT, 0.0, 0.0, 1.0),
"distortX"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<DistortEffect>(true), std::make_shared<DistortEffect>(true),
new EffectParameter("Distort Y", "distortY", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Distort Y", "distortY", VERSION_HINT, 0.0, 0.0, 1.0),
"distortY"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
input.x += values[0]; input.x += values[0];
input.y += values[1]; input.y += values[1];
return input; return input;
}, std::vector<EffectParameter*>{new EffectParameter("Translate X", "translateX", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "translateY", VERSION_HINT, 0.0, -1.0, 1.0)} }, std::vector<EffectParameter*>{new EffectParameter("Translate X", "translateX", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Translate Y", "translateY", VERSION_HINT, 0.0, -1.0, 1.0)},
"translate"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<SmoothEffect>(), std::make_shared<SmoothEffect>(),
new EffectParameter("Smoothing", "smoothing", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Smoothing", "smoothing", VERSION_HINT, 0.0, 0.0, 1.0),
"smoothing"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
wobbleEffect, wobbleEffect,
new EffectParameter("Wobble", "wobble", VERSION_HINT, 0.0, 0.0, 1.0) new EffectParameter("Wobble", "wobble", VERSION_HINT, 0.0, 0.0, 1.0),
"wobble"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
delayEffect, delayEffect,
std::vector<EffectParameter*>{new EffectParameter("Delay Decay", "delayDecay", VERSION_HINT, 0.0, 0.0, 1.0), new EffectParameter("Delay Length", "delayLength", VERSION_HINT, 0.5, 0.0, 1.0)} std::vector<EffectParameter*>{new EffectParameter("Delay Decay", "delayDecay", VERSION_HINT, 0.0, 0.0, 1.0), new EffectParameter("Delay Length", "delayLength", VERSION_HINT, 0.5, 0.0, 1.0)},
"delay"
)); ));
toggleableEffects.push_back(std::make_shared<Effect>( toggleableEffects.push_back(std::make_shared<Effect>(
perspectiveEffect, perspectiveEffect,
@ -86,7 +96,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
new EffectParameter("Rotate X", "perspectiveRotateX", VERSION_HINT, 1.0, -1.0, 1.0), new EffectParameter("Rotate X", "perspectiveRotateX", VERSION_HINT, 1.0, -1.0, 1.0),
new EffectParameter("Rotate Y", "perspectiveRotateY", VERSION_HINT, 1.0, -1.0, 1.0), new EffectParameter("Rotate Y", "perspectiveRotateY", VERSION_HINT, 1.0, -1.0, 1.0),
new EffectParameter("Rotate Z", "perspectiveRotateZ", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Rotate Z", "perspectiveRotateZ", VERSION_HINT, 0.0, -1.0, 1.0),
} },
"perspective"
)); ));
toggleableEffects.push_back(traceMax); toggleableEffects.push_back(traceMax);
toggleableEffects.push_back(traceMin); toggleableEffects.push_back(traceMin);
@ -263,7 +274,8 @@ void OscirenderAudioProcessor::addLuaSlider() {
luaEffects.push_back(std::make_shared<Effect>( luaEffects.push_back(std::make_shared<Effect>(
std::make_shared<LuaEffect>(sliderName, *this), std::make_shared<LuaEffect>(sliderName, *this),
new EffectParameter("Lua " + sliderName, "lua" + sliderName, VERSION_HINT, 0.0, 0.0, 1.0, 0.001, false) new EffectParameter("Lua " + sliderName, "lua" + sliderName, VERSION_HINT, 0.0, 0.0, 1.0, 0.001, false),
"lua" + sliderName
)); ));
auto& effect = luaEffects.back(); auto& effect = luaEffects.back();

Wyświetl plik

@ -80,21 +80,24 @@ public:
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
frequency = values[0]; frequency = values[0];
return input; return input;
}, new EffectParameter("Frequency", "frequency", VERSION_HINT, 440.0, 0.0, 12000.0, 0.1) }, new EffectParameter("Frequency", "frequency", VERSION_HINT, 440.0, 0.0, 12000.0, 0.1),
"Controls how many times per second the image is drawn, thereby controlling the pitch of the sound. Lower frequencies result in more-accurately drawn images, but more flickering, and vice versa."
); );
std::shared_ptr<Effect> volumeEffect = std::make_shared<Effect>( std::shared_ptr<Effect> volumeEffect = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
volume = values[0]; volume = values[0];
return input; return input;
}, new EffectParameter("Volume", "volume", VERSION_HINT, 1.0, 0.0, 3.0) }, new EffectParameter("Volume", "volume", VERSION_HINT, 1.0, 0.0, 3.0),
"Controls the volume of the sound. Works by scaling the image and sound by a factor."
); );
std::shared_ptr<Effect> thresholdEffect = std::make_shared<Effect>( std::shared_ptr<Effect> thresholdEffect = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
threshold = values[0]; threshold = values[0];
return input; return input;
}, new EffectParameter("Threshold", "threshold", VERSION_HINT, 1.0, 0.0, 1.0) }, new EffectParameter("Threshold", "threshold", VERSION_HINT, 1.0, 0.0, 1.0),
"Clips the sound and image to a maximum value. Applying a harsher threshold results in a more distorted sound."
); );
std::shared_ptr<Effect> focalLength = std::make_shared<Effect>( std::shared_ptr<Effect> focalLength = std::make_shared<Effect>(
@ -105,7 +108,8 @@ public:
camera->setFocalLength(values[0]); camera->setFocalLength(values[0]);
} }
return input; return input;
}, new EffectParameter("Focal length", "objFocalLength", VERSION_HINT, 1.0, 0.0, 2.0) }, new EffectParameter("Focal length", "objFocalLength", VERSION_HINT, 1.0, 0.0, 2.0),
"Controls the focal length of the camera being used to render the 3D object. A lower focal length results in a wider field of view, distorting the image, and making the image smaller."
); );
BooleanParameter* fixedRotateX = new BooleanParameter("Object Fixed Rotate X", "objFixedRotateX", VERSION_HINT, false); BooleanParameter* fixedRotateX = new BooleanParameter("Object Fixed Rotate X", "objFixedRotateX", VERSION_HINT, false);
@ -124,7 +128,8 @@ public:
} }
} }
return input; return input;
}, new EffectParameter("Rotate X", "objRotateX", VERSION_HINT, 1.0, -1.0, 1.0) }, new EffectParameter("Object Rotate X", "objRotateX", VERSION_HINT, 1.0, -1.0, 1.0),
"Controls the rotation of the 3D object around the X axis. When Object Fixed Rotate X is enabled, the object is unaffected by the rotation speed, and remains in a fixed position."
); );
std::shared_ptr<Effect> rotateY = std::make_shared<Effect>( std::shared_ptr<Effect> rotateY = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
@ -139,7 +144,8 @@ public:
} }
} }
return input; return input;
}, new EffectParameter("Rotate Y", "objRotateY", VERSION_HINT, 1.0, -1.0, 1.0) }, new EffectParameter("Object Rotate Y", "objRotateY", VERSION_HINT, 1.0, -1.0, 1.0),
"Controls the rotation of the 3D object around the Y axis. When Object Fixed Rotate Y is enabled, the object is unaffected by the rotation speed, and remains in a fixed position."
); );
std::shared_ptr<Effect> rotateZ = std::make_shared<Effect>( std::shared_ptr<Effect> rotateZ = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
@ -154,7 +160,8 @@ public:
} }
} }
return input; return input;
}, new EffectParameter("Rotate Z", "objRotateZ", VERSION_HINT, 0.0, -1.0, 1.0) }, new EffectParameter("Object Rotate Z", "objRotateZ", VERSION_HINT, 0.0, -1.0, 1.0),
"Controls the rotation of the 3D object around the Z axis. When Object Fixed Rotate Z is enabled, the object is unaffected by the rotation speed, and remains in a fixed position."
); );
std::shared_ptr<Effect> rotateSpeed = std::make_shared<Effect>( std::shared_ptr<Effect> rotateSpeed = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
@ -164,18 +171,21 @@ public:
obj->setRotationSpeed(values[0]); obj->setRotationSpeed(values[0]);
} }
return input; return input;
}, new EffectParameter("Rotate Speed", "objRotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0) }, new EffectParameter("Rotate Speed", "objRotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0),
"Controls the speed at which the 3D object rotates. A negative value results in the object rotating in the opposite direction. The rotate speed is scaled by the different Object Rotate Axis values to rotate the object."
); );
std::shared_ptr<Effect> traceMax = std::make_shared<Effect>( std::shared_ptr<Effect> traceMax = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
return input; return input;
}, new EffectParameter("Trace max", "traceMax", VERSION_HINT, 1.0, 0.0, 1.0) }, new EffectParameter("Trace max", "traceMax", VERSION_HINT, 1.0, 0.0, 1.0),
"Defines the maximum proportion of the image that is drawn before skipping to the next frame. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw until the end of the frame, so this value is 1.0."
); );
std::shared_ptr<Effect> traceMin = std::make_shared<Effect>( std::shared_ptr<Effect> traceMin = std::make_shared<Effect>(
[this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) { [this](int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
return input; return input;
}, new EffectParameter("Trace min", "traceMin", VERSION_HINT, 0.0, 0.0, 1.0) }, new EffectParameter("Trace min", "traceMin", VERSION_HINT, 0.0, 0.0, 1.0),
"Defines the proportion of the image that drawing starts from. This has the effect of 'tracing' out the image from a single dot when animated. By default, we start drawing from the beginning of the frame, so this value is 0.0."
); );
std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>(); std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();

Wyświetl plik

@ -1,21 +1,23 @@
#include "Effect.h" #include "Effect.h"
#include <numbers> #include <numbers>
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters) : Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters, juce::String description) :
effectApplication(effectApplication), effectApplication(effectApplication),
parameters(parameters), parameters(parameters),
enabled(nullptr), enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {} actualValues(std::vector<double>(parameters.size(), 0.0)),
description(description) {}
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter) : Effect(effectApplication, std::vector<EffectParameter*>{parameter}) {} Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter, juce::String description) : Effect(effectApplication, std::vector<EffectParameter*>{parameter}, description) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters) : Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters, juce::String description) :
application(application), application(application),
parameters(parameters), parameters(parameters),
enabled(nullptr), enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {} actualValues(std::vector<double>(parameters.size(), 0.0)),
description(description) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {} Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter, juce::String description) : Effect(application, std::vector<EffectParameter*>{parameter}, description) {}
Vector2 Effect::apply(int index, Vector2 input) { Vector2 Effect::apply(int index, Vector2 input) {
animateValues(); animateValues();
@ -201,3 +203,7 @@ EffectParameter* Effect::getParameter(juce::String id) {
} }
return nullptr; return nullptr;
} }
juce::String Effect::getDescription() {
return description;
}

Wyświetl plik

@ -8,10 +8,10 @@
class Effect { class Effect {
public: public:
Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters); Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters, juce::String description);
Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter); Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter, juce::String description);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters); Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters, juce::String description);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter); Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter, juce::String description);
Vector2 apply(int index, Vector2 input); Vector2 apply(int index, Vector2 input);
@ -32,6 +32,7 @@ public:
void save(juce::XmlElement* xml); void save(juce::XmlElement* xml);
void load(juce::XmlElement* xml); void load(juce::XmlElement* xml);
EffectParameter* getParameter(juce::String id); EffectParameter* getParameter(juce::String id);
juce::String getDescription();
std::vector<EffectParameter*> parameters; std::vector<EffectParameter*> parameters;
BooleanParameter* enabled; BooleanParameter* enabled;
@ -43,6 +44,7 @@ private:
int precedence = -1; int precedence = -1;
int sampleRate = 192000; int sampleRate = 192000;
std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application; std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application;
juce::String description;
std::shared_ptr<EffectApplication> effectApplication; std::shared_ptr<EffectApplication> effectApplication;

Wyświetl plik

@ -15,6 +15,8 @@ EffectComponent::EffectComponent(OscirenderAudioProcessor& p, Effect& effect, in
lfo.addItem("Reverse Sawtooth", static_cast<int>(LfoType::ReverseSawtooth)); lfo.addItem("Reverse Sawtooth", static_cast<int>(LfoType::ReverseSawtooth));
lfo.addItem("Noise", static_cast<int>(LfoType::Noise)); lfo.addItem("Noise", static_cast<int>(LfoType::Noise));
setTooltip(effect.getDescription());
effect.addListener(index, this); effect.addListener(index, this);
setupComponent(); setupComponent();
} }

Wyświetl plik

@ -4,7 +4,7 @@
#include "../audio/Effect.h" #include "../audio/Effect.h"
#include "LabelledTextBox.h" #include "LabelledTextBox.h"
class EffectComponent : public juce::Component, public juce::AudioProcessorParameter::Listener, juce::AsyncUpdater { class EffectComponent : public juce::Component, public juce::AudioProcessorParameter::Listener, juce::AsyncUpdater, public juce::SettableTooltipClient {
public: public:
EffectComponent(OscirenderAudioProcessor& p, Effect& effect, int index); EffectComponent(OscirenderAudioProcessor& p, Effect& effect, int index);
EffectComponent(OscirenderAudioProcessor& p, Effect& effect); EffectComponent(OscirenderAudioProcessor& p, Effect& effect);