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 "CAddChannelsEdit.h"
22
23 #include "../CActionSound.h"
24 #include "../CActionParameters.h"
25
26
CAddChannelsEdit(const AActionFactory * factory,const CActionSound * actionSound,unsigned _where,unsigned _count)27 CAddChannelsEdit::CAddChannelsEdit(const AActionFactory *factory,const CActionSound *actionSound,unsigned _where,unsigned _count) :
28 AAction(factory,actionSound),
29
30 where(_where),
31 count(_count)
32 {
33 }
34
~CAddChannelsEdit()35 CAddChannelsEdit::~CAddChannelsEdit()
36 {
37 }
38
doActionSizeSafe(CActionSound * actionSound,bool prepareForUndo)39 bool CAddChannelsEdit::doActionSizeSafe(CActionSound *actionSound,bool prepareForUndo)
40 {
41 actionSound->sound->addChannels(where,count,true);
42 return true;
43 }
44
canUndo(const CActionSound * actionSound) const45 AAction::CanUndoResults CAddChannelsEdit::canUndo(const CActionSound *actionSound) const
46 {
47 return curYes;
48 }
49
undoActionSizeSafe(const CActionSound * actionSound)50 void CAddChannelsEdit::undoActionSizeSafe(const CActionSound *actionSound)
51 {
52 actionSound->sound->removeChannels(where,count);
53 }
54
55
56
57 // ------------------------------
58
CAddChannelsEditFactory(AActionDialog * dialog)59 CAddChannelsEditFactory::CAddChannelsEditFactory(AActionDialog *dialog) :
60 AActionFactory(N_("Add Channels"),_("Add New Channels of Audio"),NULL,dialog,true,false)
61 {
62 selectionPositionsAreApplicable=false;
63 }
64
~CAddChannelsEditFactory()65 CAddChannelsEditFactory::~CAddChannelsEditFactory()
66 {
67 }
68
manufactureAction(const CActionSound * actionSound,const CActionParameters * actionParameters) const69 CAddChannelsEdit *CAddChannelsEditFactory::manufactureAction(const CActionSound *actionSound,const CActionParameters *actionParameters) const
70 {
71 return new CAddChannelsEdit(
72 this,
73 actionSound,
74 actionParameters->getValue<unsigned>("Insert Where"),
75 actionParameters->getValue<unsigned>("Insert Count")
76 );
77 }
78
79