kopia lustrzana https://github.com/jameshball/osci-render
WIP renaming of sliders
rodzic
49af99ebfe
commit
98e81aa549
|
@ -332,6 +332,7 @@ public:
|
|||
BooleanParameter* sidechain = new BooleanParameter(name + " Sidechain Enabled", paramID + "Sidechain", getVersionHint(), false, "Toggles " + name + " Sidechain.");
|
||||
std::atomic<float> phase = 0.0f;
|
||||
juce::String description;
|
||||
juce::String alias = name;
|
||||
|
||||
std::vector<juce::AudioProcessorParameter*> getParameters() {
|
||||
std::vector<juce::AudioProcessorParameter*> parameters;
|
||||
|
@ -362,6 +363,7 @@ public:
|
|||
|
||||
void save(juce::XmlElement* xml) {
|
||||
FloatParameter::save(xml);
|
||||
xml->setAttribute("alias", alias);
|
||||
|
||||
if (lfo != nullptr && lfoRate != nullptr) {
|
||||
auto lfoXml = xml->createNewChildElement("lfo");
|
||||
|
@ -377,6 +379,9 @@ public:
|
|||
|
||||
void load(juce::XmlElement* xml) {
|
||||
FloatParameter::load(xml);
|
||||
if (xml->hasAttribute("alias")) {
|
||||
alias = xml->getStringAttribute("alias");
|
||||
}
|
||||
|
||||
if (lfo != nullptr && lfoRate != nullptr) {
|
||||
auto lfoXml = xml->getChildByName("lfo");
|
||||
|
|
|
@ -54,7 +54,7 @@ void EffectComponent::setupComponent() {
|
|||
setEnabled(effect.enabled == nullptr || effect.enabled->getBoolValue());
|
||||
|
||||
setTooltip(parameter->description);
|
||||
label.setText(parameter->name, juce::dontSendNotification);
|
||||
label.setText(parameter->alias, juce::dontSendNotification);
|
||||
label.setInterceptsMouseClicks(false, false);
|
||||
|
||||
slider.setRange(parameter->min, parameter->max, parameter->step);
|
||||
|
@ -158,6 +158,39 @@ void EffectComponent::paint(juce::Graphics& g) {
|
|||
g.fillPath(path);
|
||||
}
|
||||
|
||||
void EffectComponent::paintOverChildren(juce::Graphics& g) {
|
||||
auto b = label.getBounds();
|
||||
if (mouseOverLabel && onClick != nullptr) {
|
||||
g.setColour(juce::Colours::black.withAlpha(0.2f));
|
||||
juce::Path path;
|
||||
path.addRoundedRectangle(b.getX(), b.getY(), b.getWidth(), b.getHeight(), OscirenderLookAndFeel::RECT_RADIUS);
|
||||
g.fillPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComponent::mouseMove(const juce::MouseEvent& e) {
|
||||
if (label.getBounds().contains(e.getPosition())) {
|
||||
setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
mouseOverLabel = true;
|
||||
repaint();
|
||||
} else {
|
||||
setMouseCursor(juce::MouseCursor::NormalCursor);
|
||||
mouseOverLabel = false;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComponent::mouseDown(const juce::MouseEvent& e) {
|
||||
if (label.getBounds().contains(e.getPosition())) {
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComponent::mouseExit(const juce::MouseEvent& e) {
|
||||
mouseOverLabel = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void EffectComponent::parameterValueChanged(int parameterIndex, float newValue) {
|
||||
triggerAsyncUpdate();
|
||||
}
|
||||
|
@ -184,3 +217,7 @@ void EffectComponent::setSliderOnValueChange() {
|
|||
effect.setValue(index, slider.getValue());
|
||||
};
|
||||
}
|
||||
|
||||
void EffectComponent::setOnClick(std::function<void()> onClick) {
|
||||
this->onClick = onClick;
|
||||
}
|
||||
|
|
|
@ -13,15 +13,21 @@ public:
|
|||
|
||||
void resized() override;
|
||||
void paint(juce::Graphics& g) override;
|
||||
void mouseMove(const juce::MouseEvent& e) override;
|
||||
void mouseExit(const juce::MouseEvent& e) override;
|
||||
void mouseDown(const juce::MouseEvent& e) override;
|
||||
void paintOverChildren(juce::Graphics& g) override;
|
||||
void parameterValueChanged(int parameterIndex, float newValue) override;
|
||||
void parameterGestureChanged(int parameterIndex, bool gestureIsStarting) override;
|
||||
void handleAsyncUpdate() override;
|
||||
|
||||
void setComponent(std::shared_ptr<juce::Component> component);
|
||||
void setSliderOnValueChange();
|
||||
void setOnClick(std::function<void()> onClick);
|
||||
|
||||
juce::Slider slider;
|
||||
juce::Slider lfoSlider;
|
||||
juce::Label label;
|
||||
Effect& effect;
|
||||
int index = 0;
|
||||
juce::ComboBox lfo;
|
||||
|
@ -90,11 +96,12 @@ private:
|
|||
bool sidechainEnabled = true;
|
||||
std::shared_ptr<juce::Component> component;
|
||||
OscirenderAudioProcessor& audioProcessor;
|
||||
|
||||
bool mouseOverLabel = false;
|
||||
std::function<void()> onClick;
|
||||
|
||||
std::unique_ptr<SvgButton> sidechainButton;
|
||||
|
||||
juce::Label label;
|
||||
|
||||
SvgButton rangeButton = { "rangeButton", BinaryData::range_svg, juce::Colours::white };
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectComponent)
|
||||
|
|
|
@ -6,6 +6,12 @@ LuaListComponent::LuaListComponent(OscirenderAudioProcessor& p, Effect& effect)
|
|||
effectComponent->slider.onValueChange = [this, &effect, &p] {
|
||||
effect.setValue(effectComponent->slider.getValue());
|
||||
};
|
||||
|
||||
effectComponent->setOnClick([this] () {
|
||||
auto rename = std::make_unique<RenameEffectComponent>(effectComponent.get());
|
||||
rename->setSize(250, 110);
|
||||
auto& myBox = juce::CallOutBox::launchAsynchronously(std::move(rename), effectComponent->label.getScreenBounds(), nullptr);
|
||||
});
|
||||
|
||||
addAndMakeVisible(*effectComponent);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,58 @@ public:
|
|||
protected:
|
||||
std::shared_ptr<EffectComponent> effectComponent;
|
||||
private:
|
||||
|
||||
class RenameEffectComponent : public juce::Component {
|
||||
public:
|
||||
RenameEffectComponent(EffectComponent* parent) {
|
||||
addAndMakeVisible(staticName);
|
||||
addAndMakeVisible(aliasLabel);
|
||||
addAndMakeVisible(alias);
|
||||
addAndMakeVisible(variableLabel);
|
||||
addAndMakeVisible(variableName);
|
||||
|
||||
staticName.setJustificationType(juce::Justification::centred);
|
||||
aliasLabel.setJustificationType(juce::Justification::right);
|
||||
variableLabel.setJustificationType(juce::Justification::right);
|
||||
|
||||
aliasLabel.setText("Alias", juce::dontSendNotification);
|
||||
variableLabel.setText("Variable Name", juce::dontSendNotification);
|
||||
|
||||
juce::Font font = juce::Font(13.0f);
|
||||
staticName.setFont(font);
|
||||
aliasLabel.setFont(font);
|
||||
variableLabel.setFont(font);
|
||||
|
||||
staticName.setText(parent->effect.getName(), juce::dontSendNotification);
|
||||
alias.setText(parent->effect.parameters[parent->index]->alias, juce::dontSendNotification);
|
||||
// variableName.setText(parent->effect.parameters[parent->index]->, juce::dontSendNotification);
|
||||
|
||||
alias.onTextChange = [parent, this] {
|
||||
parent->effect.parameters[parent->index]->alias = alias.getText();
|
||||
parent->label.setText(alias.getText(), juce::dontSendNotification);
|
||||
};
|
||||
}
|
||||
|
||||
void resized() override {
|
||||
auto bounds = getLocalBounds();
|
||||
staticName.setBounds(bounds.removeFromTop(30));
|
||||
auto aliasRow = bounds.removeFromTop(30);
|
||||
aliasLabel.setBounds(aliasRow.removeFromLeft(90));
|
||||
alias.setBounds(aliasRow);
|
||||
bounds.removeFromTop(10);
|
||||
auto variableRow = bounds.removeFromTop(30);
|
||||
variableLabel.setBounds(variableRow.removeFromLeft(90));
|
||||
variableName.setBounds(variableRow);
|
||||
}
|
||||
|
||||
private:
|
||||
juce::Label staticName;
|
||||
juce::Label aliasLabel;
|
||||
juce::TextEditor alias;
|
||||
juce::Label variableLabel;
|
||||
juce::TextEditor variableName;
|
||||
};
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LuaListComponent)
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue