File indexing completed on 2024-05-05 16:57:02
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2013 by Linuxstopmotion contributors. * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0018 ***************************************************************************/ 0019 #ifndef OBSERVER_H 0020 #define OBSERVER_H 0021 0022 #include "src/config.h" 0023 #include "src/domain/animation/frame.h" 0024 #include "src/presentation/frontends/frontend.h" 0025 0026 #include <vector> 0027 0028 using namespace std; 0029 0030 /** 0031 * The observer interface. Any object wanting to be notified when something 0032 * changes in the animationmodel has to implement from this class. 0033 * 0034 * The observers implemented with this class also has to be attached to the 0035 * animationmodel. 0036 * 0037 * The observer is implemented with strong use of the push model. Although this 0038 * decreases the flexibility we gain a lot in efficiency which is more 0039 * important to us. 0040 * 0041 * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad 0042 */ 0043 class Observer { 0044 public: 0045 virtual ~Observer() {} 0046 0047 /** 0048 * Abstract function for receiving notification about new frames added to the model. 0049 * 0050 * @param frames the frames which has been added to the model. 0051 * @param scene The scene to which the frames have been added. 0052 * @param index The frame number within the scene to which the frames have 0053 * been added. 0054 * @param frontend the GUI frontend which is used to displaying progress on timeconsuming operations 0055 */ 0056 virtual void updateAdd(int scene, int index, int numFrames) = 0; 0057 0058 /** 0059 * Abstract function for receiving notification about frames removed from the model. 0060 * @param fromFrame the first frame of those removed 0061 * @param toFrame the last frame of those removed 0062 */ 0063 virtual void updateRemove(int scene, int fromFrame, int toFrame) = 0; 0064 0065 /** 0066 * Abstract function for receiving notification when frames are moved in the model. 0067 * @param fromScene The scene that the frames were moved from. 0068 * @param fromFrame Index of the first selected frame within {@a fromScene} 0069 * @param count The number of frames moved. 0070 * @param toScene The scene to which the frames were moved. 0071 * @param toFrame The position within scene {@a toScene} that the frames 0072 * were moved to. 0073 */ 0074 virtual void updateMove(int fromScene, int fromFrame, int count, 0075 int toScene, int toFrame) = 0; 0076 0077 /** 0078 * Abstract function for receiving notification when the model is erased. 0079 */ 0080 virtual void updateClear() = 0; 0081 0082 /** 0083 * Abstract function for receiving notification when a new scene is 0084 * created at location index. 0085 * @param index The location at which the new scene is created. 0086 */ 0087 virtual void updateNewScene(int index) = 0; 0088 0089 /** 0090 * Abstract function for receiving notification when a scene is removed from 0091 * the model. 0092 * @param sceneNumber the scene which has been removed from the model. 0093 */ 0094 virtual void updateRemoveScene(int sceneNumber) = 0; 0095 0096 /** 0097 * Abstract function for receiving notification when a scene in the animation 0098 * has been moved. 0099 * @param sceneNumber the scene that has been moved. 0100 * @param movePosition the position the scene has been moved to. 0101 */ 0102 virtual void updateMoveScene(int sceneNumber, int movePosition) = 0; 0103 0104 /** 0105 * Abstract function for receiving notification when the disk representation of the 0106 * animation is changed by other programs. 0107 * @param sceneNumber The scene to which the changed frame belongs. 0108 * @param frameNumber The index of the frame that has been changed. 0109 */ 0110 virtual void updateAnimationChanged(int activeScene, int frameNumber) = 0; 0111 0112 /** 0113 * Abstract function for receiving notifications when the number, order or 0114 * names of the sounds attached to a frame change. 0115 * @param sceneNumber The scene to which the frame belongs. 0116 * @param frameNumber The frame within scene number @a sceneNumber to which 0117 * the changed sounds belong. 0118 */ 0119 virtual void updateSoundChanged(int sceneNumber, int frameNumber) = 0; 0120 0121 /** 0122 * Resynchronizes the observer with the state of the animation. This is 0123 * called whenever the animation is called with out-of-range arguments. 0124 */ 0125 virtual void resync() = 0; 0126 }; 0127 0128 #endif