2
0
Fork 0

Preset bar flicker fix

This commit is contained in:
George Reales 2021-05-17 19:52:09 +02:00
parent 48849a96d8
commit f52aedeb7d
4 changed files with 37 additions and 15 deletions

0
Source/Components/PresetBar.cpp Normal file → Executable file
View File

View File

@ -105,9 +105,9 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
setSize (1440, 450); setSize (1440, 450);
} }
else { else {
int xScreen = getWidth(), yScreen = getHeight();
if (doc->getTagName() == "PROPERTIES"){ if (doc->getTagName() == "PROPERTIES"){
forEachXmlChildElementWithTagName(*doc, child, "VALUE"){ forEachXmlChildElementWithTagName(*doc, child, "VALUE"){
if (child->hasAttribute("NAME") && child->hasAttribute("x") && child->hasAttribute("y")) { if (child->hasAttribute("NAME") && child->hasAttribute("x") && child->hasAttribute("y")) {
String name = child->getStringAttribute("NAME"); String name = child->getStringAttribute("NAME");
@ -117,7 +117,17 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
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 == "guisize"){
xScreen = x;
yScreen = y;
if (processor.getShowPresetBar()) {
setSize(xScreen, yScreen +40);
}
else {
setSize(xScreen, yScreen);
}
}
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); }
@ -241,6 +251,17 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
} }
} }
} }
presetBar.reset(new PresetBar(*this));
addAndMakeVisible(*presetBar);
presetBar->setVisible(processor.getShowPresetBar());
presetBar->setBounds(
(xScreen - presetBar->getWidth()) / 2, yScreen, presetBar->getWidth(), presetBar->getHeight());
updatePresetBar(false);
} }
// Prepare data // Prepare data
@ -269,12 +290,7 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
ownerFilter.addChangeListener (this); ownerFilter.addChangeListener (this);
presetBar.reset(new PresetBar(*this));
addAndMakeVisible(*presetBar);
presetBar->setVisible(processor.getShowPresetBar());
presetBar->setBounds(
(getWidth() - presetBar->getWidth())/2, getHeight(), presetBar->getWidth(), presetBar->getHeight());
updatePresetBar();
repaint(); repaint();
} }
ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor() ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor()
@ -565,17 +581,21 @@ void ObxdAudioProcessorEditor::resultFromMenu (const Point<int> pos)
} }
} }
void ObxdAudioProcessorEditor::updatePresetBar(){ void ObxdAudioProcessorEditor::updatePresetBar(bool resize){
DBG(" H: " << getHeight() <<" W:" <<getWidth() << " CW:"<<presetBar->getWidth() << " CH" <<presetBar->getHeight() << " CX:" <<presetBar->getX() << " CY: " <<presetBar->getY()); DBG(" H: " << getHeight() <<" W:" <<getWidth() << " CW:"<<presetBar->getWidth() << " CH" <<presetBar->getHeight() << " CX:" <<presetBar->getX() << " CY: " <<presetBar->getY());
if (processor.getShowPresetBar()){
this->setSize(this->getWidth(), this->getHeight() + 40); if (processor.getShowPresetBar()) {
if (resize) {
this->setSize(this->getWidth(), this->getHeight() + 40);
}
presetBar->setVisible(true); presetBar->setVisible(true);
} }
else if (presetBar->isVisible()) { else if (presetBar->isVisible()) {
this->setSize(this->getWidth(), this->getHeight() - 40); if (resize) {
this->setSize(this->getWidth(), this->getHeight() - 40);
}
presetBar->setVisible(false); presetBar->setVisible(false);
} }
presetBar->update(); presetBar->update();
} }

View File

@ -72,7 +72,7 @@ public:
String getCurrentProgramName(){ String getCurrentProgramName(){
return processor.getProgramName(processor.getCurrentProgram()); return processor.getProgramName(processor.getCurrentProgram());
} }
void updatePresetBar(); void updatePresetBar(bool resize=true);
//============================================================================== //==============================================================================
void changeListenerCallback (ChangeBroadcaster* source) override; void changeListenerCallback (ChangeBroadcaster* source) override;
void buttonClicked (Button *) override; void buttonClicked (Button *) override;

View File

@ -533,12 +533,14 @@ bool ObxdAudioProcessor::saveFXPFile(const File& fxpFile){
fxpFile.replaceWithData(memoryBlock.getData(), memoryBlock.getSize()); fxpFile.replaceWithData(memoryBlock.getData(), memoryBlock.getSize());
} }
return true;
} }
bool ObxdAudioProcessor::savePreset(const File& fxpFile) { bool ObxdAudioProcessor::savePreset(const File& fxpFile) {
saveFXPFile(fxpFile); saveFXPFile(fxpFile);
currentPreset = fxpFile.getFileName(); currentPreset = fxpFile.getFileName();
currentPresetFile = fxpFile; currentPresetFile = fxpFile;
return true;
} }
void ObxdAudioProcessor::changePresetName(const String &name){ void ObxdAudioProcessor::changePresetName(const String &name){