File indexing completed on 2024-05-12 16:23:27
0001 /*************************************************************************** 0002 * Copyright (C) 2013 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #include "addallcommands.h" 0022 0023 #include <memory> 0024 #include <utility> 0025 0026 #include "commandadd.h" 0027 #include "commandremove.h" 0028 #include "commandmove.h" 0029 #include "commandaddsound.h" 0030 #include "commandremovesound.h" 0031 #include "commandrenamesound.h" 0032 #include "commandaddscene.h" 0033 #include "commandremovescene.h" 0034 #include "commandmovescene.h" 0035 #include "commandsetimage.h" 0036 #include "src/domain/undo/command.h" 0037 #include "src/domain/undo/executor.h" 0038 0039 0040 class AnimationImpl; 0041 0042 const char* Commands::addFrames = "add-frame"; 0043 const char* Commands::removeFrames = "delete-frame"; 0044 const char* Commands::moveFrames = "move-frame"; 0045 const char* Commands::setImage = "set-image"; 0046 const char* Commands::addSound = "add-sound"; 0047 const char* Commands::removeSound = "delete-sound"; 0048 const char* Commands::renameSound = "rename-sound"; 0049 const char* Commands::addScene = "new-scene"; 0050 const char* Commands::removeScene = "delete-scene"; 0051 const char* Commands::moveScene = "move-scene"; 0052 0053 template<typename COMMAND_FACTORY> void addCommand(Executor& ex, AnimationImpl& model, 0054 const char* name, bool constructive) { 0055 std::unique_ptr<CommandFactory> c(new COMMAND_FACTORY(model)); 0056 ex.addCommand(name, std::move(c), constructive); 0057 } 0058 0059 Executor* makeAnimationCommandExecutor(AnimationImpl& model) { 0060 std::unique_ptr<Executor> ex(makeExecutor()); 0061 addCommand<CommandAddFactory>(*ex, model, Commands::addFrames, true); 0062 addCommand<CommandRemoveFactory>(*ex, model, Commands::removeFrames, false); 0063 addCommand<CommandMoveFactory>(*ex, model, Commands::moveFrames, false); 0064 addCommand<CommandSetImageFactory>(*ex, model, Commands::setImage, false); 0065 addCommand<CommandAddSoundFactory>(*ex, model, Commands::addSound, true); 0066 addCommand<UndoRemoveSoundFactory>(*ex, model, Commands::removeSound, false); 0067 addCommand<CommandRenameSoundFactory>(*ex, model, Commands::renameSound, false); 0068 addCommand<CommandAddSceneFactory>(*ex, model, Commands::addScene, true); 0069 addCommand<UndoRemoveSceneFactory>(*ex, model, Commands::removeScene, false); 0070 addCommand<CommandMoveSceneFactory>(*ex, model, Commands::moveScene, false); 0071 return ex.release(); 0072 } 0073