1 /* 2 * Copyright (C) 2002 - David W. Durham 3 * 4 * This file is part of ReZound, an audio editing application. 5 * 6 * ReZound is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, 9 * or (at your option) any later version. 10 * 11 * ReZound is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 */ 20 21 #ifndef __CActionParamDialog_H__ 22 #define __CActionParamDialog_H__ 23 24 #include "../../config/common.h" 25 #include "fox_compat.h" 26 27 28 class CActionParamDialog; 29 30 #include <vector> 31 #include <utility> 32 33 #include "FXModalDialogBox.h" 34 35 #include "FXConstantParamValue.h" 36 #include "FXTextParamValue.h" 37 #include "FXDiskEntityParamValue.h" 38 #include "FXComboTextParamValue.h" 39 #include "FXCheckBoxParamValue.h" 40 #include "FXGraphParamValue.h" 41 #include "FXLFOParamValue.h" 42 #include "FXPluginRoutingParamValue.h" 43 44 #include "../backend/AActionDialog.h" 45 #include "../backend/CGraphParamValueNode.h" 46 47 #include "../backend/AActionParamMapper.h" 48 49 class CNestedDataFile; 50 51 class CActionParamDialog : public FXModalDialogBox, public AActionDialog 52 { 53 FXDECLARE(CActionParamDialog); 54 public: 55 typedef const double (*f_at_x)(const double x); 56 57 // the presetPrefix value will get prefixed to all the read/writes on the presets file 58 CActionParamDialog(FXWindow *mainWindow,bool showPresetPanel=true,const string presetPrefix="",FXModalDialogBox::ShowTypes showType=FXModalDialogBox::stRememberSizeAndPosition); 59 virtual ~CActionParamDialog(); 60 61 // these are used to create new parents for the controls 62 // or something to lay other FOX widgets on (but not controls since they won't be saved in presets) 63 // pass NULL the first time 64 FXPacker *newHorzPanel(void *parent,bool createMargin=true,bool createFrame=false); 65 FXPacker *newVertPanel(void *parent,bool createMargin=true,bool createFrame=false); 66 67 FXConstantParamValue *addSlider(void *parent,const string name,const string units,AActionParamMapper *valueMapper,f_at_x optRetValueConv,bool showInverseButton); 68 FXConstantParamValue *getSliderParam(const string name); 69 FXTextParamValue *addNumericTextEntry(void *parent,const string name,const string units,const double initialValue,const double minValue,const double maxValue,const string unitsTipText=""); 70 FXTextParamValue *addStringTextEntry(void *parent,const string name,const string initialValue,const string tipText=""); 71 FXTextParamValue *getTextParam(const string name); 72 FXDiskEntityParamValue *addDiskEntityEntry(void *parent,const string name,const string intialEntityName,FXDiskEntityParamValue::DiskEntityTypes entityType,const string tipText=""); 73 FXDiskEntityParamValue *getDiskEntityParam(const string name); 74 enum ComboParamValueTypes { cpvtAsInteger/* if editable, then atoi of text, else index*/ ,cpvtAsString }; 75 /* is isEditable then the value is an integer of the actual value, if isEditable is false, then the integer value is the index of the items */ 76 FXComboTextParamValue *addComboTextEntry(void *parent,const string name,const vector<string> &items,ComboParamValueTypes type,const string tipText="",bool isEditable=false); 77 FXComboTextParamValue *getComboText(const string name); // so a derived class can set the values 78 FXCheckBoxParamValue *addCheckBoxEntry(void *parent,const string name,const bool checked,const string tipText=""); 79 FXCheckBoxParamValue *getCheckBoxParam(const string name); 80 FXGraphParamValue *addGraph(void *parent,const string name,const string horzAxisLabel,const string horzUnits,AActionParamMapper *horzValueMapper,const string vertAxisLabel,const string vertUnits,AActionParamMapper *vertValueMapper,f_at_x optRetValueConv); 81 FXGraphParamValue *getGraphParam(const string name); // so a derived class can set some ranges 82 FXGraphParamValue *addGraphWithWaveform(void *parent,const string name,const string vertAxisLabel,const string vertUnits,AActionParamMapper *vertValueMapper,f_at_x optRetValueConv); 83 FXLFOParamValue *addLFO(void *parent,const string name,const string ampUnits,const string ampTitle,const double maxAmp,const string freqUnits,const double maxFreq,const bool hideBipolarLFOs); 84 FXLFOParamValue *getLFOParam(const string name); 85 FXPluginRoutingParamValue *addPluginRoutingParam(void *parent,const string name,const LADSPA_Descriptor *desc); 86 FXPluginRoutingParamValue *getPluginRoutingParam(const string name); 87 88 // show or hide a control 89 void showControl(const string name,bool show); 90 91 /* 92 * index corrisponds to the order that the add...() methods were called 93 * and this can only be called for sliders, text entries, check boxes, and 94 * to set the index of a combobox 95 */ 96 void setValue(size_t index,const double value); 97 98 //void setControlHeight(size_t index,const size_t height); 99 //const size_t getControlHeight(size_t index) const; 100 101 void setTipText(const string name,const string tipText); 102 103 // don't like this, but it will do for now... someday I've got to come up with just how to specify placement of the added wigets 104 void setMargin(FXint margin); // will add a margin the left and right of all the controls 105 106 bool show(CActionSound *actionSound,CActionParameters *actionParameters); 107 void hide(); 108 109 enum 110 { 111 ID_NATIVE_PRESET_BUTTON=FXModalDialogBox::ID_LAST, 112 ID_NATIVE_PRESET_LIST, 113 114 ID_USER_PRESET_LIST, 115 ID_USER_PRESET_USE_BUTTON, 116 ID_USER_PRESET_SAVE_BUTTON, 117 ID_USER_PRESET_REMOVE_BUTTON, 118 119 ID_EXPLAIN_BUTTON, 120 121 ID_LAST 122 }; 123 124 125 long onPresetUseButton(FXObject *sender,FXSelector sel,void *ptr); 126 long onPresetSaveButton(FXObject *sender,FXSelector sel,void *ptr); 127 long onPresetRemoveButton(FXObject *sender,FXSelector sel,void *ptr); 128 129 long onExplainButton(FXObject *sender,FXSelector sel,void *ptr); 130 131 void create(); 132 setTitle(const string title)133 void setTitle(const string title) { FXModalDialogBox::setTitle(title); } 134 135 protected: CActionParamDialog()136 CActionParamDialog() {} 137 138 // can be overridden to return an explanation of the action which will cause the appearance of an 'explain' button on the dialog getExplanation()139 virtual const string getExplanation() const { return ""; } 140 141 private: 142 const CActionSound *actionSound; 143 144 bool showPresetPanel; 145 146 bool explanationButtonCreated; 147 148 enum ParamTypes 149 { 150 ptConstant, 151 ptNumericText, 152 ptStringText, 153 ptDiskEntity, 154 ptComboText, 155 ptCheckBox, 156 ptGraph, 157 ptGraphWithWaveform, 158 ptLFO, 159 ptPluginRouting 160 }; 161 162 // the FXWindow * points to either an FXConstantParamValue, FXTextParamValue, FXComboTextParamValue, FXCheckBoxParamValue or an FXGraphParamValue 163 vector<pair<ParamTypes,FXWindow *> > parameters; 164 vector<f_at_x> retValueConvs; 165 166 FXSplitter *splitter; 167 FXPacker *topPanel; 168 FXFrame *leftMargin; 169 FXPacker *controlsFrame; 170 FXFrame *rightMargin; 171 FXPacker *presetsFrame; 172 FXList *nativePresetList; 173 FXList *userPresetList; 174 175 const string presetPrefix; 176 177 void buildPresetLists(); 178 void buildPresetList(CNestedDataFile *f,FXList *list); 179 180 unsigned findParamByName(const string name) const; 181 182 bool firstShowing; 183 184 }; 185 186 #endif 187