MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ButtonClicked

Method ButtonClicked

Source/VSTPlugin.cpp:1080–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1078}
1079
1080void VSTPlugin::ButtonClicked(ClickButton* button, double time)
1081{
1082 if (button == mOpenEditorButton)
1083 mWantOpenVstWindow = true;
1084
1085 if (button == mPanicButton)
1086 {
1087 mWantsPanic = true;
1088 }
1089
1090 if (button == mSavePresetFileButton && mPlugin != nullptr)
1091 {
1092 juce::File(ofToDataPath("vst/presets/" + GetPluginId())).createDirectory();
1093 FileChooser chooser("Save preset as...", File(ofToDataPath("vst/presets/" + GetPluginId() + "/preset.vstp")), "*.vstp", true, false, TheSynth->GetFileChooserParent());
1094 if (chooser.browseForFileToSave(true))
1095 {
1096 std::string path = chooser.getResult().getFullPathName().toStdString();
1097
1098 File resourceFile(path);
1099 TemporaryFile tempFile(resourceFile);
1100
1101 {
1102 FileOutputStream output(tempFile.getFile());
1103
1104 if (!output.openedOk())
1105 {
1106 DBG("FileOutputStream didn't open correctly ...");
1107 return;
1108 }
1109
1110 juce::MemoryBlock vstState;
1111 mPlugin->getStateInformation(vstState);
1112 juce::MemoryBlock vstProgramState;
1113 mPlugin->getCurrentProgramStateInformation(vstProgramState);
1114
1115 output.writeInt(GetModuleSaveStateRev());
1116 output.writeInt64(vstState.getSize());
1117 output.write(vstState.getData(), vstState.getSize());
1118 output.writeInt64(vstProgramState.getSize());
1119 if (vstProgramState.getSize() > 0)
1120 output.write(vstProgramState.getData(), vstProgramState.getSize());
1121
1122 std::vector<int> exposedParams;
1123 for (int i = 0; i < (int)mParameterSliders.size(); ++i)
1124 {
1125 if (mParameterSliders[i].mShowing)
1126 exposedParams.push_back(i);
1127 }
1128 output.writeInt((int)exposedParams.size());
1129 for (int i : exposedParams)
1130 output.writeInt(i);
1131
1132 output.flush(); // (called explicitly to force an fsync on posix)
1133
1134 if (output.getStatus().failed())
1135 {
1136 DBG("An error occurred in the FileOutputStream");
1137 return;

Callers

nothing calls this directly

Calls 3

ofToDataPathFunction · 0.85
GetFileChooserParentMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected