| 2755 | } |
| 2756 | |
| 2757 | IDrawableModule* ModularSynth::DuplicateModule(IDrawableModule* module) |
| 2758 | { |
| 2759 | juce::MemoryBlock block; |
| 2760 | { |
| 2761 | FileStreamOut out(block); |
| 2762 | module->SaveState(out); |
| 2763 | } |
| 2764 | |
| 2765 | ofxJSONElement layoutData; |
| 2766 | module->SaveLayoutBase(layoutData); |
| 2767 | std::vector<IDrawableModule*> modules = mModuleContainer.GetModules(); |
| 2768 | std::string newName = GetUniqueName(layoutData["name"].asString(), modules); |
| 2769 | layoutData["name"] = newName; |
| 2770 | |
| 2771 | IDrawableModule* newModule = CreateModule(layoutData); |
| 2772 | mModuleContainer.AddModule(newModule); |
| 2773 | SetUpModule(newModule, layoutData); |
| 2774 | newModule->Init(); |
| 2775 | |
| 2776 | assert(newModule); |
| 2777 | |
| 2778 | newModule->SetName(module->Name()); //temporarily rename to the same as what we duplicated, so we can load state properly |
| 2779 | |
| 2780 | { |
| 2781 | FileStreamIn in(block); |
| 2782 | mIsLoadingModule = true; |
| 2783 | mIsDuplicatingModule = true; |
| 2784 | newModule->LoadState(in, newModule->LoadModuleSaveStateRev(in)); |
| 2785 | mIsDuplicatingModule = false; |
| 2786 | mIsLoadingModule = false; |
| 2787 | } |
| 2788 | |
| 2789 | newModule->SetName(newName.c_str()); |
| 2790 | |
| 2791 | return newModule; |
| 2792 | } |
| 2793 | |
| 2794 | ofxJSONElement ModularSynth::GetLayout() |
| 2795 | { |
nothing calls this directly
no test coverage detected