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);
}
~Knob() override {};
private:
Image kni;
int fh, numFr;

View file

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

View file

@ -18,7 +18,17 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
{
skinFolder = ownerFilter.getCurrentSkinFolder();
loadSkin(processor);
//rebuildComponents (processor);
//
//clean();
repaint();
}
void ObxdAudioProcessorEditor::loadSkin(ObxdAudioProcessor& ownerFilter){
ownerFilter.removeChangeListener (this);
//File coords("/Users/jimmy/Downloads/coords.xml");
skinFolder = ownerFilter.getCurrentSkinFolder();
File coords = skinFolder.getChildFile ("coords.xml");
bool useClassicSkin = coords.existsAsFile();
if (!useClassicSkin) {
@ -29,6 +39,7 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
XmlDocument skin (coords);
XmlElement* doc = skin.getDocumentElement();
if (doc) {
if (doc->getTagName() == "PROPERTIES"){
forEachXmlChildElementWithTagName(*doc, child, "VALUE"){
@ -40,6 +51,8 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
int w = child->getIntAttribute("w");
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 == "cutoffKnob"){ cutoffKnob = addKnob (x, y, d, ownerFilter, CUTOFF, "Cutoff", 0.4); }
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 == "envelopeDetuneKnob"){ envelopeDetuneKnob = addKnob (x, y, d, ownerFilter, ENVDER, "Env", 0.2); }
if (name == "guisize"){ setSize (x, y); }
if (name == "voiceSwitch"){ 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 == "voiceSwitch"){
//if (voiceSwitch) voiceSwitch->setVisible(false);
voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.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);
}
@ -148,6 +163,7 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
for (int i = 1; i <= 32; ++i)
{
voiceSwitch->addChoice (String (i));
voiceSwitch ->setValue(ownerFilter.getParameter(VOICE_COUNT),dontSendNotification);
}
}
if (legatoSwitch) {
@ -155,11 +171,12 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
legatoSwitch->addChoice ("Keep Filter Envelope");
legatoSwitch->addChoice ("Keep Amplitude Envelope");
legatoSwitch->addChoice ("Retrig");
}
//rebuildComponents (processor);
repaint();
legatoSwitch ->setValue(ownerFilter.getParameter(LEGATOMODE),dontSendNotification);
}
ownerFilter.addChangeListener (this);
repaint();
}
ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor()
{
processor.removeChangeListener (this);
@ -197,7 +214,7 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
knob->setRange (0, 1);
addAndMakeVisible (knob);
//addAndMakeVisible(knobl);
knob->setBounds (x, y, d, d);
knob->setBounds (x, y, d+(d/6), d+(d/6));
// knob->setValue (filter.getParameter (parameter), dontSendNotification);
//knobl->setJustificationType(Justification::centred);
//knobl->setInterceptsMouseClicks(false,true);
@ -214,6 +231,51 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
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* 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);
processor.setCurrentSkinFolder(newSkinFolder.getFileName());
rebuildComponents (processor);
//rebuildComponents (processor);
clean();
loadSkin(processor);
}
else if (result >= (bankStart + 1) && result <= (bankStart + banks.size()))
{

View file

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