From f52aedeb7dc91933d72ffeb63294ca6f1c82a4f4 Mon Sep 17 00:00:00 2001 From: George Reales Date: Mon, 17 May 2021 19:52:09 +0200 Subject: [PATCH] Preset bar flicker fix --- Source/Components/PresetBar.cpp | 0 Source/PluginEditor.cpp | 48 +++++++++++++++++++++++---------- Source/PluginEditor.h | 2 +- Source/PluginProcessor.cpp | 2 ++ 4 files changed, 37 insertions(+), 15 deletions(-) mode change 100644 => 100755 Source/Components/PresetBar.cpp diff --git a/Source/Components/PresetBar.cpp b/Source/Components/PresetBar.cpp old mode 100644 new mode 100755 diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 69104ea..0dcc269 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -105,9 +105,9 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter) setSize (1440, 450); } else { - + int xScreen = getWidth(), yScreen = getHeight(); if (doc->getTagName() == "PROPERTIES"){ - + forEachXmlChildElementWithTagName(*doc, child, "VALUE"){ if (child->hasAttribute("NAME") && child->hasAttribute("x") && child->hasAttribute("y")) { String name = child->getStringAttribute("NAME"); @@ -117,7 +117,17 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter) int w = child->getIntAttribute("w"); 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 == "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 @@ -269,12 +290,7 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter) 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(); } ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor() @@ -565,17 +581,21 @@ void ObxdAudioProcessorEditor::resultFromMenu (const Point pos) } } -void ObxdAudioProcessorEditor::updatePresetBar(){ +void ObxdAudioProcessorEditor::updatePresetBar(bool resize){ DBG(" H: " << getHeight() <<" W:" <getWidth() << " CH" <getHeight() << " CX:" <getX() << " CY: " <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); } else if (presetBar->isVisible()) { - this->setSize(this->getWidth(), this->getHeight() - 40); + if (resize) { + this->setSize(this->getWidth(), this->getHeight() - 40); + } presetBar->setVisible(false); } - presetBar->update(); } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index a493a25..f0f5082 100755 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -72,7 +72,7 @@ public: String getCurrentProgramName(){ return processor.getProgramName(processor.getCurrentProgram()); } - void updatePresetBar(); + void updatePresetBar(bool resize=true); //============================================================================== void changeListenerCallback (ChangeBroadcaster* source) override; void buttonClicked (Button *) override; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 8061888..7113118 100755 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -533,12 +533,14 @@ bool ObxdAudioProcessor::saveFXPFile(const File& fxpFile){ fxpFile.replaceWithData(memoryBlock.getData(), memoryBlock.getSize()); } + return true; } bool ObxdAudioProcessor::savePreset(const File& fxpFile) { saveFXPFile(fxpFile); currentPreset = fxpFile.getFileName(); currentPresetFile = fxpFile; + return true; } void ObxdAudioProcessor::changePresetName(const String &name){