Skip to content

Commit

Permalink
Fix creating new presets in VST3
Browse files Browse the repository at this point in the history
  • Loading branch information
FigBug committed Sep 6, 2023
1 parent 99a3942 commit f584c7c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions modules/gin_plugin/components/gin_plugineditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ TitleBar::TitleBar (ProcessorEditor& e, Processor& p)
nextButton.onClick = [this]
{
int prog = slProc.getCurrentProgram() + 1;
if (prog >= slProc.getNumPrograms())
if (prog >= slProc.getPrograms().size())
prog = 0;

slProc.setCurrentProgram (prog);
Expand All @@ -215,7 +215,7 @@ TitleBar::TitleBar (ProcessorEditor& e, Processor& p)
{
int prog = slProc.getCurrentProgram() - 1;
if (prog < 0)
prog = slProc.getNumPrograms() - 1;
prog = slProc.getPrograms().size() - 1;

slProc.setCurrentProgram (prog);
};
Expand Down Expand Up @@ -376,8 +376,8 @@ void TitleBar::resized()

if (hasPresets)
{
prevButton.setBounds (programsRC.removeFromLeft (programsRC.getHeight()).withSizeKeepingCentre (8, 8));
nextButton.setBounds (programsRC.removeFromRight (programsRC.getHeight()).withSizeKeepingCentre (8, 8));
prevButton.setBounds (programsRC.removeFromLeft (programsRC.getHeight()).withSizeKeepingCentre (12, 12));
nextButton.setBounds (programsRC.removeFromRight (programsRC.getHeight()).withSizeKeepingCentre (12, 12));
}
else
{
Expand All @@ -393,7 +393,7 @@ void TitleBar::refreshPrograms()
{
programs.clear();

for (int i = 0; i < slProc.getNumPrograms(); i++)
for (int i = 0; i < slProc.getPrograms().size(); i++)
programs.addItem (slProc.getProgramName (i), i + 1);

programs.setSelectedItemIndex (slProc.getCurrentProgram(), juce::dontSendNotification);
Expand Down
4 changes: 2 additions & 2 deletions modules/gin_plugin/components/gin_plugineditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class TitleBar : public juce::Component,
SVGButton addButton { "add", gin::Assets::add };
SVGButton deleteButton { "delete", gin::Assets::del };
SVGButton browseButton { "browse", gin::Assets::browse };
SVGButton nextButton { "next", gin::Assets::next };
SVGButton prevButton { "prev", gin::Assets::prev };
SVGButton nextButton { "next", gin::Assets::next, 4 };
SVGButton prevButton { "prev", gin::Assets::prev, 4 };

SVGButton menuButton { "menu", gin::Assets::menu };
SVGButton infoButton { "info", gin::Assets::info };
Expand Down
11 changes: 7 additions & 4 deletions modules/gin_plugin/plugin/gin_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ double Processor::getTailLengthSeconds() const

int Processor::getNumPrograms()
{
return programs.size();
if (maxPrograms == 0)
maxPrograms = programs.size() + 50;

return maxPrograms;
}

int Processor::getCurrentProgram()
Expand Down Expand Up @@ -255,8 +258,8 @@ const juce::String Processor::getProgramName (int index)
{
if (auto p = programs[index])
return p->name;
return {};

return "----";
}

bool Processor::hasProgram (juce::String name)
Expand All @@ -281,7 +284,7 @@ void Processor::changeProgramName (int index, const juce::String& newName)
void Processor::loadAllPrograms()
{
updateState();

programs.clear();

// create the default program
Expand Down
1 change: 1 addition & 0 deletions modules/gin_plugin/plugin/gin_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Processor : public ProcessorBaseClass,
void updateParams();

int currentProgram = 0;
int maxPrograms = 0;
juce::OwnedArray<Program> programs;

juce::Time lastStateLoad;
Expand Down

0 comments on commit f584c7c

Please sign in to comment.