diff --git a/plugins/zynaddsubfx/ChangeLog b/plugins/zynaddsubfx/ChangeLog index 7b561d87c..0df66d70d 100644 --- a/plugins/zynaddsubfx/ChangeLog +++ b/plugins/zynaddsubfx/ChangeLog @@ -965,3 +965,11 @@ 18 Nov 2009 (Mark McCurry) - Fixed segfault in VirKeyBoard + +02 Dec 2009 (Paul Nasca) + - Fixed a small typo on Virtual Keyboard + +10 Dec 2009 (Mark McCurry) + - Separated out Presets and arrayed Presets to reduce warnings from + the Wextra flag + diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp index 80c23391d..5bd974978 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp @@ -28,7 +28,8 @@ int ADnote_unison_sizes[] = {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 25, 30, 40, 50, 0}; -ADnoteParameters::ADnoteParameters(FFTwrapper *fft_):Presets() +ADnoteParameters::ADnoteParameters(FFTwrapper *fft_) + :PresetsArray() { setpresettype("Padsyth"); fft = fft_; diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h index ee5a632bd..e63efcff3 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.h +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.h @@ -33,7 +33,7 @@ #include "../Misc/Util.h" #include "../Misc/XMLwrapper.h" #include "../DSP/FFTwrapper.h" -#include "Presets.h" +#include "PresetsArray.h" enum FMTYPE { NONE, MORPH, RING_MOD, PHASE_MOD, FREQ_MOD, PITCH_MOD @@ -275,7 +275,7 @@ struct ADnoteVoiceParam { EnvelopeParams *FMAmpEnvelope; }; -class ADnoteParameters:public Presets +class ADnoteParameters : public PresetsArray { public: ADnoteParameters(FFTwrapper *fft_); diff --git a/plugins/zynaddsubfx/src/Params/CMakeLists.txt b/plugins/zynaddsubfx/src/Params/CMakeLists.txt index 5ad77a4f2..670fcf26d 100644 --- a/plugins/zynaddsubfx/src/Params/CMakeLists.txt +++ b/plugins/zynaddsubfx/src/Params/CMakeLists.txt @@ -6,6 +6,7 @@ set(zynaddsubfx_params_SRCS LFOParams.cpp PADnoteParameters.cpp Presets.cpp + PresetsArray.cpp PresetsStore.cpp SUBnoteParameters.cpp diff --git a/plugins/zynaddsubfx/src/Params/FilterParams.cpp b/plugins/zynaddsubfx/src/Params/FilterParams.cpp index a74bf5a99..5f5747332 100644 --- a/plugins/zynaddsubfx/src/Params/FilterParams.cpp +++ b/plugins/zynaddsubfx/src/Params/FilterParams.cpp @@ -27,7 +27,8 @@ FilterParams::FilterParams(unsigned char Ptype_, unsigned char Pfreq_, - unsigned char Pq_):Presets() + unsigned char Pq_) + : PresetsArray() { setpresettype("Pfilter"); Dtype = Ptype_; diff --git a/plugins/zynaddsubfx/src/Params/FilterParams.h b/plugins/zynaddsubfx/src/Params/FilterParams.h index 2a1df6b28..8facbe58c 100644 --- a/plugins/zynaddsubfx/src/Params/FilterParams.h +++ b/plugins/zynaddsubfx/src/Params/FilterParams.h @@ -25,9 +25,9 @@ #include "../globals.h" #include "../Misc/XMLwrapper.h" -#include "Presets.h" +#include "PresetsArray.h" -class FilterParams:public Presets +class FilterParams : public PresetsArray { public: FilterParams(unsigned char Ptype_, diff --git a/plugins/zynaddsubfx/src/Params/Presets.cpp b/plugins/zynaddsubfx/src/Params/Presets.cpp index b3cfd1610..8fbd0830a 100644 --- a/plugins/zynaddsubfx/src/Params/Presets.cpp +++ b/plugins/zynaddsubfx/src/Params/Presets.cpp @@ -27,7 +27,6 @@ Presets::Presets() { type[0] = 0; - nelement = -1; } Presets::~Presets() @@ -48,18 +47,14 @@ void Presets::copy(const char *name) char type[MAX_PRESETTYPE_SIZE]; strcpy(type, this->type); - if(nelement != -1) - strcat(type, "n"); + strcat(type, "n"); if(name == NULL) if(strstr(type, "Plfo") != NULL) strcpy(type, "Plfo"); ; xml->beginbranch(type); - if(nelement == -1) - add2XML(xml); - else - add2XMLsection(xml, nelement); + add2XML(xml); xml->endbranch(); if(name == NULL) @@ -68,15 +63,14 @@ void Presets::copy(const char *name) presetsstore.copypreset(xml, type, name); delete (xml); - nelement = -1; } void Presets::paste(int npreset) { char type[MAX_PRESETTYPE_SIZE]; strcpy(type, this->type); - if(nelement != -1) - strcat(type, "n"); + strcat(type, "n"); + if(npreset == 0) if(strstr(type, "Plfo") != NULL) strcpy(type, "Plfo"); @@ -85,57 +79,42 @@ void Presets::paste(int npreset) XMLwrapper *xml = new XMLwrapper(); if(npreset == 0) { if(!checkclipboardtype()) { - nelement = -1; delete (xml); return; } if(!presetsstore.pasteclipboard(xml)) { delete (xml); - nelement = -1; return; } } else { if(!presetsstore.pastepreset(xml, npreset)) { delete (xml); - nelement = -1; return; } } if(xml->enterbranch(type) == 0) { - nelement = -1; return; } - if(nelement == -1) { - defaults(); - getfromXML(xml); - } - else { - defaults(nelement); - getfromXMLsection(xml, nelement); - } + + defaults(); + getfromXML(xml); + xml->exitbranch(); delete (xml); - nelement = -1; } bool Presets::checkclipboardtype() { char type[MAX_PRESETTYPE_SIZE]; strcpy(type, this->type); - if(nelement != -1) - strcat(type, "n"); + strcat(type, "n"); return presetsstore.checkclipboardtype(type); } -void Presets::setelement(int n) -{ - nelement = n; -} - void Presets::rescanforpresets() { presetsstore.rescanforpresets(type); diff --git a/plugins/zynaddsubfx/src/Params/Presets.h b/plugins/zynaddsubfx/src/Params/Presets.h index 8e143aed6..d8000fe3b 100644 --- a/plugins/zynaddsubfx/src/Params/Presets.h +++ b/plugins/zynaddsubfx/src/Params/Presets.h @@ -30,17 +30,18 @@ /**Presets and Clipboard management*/ class Presets { + friend class PresetsArray; public: Presets(); virtual ~Presets(); - void copy(const char *name); /** + + +PresetsArray::PresetsArray() +{ + type[0] = 0; + nelement = -1; +} + +PresetsArray::~PresetsArray() +{} + +void PresetsArray::setpresettype(const char *type) +{ + strcpy(this->type, type); +} + +void PresetsArray::copy(const char *name) +{ + XMLwrapper *xml = new XMLwrapper(); + + //used only for the clipboard + if(name == NULL) + xml->minimal = false; + + char type[MAX_PRESETTYPE_SIZE]; + strcpy(type, this->type); + if(nelement != -1) + strcat(type, "n"); + if(name == NULL) + if(strstr(type, "Plfo") != NULL) + strcpy(type, "Plfo"); + ; + + xml->beginbranch(type); + if(nelement == -1) + add2XML(xml); + else + add2XMLsection(xml, nelement); + xml->endbranch(); + + if(name == NULL) + presetsstore.copyclipboard(xml, type); + else + presetsstore.copypreset(xml, type, name); + + delete (xml); + nelement = -1; +} + +void PresetsArray::paste(int npreset) +{ + char type[MAX_PRESETTYPE_SIZE]; + strcpy(type, this->type); + if(nelement != -1) + strcat(type, "n"); + if(npreset == 0) + if(strstr(type, "Plfo") != NULL) + strcpy(type, "Plfo"); + ; + + XMLwrapper *xml = new XMLwrapper(); + if(npreset == 0) { + if(!checkclipboardtype()) { + nelement = -1; + delete (xml); + return; + } + if(!presetsstore.pasteclipboard(xml)) { + delete (xml); + nelement = -1; + return; + } + } + else { + if(!presetsstore.pastepreset(xml, npreset)) { + delete (xml); + nelement = -1; + return; + } + } + + if(xml->enterbranch(type) == 0) { + nelement = -1; + return; + } + if(nelement == -1) { + defaults(); + getfromXML(xml); + } + else { + defaults(nelement); + getfromXMLsection(xml, nelement); + } + xml->exitbranch(); + + delete (xml); + nelement = -1; +} + +bool PresetsArray::checkclipboardtype() +{ + char type[MAX_PRESETTYPE_SIZE]; + strcpy(type, this->type); + if(nelement != -1) + strcat(type, "n"); + + return presetsstore.checkclipboardtype(type); +} + +void PresetsArray::setelement(int n) +{ + nelement = n; +} + diff --git a/plugins/zynaddsubfx/src/Params/PresetsArray.h b/plugins/zynaddsubfx/src/Params/PresetsArray.h new file mode 100644 index 000000000..aea7ed362 --- /dev/null +++ b/plugins/zynaddsubfx/src/Params/PresetsArray.h @@ -0,0 +1,60 @@ +/* + ZynAddSubFX - a software synthesizer + + PresetsArray.h - PresetsArray and Clipboard management + Copyright (C) 2002-2005 Nasca Octavian Paul + Author: Nasca Octavian Paul + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2 or later) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#ifndef PRESETSARRAY_H +#define PRESETSARRAY_H + +#include "../Misc/XMLwrapper.h" + +#include "Presets.h" + +/**PresetsArray and Clipboard management*/ +class PresetsArray : public Presets +{ + public: + PresetsArray(); + virtual ~PresetsArray(); + + void copy(const char *name); /**setelement(n); + PresetsArray *pre = dynamic_cast(p); +if(pre) + pre->setelement(n); copy(p); } void PresetsUI::paste(Presets *p,PresetsUI_ *pui,int n) { - p->setelement(n); + PresetsArray *pre = dynamic_cast(p); +if(pre) + pre->setelement(n); paste(p,pui); } diff --git a/plugins/zynaddsubfx/src/UI/PresetsUI.fl b/plugins/zynaddsubfx/src/UI/PresetsUI.fl index 0378d62ef..61e78ce14 100644 --- a/plugins/zynaddsubfx/src/UI/PresetsUI.fl +++ b/plugins/zynaddsubfx/src/UI/PresetsUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0105 +version 1.0107 header_name {.h} code_name {.cc} decl {\#include } {public @@ -11,6 +11,9 @@ decl {\#include } {public decl {\#include } {public } +decl {\#include "../Params/PresetsArray.h"} {selected +} + decl {\#include "../Params/Presets.h"} {public } @@ -96,7 +99,7 @@ if (strlen(tmp)>0) { }else{ pastepbutton->activate(); deletepbutton->activate(); -};} selected +};} xywh {10 25 245 320} type Hold } Fl_Button pastepbutton { @@ -171,11 +174,15 @@ if (but) { };} {} } Function {copy(Presets *p,int n)} {} { - code {p->setelement(n); + code {PresetsArray *pre = dynamic_cast(p); +if(pre) + pre->setelement(n); copy(p);} {} } Function {paste(Presets *p,PresetsUI_ *pui,int n)} {} { - code {p->setelement(n); + code {PresetsArray *pre = dynamic_cast(p); +if(pre) + pre->setelement(n); paste(p,pui);} {} } Function {rescan()} {} {