1 /*
2 * Copyright (C) 2005 - 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 "CMacroActionParamsDialog.h"
22
23 #include "CFOXIcons.h"
24 #include "utils.h"
25 #include "CStatusComm.h"
26
27 #include "../backend/AAction.h"
28 #include "../backend/CLoadedSound.h"
29 #include "../backend/CSound.h"
30 #include "../backend/CSoundPlayerChannel.h"
31
32 FXDEFMAP(CMacroActionParamsDialog) CMacroActionParamsDialogMap[]=
33 {
34 // Message_Type ID Message_Handler
35 //FXMAPFUNC(SEL_COMMAND, CMacroActionParamsDialog::ID_START_BUTTON, CMacroActionParamsDialog::onStartButton),
36 FXMAPFUNC(SEL_COMMAND, CMacroActionParamsDialog::ID_RADIO_BUTTON, CMacroActionParamsDialog::onRadioButton),
37 };
38
39
FXIMPLEMENT(CMacroActionParamsDialog,FXModalDialogBox,CMacroActionParamsDialogMap,ARRAYNUMBER (CMacroActionParamsDialogMap))40 FXIMPLEMENT(CMacroActionParamsDialog,FXModalDialogBox,CMacroActionParamsDialogMap,ARRAYNUMBER(CMacroActionParamsDialogMap))
41
42
43
44 // ----------------------------------------
45
46 CMacroActionParamsDialog::CMacroActionParamsDialog(FXWindow *mainWindow) :
47 FXModalDialogBox(mainWindow,N_("Macro Action Parameters"),350,100,FXModalDialogBox::ftVertical)
48 {
49 //setIcon(FOXIcons->small_record_macro);
50
51 getFrame()->setHSpacing(0);
52 getFrame()->setVSpacing(5);
53
54
55 FXPacker *frame1;
56
57 #warning need to remove the cancel button
58
59 actionNameLabel=new FXLabel(getFrame(),"",0,LABEL_NORMAL);
60
61 //frame1=new FXHorizontalFrame(getFrame(),FRAME_RAISED | LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0, 1,1);
62 new FXLabel(getFrame(),_("When the Macro is Played Back and This Action is to be Performed..."),0,LABEL_NORMAL|LAYOUT_CENTER_X);
63
64 //frame1=new FXHorizontalFrame(getFrame(),FRAME_RAISED | LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0, 1,1);
65 askToPromptForActionParametersAtPlaybackCheckButton=new FXCheckButton(getFrame(),"Ask to Prompt For Action Parameters");
66 askToPromptForActionParametersAtPlaybackCheckButton->setCheck(FALSE);
67
68 // ??? there might be a better way of wording this (especially the "percentage" term)
69 // ??? if the start or stop positions are on exact cue positions, then we could ask to set the position to the same cue names
70
71 frame1=startPosPositioningGroupBox=new FXGroupBox(getFrame(),_("Set the Start Position..."),GROUPBOX_NORMAL | FRAME_GROOVE);
72 startPosRadioButton4=new FXRadioButton(frame1,_("Same Proportionate Time"),this,ID_RADIO_BUTTON);
73 startPosRadioButton2=new FXRadioButton(frame1,_("Same Absolute Time From the Beginning of the Audio File"),this,ID_RADIO_BUTTON);
74 startPosRadioButton3=new FXRadioButton(frame1,_("Same Absolute Time From the End of the Audio File"),this,ID_RADIO_BUTTON);
75 startPosRadioButton5=new FXRadioButton(frame1,_("Same Absolute Time Before the Stop Position"),this,ID_RADIO_BUTTON);
76 startPosRadioButton6=new FXRadioButton(frame1,_("Same Proportionate Time Before the Stop Position"),this,ID_RADIO_BUTTON);
77 startPosRadioButton9=new FXRadioButton(frame1,_("Same Cue Name"),this,ID_RADIO_BUTTON);
78 startPosRadioButton1=new FXRadioButton(frame1,_("Leave in the Same Position From Previous Action"),this,ID_RADIO_BUTTON);
79 startPosRadioButton4->setCheck(TRUE);
80
81 frame1=stopPosPositioningGroupBox=new FXGroupBox(getFrame(),_("Set the Stop Position..."),GROUPBOX_NORMAL | FRAME_GROOVE);
82 stopPosRadioButton4=new FXRadioButton(frame1,_("Same Proportionate Time"),this,ID_RADIO_BUTTON);
83 stopPosRadioButton2=new FXRadioButton(frame1,_("Same Absolute Time From the Beginning of the Audio File"),this,ID_RADIO_BUTTON);
84 stopPosRadioButton3=new FXRadioButton(frame1,_("Same Absolute Time From the End of the Audio File"),this,ID_RADIO_BUTTON);
85 stopPosRadioButton7=new FXRadioButton(frame1,_("Same Absolute Time After the Start Position"),this,ID_RADIO_BUTTON);
86 stopPosRadioButton8=new FXRadioButton(frame1,_("Same Proportionate Time After the Start Position"),this,ID_RADIO_BUTTON);
87 stopPosRadioButton9=new FXRadioButton(frame1,_("Same Cue Name"),this,ID_RADIO_BUTTON);
88 stopPosRadioButton1=new FXRadioButton(frame1,_("Leave in the Same Position From Previous Action"),this,ID_RADIO_BUTTON);
89 stopPosRadioButton4->setCheck(TRUE);
90 }
91
~CMacroActionParamsDialog()92 CMacroActionParamsDialog::~CMacroActionParamsDialog()
93 {
94 }
95
showIt(const AActionFactory * actionFactory,AFrontendHooks::MacroActionParameters & macroActionParameters,CLoadedSound * loadedSound)96 bool CMacroActionParamsDialog::showIt(const AActionFactory *actionFactory,AFrontendHooks::MacroActionParameters ¯oActionParameters,CLoadedSound *loadedSound)
97 {
98 const string actionName=actionFactory->getName();
99 const bool selectionPositionsAreApplicable=actionFactory->selectionPositionsAreApplicable;
100 const bool hasDialog=actionFactory->hasDialog();
101
102 if(!hasDialog && !selectionPositionsAreApplicable)
103 {
104 macroActionParameters.askToPromptForActionParametersAtPlayback=false;
105 return true; // don't bother even showing the dialog
106 }
107
108 if(hasDialog)
109 askToPromptForActionParametersAtPlaybackCheckButton->enable();
110 else
111 askToPromptForActionParametersAtPlaybackCheckButton->disable();
112
113 string startPositionCueName;
114 string stopPositionCueName;
115 if(loadedSound && selectionPositionsAreApplicable)
116 {
117 enableAllChildren(startPosPositioningGroupBox);
118 enableAllChildren(stopPosPositioningGroupBox);
119
120 size_t index;
121
122 if(loadedSound->sound->findCue(loadedSound->channel->getStartPosition(),index))
123 {
124 startPositionCueName=loadedSound->sound->getCueName(index);
125 startPosRadioButton9->enable();
126 }
127 else
128 {
129 startPosRadioButton9->disable();
130 if(startPosRadioButton9->getCheck()==TRUE)
131 {
132 startPosRadioButton1->setCheck(TRUE);
133 startPosRadioButton9->setCheck(FALSE);
134 }
135 }
136
137 if(loadedSound->sound->findCue(loadedSound->channel->getStopPosition(),index))
138 {
139 stopPositionCueName=loadedSound->sound->getCueName(index);
140 stopPosRadioButton9->enable();
141 }
142 else
143 {
144 stopPosRadioButton9->disable();
145 if(stopPosRadioButton9->getCheck()==TRUE)
146 {
147 stopPosRadioButton1->setCheck(TRUE);
148 stopPosRadioButton9->setCheck(FALSE);
149 }
150 }
151 }
152 else
153 {
154 disableAllChildren(startPosPositioningGroupBox);
155 disableAllChildren(stopPosPositioningGroupBox);
156 }
157
158 actionNameLabel->setText(("Action: "+actionName).c_str());
159
160 reshow:
161
162 if(execute(PLACEMENT_CURSOR))
163 {
164 macroActionParameters.askToPromptForActionParametersAtPlayback=(askToPromptForActionParametersAtPlaybackCheckButton->getCheck()==TRUE);
165
166 if(startPosRadioButton1->getCheck()==TRUE)
167 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spLeaveAlone;
168 else if(startPosRadioButton2->getCheck()==TRUE)
169 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromBeginning;
170 else if(startPosRadioButton3->getCheck()==TRUE)
171 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromEnd;
172 else if(startPosRadioButton4->getCheck()==TRUE)
173 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spProportionateTimeFromBeginning;
174 else if(startPosRadioButton5->getCheck()==TRUE)
175 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromStopPosition;
176 else if(startPosRadioButton6->getCheck()==TRUE)
177 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spProportionateTimeFromStopPosition;
178 else if(startPosRadioButton9->getCheck()==TRUE)
179 macroActionParameters.startPosPositioning=AFrontendHooks::MacroActionParameters::spSameCueName;
180 macroActionParameters.startPosCueName=startPositionCueName;
181
182 if(stopPosRadioButton1->getCheck()==TRUE)
183 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spLeaveAlone;
184 else if(stopPosRadioButton2->getCheck()==TRUE)
185 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromBeginning;
186 else if(stopPosRadioButton3->getCheck()==TRUE)
187 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromEnd;
188 else if(stopPosRadioButton4->getCheck()==TRUE)
189 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spProportionateTimeFromBeginning;
190 else if(stopPosRadioButton7->getCheck()==TRUE)
191 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spAbsoluteTimeFromStartPosition;
192 else if(stopPosRadioButton8->getCheck()==TRUE)
193 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spProportionateTimeFromStartPosition;
194 else if(stopPosRadioButton9->getCheck()==TRUE)
195 macroActionParameters.stopPosPositioning=AFrontendHooks::MacroActionParameters::spSameCueName;
196 macroActionParameters.stopPosCueName=stopPositionCueName;
197
198 if(macroActionParameters.positionsAreRelativeToEachOther())
199 {
200 hide();
201 Error(_("The positioning of the start and stop positions cannot be relative to each other."));
202 goto reshow;
203 }
204
205 return true;
206 }
207 return false;
208 }
209
onRadioButton(FXObject * sender,FXSelector sel,void * ptr)210 long CMacroActionParamsDialog::onRadioButton(FXObject *sender,FXSelector sel,void *ptr)
211 {
212 if(ptr)
213 {
214 FXGroupBox *p=(FXGroupBox *)(((FXRadioButton *)sender)->getParent());
215 for(int t=0;t<p->numChildren();t++)
216 ((FXRadioButton *)p->childAtIndex(t))->setCheck(FALSE);
217 ((FXRadioButton *)sender)->setCheck(TRUE);
218 }
219
220 return 0;
221 }
222