Cleanup: Separated Presets into Presets/PresetsArray
-Separated the Presets into two classes to reduce the g++ warnings about discarded arguments -Note: looking at these classes, they need a bit more work to have them fit one good abstraction (cherry picked from commit 92c2a9016f1663d0ad48dac081f277baaed37701)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -6,6 +6,7 @@ set(zynaddsubfx_params_SRCS
|
||||
LFOParams.cpp
|
||||
PADnoteParameters.cpp
|
||||
Presets.cpp
|
||||
PresetsArray.cpp
|
||||
PresetsStore.cpp
|
||||
SUBnoteParameters.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_;
|
||||
|
||||
@@ -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_,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -30,17 +30,18 @@
|
||||
/**Presets and Clipboard management*/
|
||||
class Presets
|
||||
{
|
||||
friend class PresetsArray;
|
||||
public:
|
||||
Presets();
|
||||
virtual ~Presets();
|
||||
|
||||
void copy(const char *name); /**<if name==NULL, the clipboard is used*/
|
||||
void paste(int npreset); //npreset==0 for clipboard
|
||||
bool checkclipboardtype();
|
||||
virtual void copy(const char *name); /**<if name==NULL, the clipboard is used*/
|
||||
virtual void paste(int npreset); //npreset==0 for clipboard
|
||||
virtual bool checkclipboardtype();
|
||||
void deletepreset(int npreset);
|
||||
|
||||
char type[MAX_PRESETTYPE_SIZE];
|
||||
void setelement(int n);
|
||||
//void setelement(int n);
|
||||
|
||||
void rescanforpresets();
|
||||
|
||||
@@ -50,10 +51,6 @@ class Presets
|
||||
virtual void add2XML(XMLwrapper *xml) = 0;
|
||||
virtual void getfromXML(XMLwrapper *xml) = 0;
|
||||
virtual void defaults() = 0;
|
||||
virtual void add2XMLsection(XMLwrapper *xml, int n) {}
|
||||
virtual void getfromXMLsection(XMLwrapper *xml, int n) {}
|
||||
virtual void defaults(int n) {}
|
||||
int nelement;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
138
plugins/zynaddsubfx/src/Params/PresetsArray.cpp
Normal file
138
plugins/zynaddsubfx/src/Params/PresetsArray.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
ZynAddSubFX - a software synthesizer
|
||||
|
||||
PresetsArray.C - 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
|
||||
|
||||
*/
|
||||
|
||||
#include "PresetsArray.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
60
plugins/zynaddsubfx/src/Params/PresetsArray.h
Normal file
60
plugins/zynaddsubfx/src/Params/PresetsArray.h
Normal file
@@ -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); /**<if name==NULL, the clipboard is used*/
|
||||
void paste(int npreset); //npreset==0 for clipboard
|
||||
bool checkclipboardtype();
|
||||
void deletepreset(int npreset);
|
||||
|
||||
char type[MAX_PRESETTYPE_SIZE];
|
||||
void setelement(int n);
|
||||
|
||||
void rescanforpresets();
|
||||
|
||||
protected:
|
||||
void setpresettype(const char *type);
|
||||
private:
|
||||
virtual void add2XML(XMLwrapper *xml) = 0;
|
||||
virtual void getfromXML(XMLwrapper *xml) = 0;
|
||||
virtual void defaults() = 0;
|
||||
virtual void add2XMLsection(XMLwrapper *xml, int n) = 0;
|
||||
virtual void getfromXMLsection(XMLwrapper *xml, int n) = 0;
|
||||
virtual void defaults(int n) = 0;
|
||||
int nelement;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// generated by Fast Light User Interface Designer (fluid) version 1.0300
|
||||
|
||||
#include "PresetsUI.h"
|
||||
#include "../Params/PresetsArray.h"
|
||||
|
||||
void PresetsUI_::refresh() {
|
||||
}
|
||||
@@ -242,12 +243,16 @@ if (but) {
|
||||
}
|
||||
|
||||
void PresetsUI::copy(Presets *p,int n) {
|
||||
p->setelement(n);
|
||||
PresetsArray *pre = dynamic_cast<PresetsArray *>(p);
|
||||
if(pre)
|
||||
pre->setelement(n);
|
||||
copy(p);
|
||||
}
|
||||
|
||||
void PresetsUI::paste(Presets *p,PresetsUI_ *pui,int n) {
|
||||
p->setelement(n);
|
||||
PresetsArray *pre = dynamic_cast<PresetsArray *>(p);
|
||||
if(pre)
|
||||
pre->setelement(n);
|
||||
paste(p,pui);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <FL/fl_ask.H>} {public
|
||||
@@ -11,6 +11,9 @@ decl {\#include <stdio.h>} {public
|
||||
decl {\#include <stdlib.h>} {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<PresetsArray *>(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<PresetsArray *>(p);
|
||||
if(pre)
|
||||
pre->setelement(n);
|
||||
paste(p,pui);} {}
|
||||
}
|
||||
Function {rescan()} {} {
|
||||
|
||||
Reference in New Issue
Block a user