GUI refresh fix
This commit is contained in:
parent
d73fcd8490
commit
29579de1c3
5 changed files with 56 additions and 13 deletions
|
@ -40,19 +40,29 @@ public:
|
|||
public:
|
||||
class ButtonListAttachment : public juce::AudioProcessorValueTreeState::ComboBoxAttachment
|
||||
{
|
||||
RangedAudioParameter* parameter = nullptr;
|
||||
ButtonList* buttonListToControl = nullptr;
|
||||
public:
|
||||
ButtonListAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
ButtonList& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl)
|
||||
ButtonList& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl), buttonListToControl(&buttonListToControl)
|
||||
{
|
||||
buttonListToControl.setParameter (stateToControl.getParameter (parameterID));
|
||||
parameter = stateToControl.getParameter (parameterID);
|
||||
buttonListToControl.setParameter (parameter);
|
||||
}
|
||||
|
||||
/*
|
||||
ButtonListAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
ComboBox& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl)
|
||||
{
|
||||
}
|
||||
*/
|
||||
void updateToSlider(){
|
||||
float val = parameter->getValue();
|
||||
buttonListToControl->setValue(val, NotificationType::dontSendNotification);
|
||||
//buttonListToControl->setValue(parameter->convertFrom0to1(val0to1), NotificationType::dontSendNotification);
|
||||
buttonListToControl->setValue(val, NotificationType::dontSendNotification);
|
||||
}
|
||||
|
||||
virtual ~ButtonListAttachment() = default;
|
||||
};
|
||||
|
|
|
@ -46,24 +46,35 @@ public:
|
|||
public:
|
||||
class KnobAttachment : public juce::AudioProcessorValueTreeState::SliderAttachment
|
||||
{
|
||||
RangedAudioParameter* parameter = nullptr;
|
||||
Knob* sliderToControl = nullptr;
|
||||
public:
|
||||
KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
Knob& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl)
|
||||
Knob& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl), sliderToControl(&sliderToControl)
|
||||
{
|
||||
sliderToControl.setParameter (stateToControl.getParameter (parameterID));
|
||||
parameter = stateToControl.getParameter (parameterID);
|
||||
sliderToControl.setParameter (parameter);
|
||||
}
|
||||
|
||||
KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
|
||||
/*KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
Slider& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl)
|
||||
{
|
||||
}*/
|
||||
|
||||
void updateToSlider(){
|
||||
float val = parameter->getValue();
|
||||
//sliderToControl->setValue(parameter->convertFrom0to1(val0to1));
|
||||
sliderToControl->setValue(val, NotificationType::dontSendNotification);
|
||||
DBG(" Slider: " << sliderToControl->getName() << " " << sliderToControl->getValue() << " Parameter: "<< " " << parameter->getValue());
|
||||
}
|
||||
|
||||
virtual ~KnobAttachment() = default;
|
||||
};
|
||||
|
||||
void setParameter (const AudioProcessorParameter* p)
|
||||
void setParameter (AudioProcessorParameter* p)
|
||||
{
|
||||
if (parameter == p)
|
||||
return;
|
||||
|
@ -84,5 +95,5 @@ private:
|
|||
Image kni;
|
||||
int fh, numFr;
|
||||
int w2, h2;
|
||||
const AudioProcessorParameter* parameter {nullptr};
|
||||
AudioProcessorParameter* parameter {nullptr};
|
||||
};
|
||||
|
|
|
@ -45,20 +45,26 @@ public:
|
|||
public:
|
||||
class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment
|
||||
{
|
||||
RangedAudioParameter* parameter = nullptr;
|
||||
TooglableButton* buttonToControl = nullptr;
|
||||
public:
|
||||
ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
TooglableButton& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl)
|
||||
TooglableButton& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl), buttonToControl(&buttonToControl)
|
||||
{
|
||||
buttonToControl.setParameter (stateToControl.getParameter (parameterID));
|
||||
parameter = stateToControl.getParameter (parameterID);
|
||||
buttonToControl.setParameter (parameter);
|
||||
}
|
||||
|
||||
/*
|
||||
ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
||||
const juce::String& parameterID,
|
||||
Button& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl)
|
||||
{
|
||||
}*/
|
||||
void updateToSlider(){
|
||||
float val = parameter->getValue();
|
||||
//buttonToControl->setValue(parameter->convertFrom0to1(val0to1), NotificationType::dontSendNotification);
|
||||
}
|
||||
|
||||
virtual ~ToggleAttachment() = default;
|
||||
};
|
||||
|
||||
|
|
|
@ -442,6 +442,18 @@ void ObxdAudioProcessorEditor::rebuildComponents (ObxdAudioProcessor& ownerFilte
|
|||
//==============================================================================
|
||||
void ObxdAudioProcessorEditor::changeListenerCallback (ChangeBroadcaster* source)
|
||||
{
|
||||
|
||||
for (int i = 0; i < knobAttachments.size(); i++){
|
||||
knobAttachments[i]->updateToSlider();
|
||||
}
|
||||
|
||||
for (int i = 0; i < toggleAttachments.size(); i++){
|
||||
toggleAttachments[i]->updateToSlider();
|
||||
}
|
||||
|
||||
for (int i = 0; i < buttonListAttachments.size(); i++){
|
||||
buttonListAttachments[i]->updateToSlider();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -415,6 +415,7 @@ void ObxdAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
|
|||
|
||||
setCurrentProgram(xmlState->getIntAttribute(S("currentProgram"), 0));
|
||||
|
||||
sendChangeMessage();
|
||||
#if JUCE_VERSION <= JUCE_543
|
||||
delete xmlState;
|
||||
#endif
|
||||
|
@ -443,7 +444,8 @@ void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data, in
|
|||
programs.currentProgramPtr->name = e->getStringAttribute(S("programName"), S("Default"));
|
||||
|
||||
setCurrentProgram(programs.currentProgram);
|
||||
|
||||
|
||||
sendChangeMessage();
|
||||
#if JUCE_VERSION <= JUCE_543
|
||||
delete e;
|
||||
#endif
|
||||
|
@ -740,6 +742,8 @@ void ObxdAudioProcessor::setEngineParameterValue (int index, float newValue)
|
|||
}
|
||||
|
||||
programs.currentProgramPtr->values[index] = newValue;
|
||||
apvtState.getParameter(getEngineParameterId(index))->setValue(newValue);
|
||||
|
||||
|
||||
switch (index)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue