2
0
Fork 0

GUI code fixes

This commit is contained in:
George Reales 2020-04-21 15:08:05 +02:00
parent 583809fd03
commit 9afc2eeceb
5 changed files with 99 additions and 30 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

After

Width:  |  Height:  |  Size: 280 KiB

View file

@ -79,6 +79,7 @@ public:
g.drawImage (kni, 0, 0, getWidth(), getHeight(), 0, h2 * ofs, w2, h2); g.drawImage (kni, 0, 0, getWidth(), getHeight(), 0, h2 * ofs, w2, h2);
} }
~Knob() override {};
private: private:
Image kni; Image kni;
int fh, numFr; int fh, numFr;

View file

@ -38,7 +38,9 @@ public:
h2 = height / 2; h2 = height / 2;
this->setClickingTogglesState (true); this->setClickingTogglesState (true);
} }
~TooglableButton() override{
};
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h // Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
public: public:
class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment

View file

@ -18,7 +18,17 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
{ {
skinFolder = ownerFilter.getCurrentSkinFolder(); skinFolder = ownerFilter.getCurrentSkinFolder();
loadSkin(processor);
//rebuildComponents (processor);
//
//clean();
repaint();
}
void ObxdAudioProcessorEditor::loadSkin(ObxdAudioProcessor& ownerFilter){
ownerFilter.removeChangeListener (this);
//File coords("/Users/jimmy/Downloads/coords.xml"); //File coords("/Users/jimmy/Downloads/coords.xml");
skinFolder = ownerFilter.getCurrentSkinFolder();
File coords = skinFolder.getChildFile ("coords.xml"); File coords = skinFolder.getChildFile ("coords.xml");
bool useClassicSkin = coords.existsAsFile(); bool useClassicSkin = coords.existsAsFile();
if (!useClassicSkin) { if (!useClassicSkin) {
@ -29,6 +39,7 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
XmlDocument skin (coords); XmlDocument skin (coords);
XmlElement* doc = skin.getDocumentElement(); XmlElement* doc = skin.getDocumentElement();
if (doc) { if (doc) {
if (doc->getTagName() == "PROPERTIES"){ if (doc->getTagName() == "PROPERTIES"){
forEachXmlChildElementWithTagName(*doc, child, "VALUE"){ forEachXmlChildElementWithTagName(*doc, child, "VALUE"){
@ -40,6 +51,8 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
int w = child->getIntAttribute("w"); int w = child->getIntAttribute("w");
int h = child->getIntAttribute("h"); int h = child->getIntAttribute("h");
if (name == "guisize"){ setSize (x, y); }
if (name == "resonanceKnob"){ resonanceKnob = addKnob (x, y, d, ownerFilter, RESONANCE, "Resonance", 0); } if (name == "resonanceKnob"){ resonanceKnob = addKnob (x, y, d, ownerFilter, RESONANCE, "Resonance", 0); }
if (name == "cutoffKnob"){ cutoffKnob = addKnob (x, y, d, ownerFilter, CUTOFF, "Cutoff", 0.4); } if (name == "cutoffKnob"){ cutoffKnob = addKnob (x, y, d, ownerFilter, CUTOFF, "Cutoff", 0.4); }
if (name == "filterEnvelopeAmtKnob"){ filterEnvelopeAmtKnob = addKnob (x, y, d, ownerFilter, ENVELOPE_AMT, "Envelope", 0); } if (name == "filterEnvelopeAmtKnob"){ filterEnvelopeAmtKnob = addKnob (x, y, d, ownerFilter, ENVELOPE_AMT, "Envelope", 0); }
@ -131,10 +144,12 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
if (name == "portamentoDetuneKnob"){ portamentoDetuneKnob = addKnob (x, y, d, ownerFilter, PORTADER, "Port", 0.2); } if (name == "portamentoDetuneKnob"){ portamentoDetuneKnob = addKnob (x, y, d, ownerFilter, PORTADER, "Port", 0.2); }
if (name == "envelopeDetuneKnob"){ envelopeDetuneKnob = addKnob (x, y, d, ownerFilter, ENVDER, "Env", 0.2); } if (name == "envelopeDetuneKnob"){ envelopeDetuneKnob = addKnob (x, y, d, ownerFilter, ENVDER, "Env", 0.2); }
if (name == "guisize"){ setSize (x, y); } if (name == "voiceSwitch"){
//if (voiceSwitch) voiceSwitch->setVisible(false);
if (name == "voiceSwitch"){ voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.png"))); } voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.png"))); }
if (name == "legatoSwitch"){ legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromFile(skinFolder.getChildFile("legato.png"))); } if (name == "legatoSwitch"){
//if (legatoSwitch) legatoSwitch->setVisible(false);
legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromFile(skinFolder.getChildFile("legato.png"))); }
//DBG(" Name: " << name << " X: " <<x <<" Y: "<<y); //DBG(" Name: " << name << " X: " <<x <<" Y: "<<y);
} }
@ -148,6 +163,7 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
for (int i = 1; i <= 32; ++i) for (int i = 1; i <= 32; ++i)
{ {
voiceSwitch->addChoice (String (i)); voiceSwitch->addChoice (String (i));
voiceSwitch ->setValue(ownerFilter.getParameter(VOICE_COUNT),dontSendNotification);
} }
} }
if (legatoSwitch) { if (legatoSwitch) {
@ -155,11 +171,12 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
legatoSwitch->addChoice ("Keep Filter Envelope"); legatoSwitch->addChoice ("Keep Filter Envelope");
legatoSwitch->addChoice ("Keep Amplitude Envelope"); legatoSwitch->addChoice ("Keep Amplitude Envelope");
legatoSwitch->addChoice ("Retrig"); legatoSwitch->addChoice ("Retrig");
legatoSwitch ->setValue(ownerFilter.getParameter(LEGATOMODE),dontSendNotification);
} }
//rebuildComponents (processor);
ownerFilter.addChangeListener (this);
repaint(); repaint();
} }
ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor() ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor()
{ {
processor.removeChangeListener (this); processor.removeChangeListener (this);
@ -197,7 +214,7 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
knob->setRange (0, 1); knob->setRange (0, 1);
addAndMakeVisible (knob); addAndMakeVisible (knob);
//addAndMakeVisible(knobl); //addAndMakeVisible(knobl);
knob->setBounds (x, y, d, d); knob->setBounds (x, y, d+(d/6), d+(d/6));
// knob->setValue (filter.getParameter (parameter), dontSendNotification); // knob->setValue (filter.getParameter (parameter), dontSendNotification);
//knobl->setJustificationType(Justification::centred); //knobl->setJustificationType(Justification::centred);
//knobl->setInterceptsMouseClicks(false,true); //knobl->setInterceptsMouseClicks(false,true);
@ -214,6 +231,51 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
return knob; return knob;
} }
void ObxdAudioProcessorEditor::clean(){
this->removeAllChildren();
/*
//knobAttachments.clearQuick(true);
//toggleAttachments.clearQuick(true);
//buttonListAttachments.clearQuick(true);
for (auto knob : {&cutoffKnob,&resonanceKnob,&osc1PitchKnob,&osc2PitchKnob,&osc2DetuneKnob,&volumeKnob, &portamentoKnob,&voiceDetuneKnob,&filterEnvelopeAmtKnob,&pulseWidthKnob,&xmodKnob,&multimodeKnob,&attackKnob,&decayKnob,&sustainKnob,&releaseKnob,
&fattackKnob,&fdecayKnob,&fsustainKnob,&freleaseKnob,&osc1MixKnob,&osc2MixKnob,&noiseMixKnob,
&filterDetuneKnob,&envelopeDetuneKnob,&portamentoDetuneKnob,
&tuneKnob,
&lfoFrequencyKnob,&lfoAmt1Knob,&lfoAmt2Knob,
&pan1Knob,&pan2Knob,&pan3Knob,&pan4Knob,&pan5Knob,&pan6Knob,&pan7Knob,&pan8Knob
}){
if (*knob){
(*knob)->deleteAllChildren();
delete *knob;
*knob = nullptr;
}
}
for (auto btn : {&osc1SawButton,&osc2SawButton,&osc1PulButton,&osc2PulButton,&filterKeyFollowButton,&unisonButton,&pitchQuantButton,
&filterHQButton,&filterBPBlendButton,
&lfoSinButton,&lfoSquareButton,&lfoSHButton,&lfoOsc1Button,&lfoOsc2Button,&lfoFilterButton,
&lfoPwm1Button,&lfoPwm2Button,
&bendRangeButton,&bendOsc2OnlyButton,
&fourPoleButton,&asPlayedAllocButton,&midiLearnButton,&midiUnlearnButton}){
if (*btn){
(*btn)->deleteAllChildren();
delete *btn;
*btn = nullptr;
}
}
for (auto list :{
&voiceSwitch,&legatoSwitch}){
if (*list){
(*list)->deleteAllChildren();
delete *list;
*list = nullptr;
}
}
*/
}
TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name) TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name)
{ {
TooglableButton* button = new TooglableButton (ImageCache::getFromFile(skinFolder.getChildFile("button.png"))); TooglableButton* button = new TooglableButton (ImageCache::getFromFile(skinFolder.getChildFile("button.png")));
@ -446,7 +508,9 @@ void ObxdAudioProcessorEditor::mouseUp(const MouseEvent& e)
const File newSkinFolder = skins.getUnchecked(result); const File newSkinFolder = skins.getUnchecked(result);
processor.setCurrentSkinFolder(newSkinFolder.getFileName()); processor.setCurrentSkinFolder(newSkinFolder.getFileName());
rebuildComponents (processor); //rebuildComponents (processor);
clean();
loadSkin(processor);
} }
else if (result >= (bankStart + 1) && result <= (bankStart + banks.size())) else if (result >= (bankStart + 1) && result <= (bankStart + banks.size()))
{ {

View file

@ -33,6 +33,7 @@ public:
ObxdAudioProcessorEditor(ObxdAudioProcessor& ownerFilter); ObxdAudioProcessorEditor(ObxdAudioProcessor& ownerFilter);
~ObxdAudioProcessorEditor(); ~ObxdAudioProcessorEditor();
void mouseUp (const MouseEvent& e) override; void mouseUp (const MouseEvent& e) override;
void paint (Graphics& g) override; void paint (Graphics& g) override;
@ -45,31 +46,32 @@ private:
TooglableButton* addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name); TooglableButton* addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name);
ButtonList* addList(int x, int y, int w, int h, ObxdAudioProcessor& filter, int parameter, String name, Image img); ButtonList* addList(int x, int y, int w, int h, ObxdAudioProcessor& filter, int parameter, String name, Image img);
//Menu* addMenu (int x, int y); //Menu* addMenu (int x, int y);
void clean();
void rebuildComponents (ObxdAudioProcessor&); void rebuildComponents (ObxdAudioProcessor&);
void loadSkin(ObxdAudioProcessor&);
//============================================================================== //==============================================================================
ObxdAudioProcessor& processor; ObxdAudioProcessor& processor;
//============================================================================== //==============================================================================
Knob* cutoffKnob,*resonanceKnob,*osc1PitchKnob,*osc2PitchKnob,*osc2DetuneKnob,*volumeKnob, Knob* cutoffKnob=nullptr, *resonanceKnob=nullptr, *osc1PitchKnob=nullptr, *osc2PitchKnob=nullptr, *osc2DetuneKnob=nullptr, *volumeKnob,
*portamentoKnob,*voiceDetuneKnob,*filterEnvelopeAmtKnob,*pulseWidthKnob,*xmodKnob,*multimodeKnob,*attackKnob,*decayKnob,*sustainKnob,*releaseKnob, *portamentoKnob=nullptr, *voiceDetuneKnob=nullptr, *filterEnvelopeAmtKnob=nullptr, *pulseWidthKnob=nullptr, *xmodKnob=nullptr, *multimodeKnob=nullptr, *attackKnob=nullptr, *decayKnob=nullptr, *sustainKnob=nullptr, *releaseKnob=nullptr,
*fattackKnob,*fdecayKnob,*fsustainKnob,*freleaseKnob,*osc1MixKnob,*osc2MixKnob,*noiseMixKnob, *fattackKnob=nullptr, *fdecayKnob=nullptr, *fsustainKnob=nullptr, *freleaseKnob=nullptr, *osc1MixKnob=nullptr, *osc2MixKnob=nullptr, *noiseMixKnob=nullptr,
*filterDetuneKnob,*envelopeDetuneKnob,*portamentoDetuneKnob, *filterDetuneKnob=nullptr, *envelopeDetuneKnob=nullptr, *portamentoDetuneKnob=nullptr,
*tuneKnob, *tuneKnob=nullptr,
*lfoFrequencyKnob,*lfoAmt1Knob,*lfoAmt2Knob, *lfoFrequencyKnob=nullptr, *lfoAmt1Knob=nullptr, *lfoAmt2Knob=nullptr,
*pan1Knob,*pan2Knob,*pan3Knob,*pan4Knob,*pan5Knob,*pan6Knob,*pan7Knob,*pan8Knob, *pan1Knob=nullptr, *pan2Knob=nullptr, *pan3Knob=nullptr, *pan4Knob=nullptr, *pan5Knob=nullptr, *pan6Knob=nullptr, *pan7Knob=nullptr, *pan8Knob=nullptr,
*brightnessKnob,*envPitchModKnob, *brightnessKnob=nullptr, *envPitchModKnob=nullptr,
*bendLfoRateKnob,*veloAmpEnvKnob,*veloFltEnvKnob,*transposeKnob; *bendLfoRateKnob=nullptr, *veloAmpEnvKnob=nullptr, *veloFltEnvKnob=nullptr, *transposeKnob=nullptr;
TooglableButton* hardSyncButton,*osc1SawButton,*osc2SawButton,*osc1PulButton,*osc2PulButton,*filterKeyFollowButton,*unisonButton,*pitchQuantButton, TooglableButton* hardSyncButton=nullptr, *osc1SawButton=nullptr, *osc2SawButton=nullptr, *osc1PulButton=nullptr, *osc2PulButton=nullptr, *filterKeyFollowButton=nullptr, *unisonButton=nullptr, *pitchQuantButton=nullptr,
*filterHQButton,*filterBPBlendButton, *filterHQButton=nullptr, *filterBPBlendButton=nullptr,
*lfoSinButton,*lfoSquareButton,*lfoSHButton,*lfoOsc1Button,*lfoOsc2Button,*lfoFilterButton, *lfoSinButton=nullptr, *lfoSquareButton=nullptr, *lfoSHButton=nullptr, *lfoOsc1Button=nullptr, *lfoOsc2Button=nullptr, *lfoFilterButton,
*lfoPwm1Button,*lfoPwm2Button, *lfoPwm1Button=nullptr, *lfoPwm2Button=nullptr,
*bendRangeButton,*bendOsc2OnlyButton, *bendRangeButton=nullptr, *bendOsc2OnlyButton=nullptr,
*fourPoleButton,*asPlayedAllocButton,*midiLearnButton,*midiUnlearnButton; *fourPoleButton=nullptr, *asPlayedAllocButton=nullptr, *midiLearnButton=nullptr, *midiUnlearnButton=nullptr;
ButtonList *voiceSwitch,*legatoSwitch; ButtonList *voiceSwitch = nullptr,*legatoSwitch = nullptr;
File skinFolder; File skinFolder;