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 #include "EditActionDialogs.h"
22 
23 #include <istring>
24 
25 #include "../backend/CActionSound.h"
26 #include "../backend/CSound.h"
27 #include "settings.h"
28 
29 #include "../backend/ActionParamMappers.h"
30 
31 
32 // --- insert silence -------------------------
33 
34 CInsertSilenceDialog::CInsertSilenceDialog(FXWindow *mainWindow) :
35 	CActionParamDialog(mainWindow)
36 {
37 	void *p=newHorzPanel(NULL);
38 		addNumericTextEntry(p,N_("Length"),_("seconds"),1.0,0,10000);
39 }
40 
41 
42 
43 // --- rotate ---------------------------------
44 
45 CRotateDialog::CRotateDialog(FXWindow *mainWindow) :
46 	CActionParamDialog(mainWindow)
47 {
48 	void *p=newHorzPanel(NULL);
49 		addNumericTextEntry(p,N_("Amount"),_("seconds"),1.0,0,10000);
50 }
51 
52 
53 
54 // --- swap channels --------------------------
55 
56 CSwapChannelsDialog::CSwapChannelsDialog(FXWindow *mainWindow) :
57 	CActionParamDialog(mainWindow)
58 {
59 	void *p=newVertPanel(NULL);
60 		vector<string> items;
61 		addComboTextEntry(p,N_("Channel A"),items,CActionParamDialog::cpvtAsInteger,"");
62 		addComboTextEntry(p,N_("Channel B"),items,CActionParamDialog::cpvtAsInteger,"");
63 }
64 
65 #include "../backend/CActionParameters.h"
66 
67 bool CSwapChannelsDialog::show(CActionSound *actionSound,CActionParameters *actionParameters)
68 {
69 	if(actionSound->sound->getChannelCount()<2)
70 		return false;
71 	else if(actionSound->sound->getChannelCount()==2)
72 	{ // only one possibility of swapping the two channels
73 		actionParameters->setValue<unsigned>("Channel A",0);
74 		actionParameters->setValue<unsigned>("Channel B",1);
75 		return true;
76 	}
77 	else
78 	{
79 		if(getComboText("Channel A")->getItems().size()!=actionSound->sound->getChannelCount())
80 		{
81 			vector<string> items;
82 			for(size_t t=0;t<actionSound->sound->getChannelCount();t++)
83 				items.push_back(_("Channel ")+istring(t));
84 
85 			// set the combo boxes according to actionSound
86 			getComboText("Channel A")->setItems(items);
87 			getComboText("Channel B")->setItems(items);
88 			getComboText("Channel A")->setCurrentItem(0);
89 			getComboText("Channel B")->setCurrentItem(1);
90 		}
91 
92 		return CActionParamDialog::show(actionSound,actionParameters);
93 	}
94 }
95 
96 
97 // --- add channels ---------------------------
98 
99 CAddChannelsDialog::CAddChannelsDialog(FXWindow *mainWindow) :
100 	CActionParamDialog(mainWindow)
101 {
102 	void *p=newVertPanel(NULL);
103 		addNumericTextEntry(p,N_("Insert Where"),"",0,0,MAX_CHANNELS);
104 		addNumericTextEntry(p,N_("Insert Count"),"",1,1,MAX_CHANNELS);
105 }
106 
107 
108 
109 // --- duplicate channel ----------------------
110 
111 CDuplicateChannelDialog::CDuplicateChannelDialog(FXWindow *mainWindow) :
112 	CActionParamDialog(mainWindow)
113 {
114 	void *p=newVertPanel(NULL);
115 		vector<string> items;
116 		addComboTextEntry(p,N_("Which Channel"),items,CActionParamDialog::cpvtAsInteger,"");
117 		addComboTextEntry(p,N_("Insert Where"),items,CActionParamDialog::cpvtAsInteger,"");
118 		addNumericTextEntry(p,N_("How Many Times"),"",1,1,MAX_CHANNELS);
119 }
120 
121 bool CDuplicateChannelDialog::show(CActionSound *actionSound,CActionParameters *actionParameters)
122 {
123 	if(getComboText("Which Channel")->getItems().size()!=actionSound->sound->getChannelCount())
124 	{
125 		vector<string> items;
126 		for(size_t t=0;t<actionSound->sound->getChannelCount();t++)
127 			items.push_back(_("Channel ")+istring(t));
128 
129 		// set the combo boxes according to actionSound
130 		getComboText("Which Channel")->setItems(items);
131 		getComboText("Which Channel")->setCurrentItem(0);
132 
133 		items.push_back(_("Channel ")+istring(actionSound->sound->getChannelCount()));
134 		getComboText("Insert Where")->setItems(items);
135 		getComboText("Insert Where")->setCurrentItem(1);
136 	}
137 
138 	return CActionParamDialog::show(actionSound,actionParameters);
139 }
140 // --- grow or slide selection dialog ---------
141 
142 CGrowOrSlideSelectionDialog::CGrowOrSlideSelectionDialog(FXWindow *mainWindow) :
143 	CActionParamDialog(mainWindow)
144 {
145 	void *p=newVertPanel(NULL);
146 		addSlider(p,
147 			N_("Amount"),
148 			"s",
149 			new CActionParamMapper_linear(1.0,2,1,3600),
150 			NULL,
151 			false
152 		);
153 		setTipText("Amount",_("Amount to Affect the Selection in Seconds"));
154 
155 		vector<string> items;
156 			items.push_back(N_("Grow Selection to the Left"));
157 			items.push_back(N_("Grow Selection to the Right"));
158 			items.push_back(N_("Grow Selection in Both Directions"));
159 			items.push_back(N_("Slide Selection to the Left"));
160 			items.push_back(N_("Slide Selection to the Right"));
161 		addComboTextEntry(p,N_("How"),items,CActionParamDialog::cpvtAsInteger);
162 		getComboText("How")->setCurrentItem(1);
163 }
164 
165