File indexing completed on 2024-04-28 16:08:34
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 #ifndef OBSERVERNOTIFIER_H_ 0022 #define OBSERVERNOTIFIER_H_ 0023 0024 #include "src/domain/animation/animationimpl.h" 0025 #include <vector> 0026 0027 class Observer; 0028 class Frontend; 0029 class ObservableOperation; 0030 class AudioDriver; 0031 class FileNameVisitor; 0032 class Frame; 0033 class Scene; 0034 class Sound; 0035 class WorkspaceFile; 0036 0037 0038 class ObserverNotifier : public AnimationImpl { 0039 AnimationImpl* del; 0040 Frontend* frontend; 0041 typedef std::vector<Observer*> observers_t; 0042 observers_t observers; 0043 void doOp(ObservableOperation& oo); 0044 public: 0045 ~ObserverNotifier(); 0046 /** 0047 * Constructs a wrapper for another {@ref AnimationImpl} that notifies 0048 * observers of changes and reports errors to the user. 0049 * @param delegate The wrapped {@ref AnimationImpl}. Ownership is passed. 0050 * @param frontend The UI, which is notified of errors and warnings. 0051 * Ownership is not passed. Optional. 0052 */ 0053 ObserverNotifier(AnimationImpl* delegate, Frontend* frontend); 0054 void addObserver(Observer* newObserver); 0055 void removeObserver(Observer* o); 0056 void registerFrontend(Frontend* fe); 0057 // derived from AnimationImpl 0058 void clear(); 0059 int sceneCount() const; 0060 0061 void addScene(int where, Scene* newScene); 0062 void addScene(int where); 0063 void preallocateScenes(int count); 0064 Scene* removeScene(int from); 0065 void moveScene(int from, int to); 0066 const Scene* getScene(int which) const; 0067 int frameCount(int scene) const; 0068 void addFrame(int scene, int where, Frame* frame); 0069 void addFrames(int scene, int where, 0070 const std::vector<Frame*>& frames); 0071 void preallocateFrames(int scene, int count); 0072 Frame* removeFrame(int scene, int frame); 0073 void removeFrames(int scene, int frame, int count, 0074 std::vector<Frame*>& out); 0075 void moveFrames(int fromScene, int fromFrame, int frameCount, 0076 int toScene, int toFrame); 0077 void replaceImage(int sceneNumber, int frameNumber, 0078 WorkspaceFile& otherImage); 0079 int soundCount(int scene, int frame) const; 0080 int soundCount() const; 0081 void addSound(int scene, int frame, int soundNumber, 0082 Sound* sound); 0083 const char* setSoundName(int scene, int frame, int soundNumber, 0084 const char* soundName); 0085 Sound* removeSound(int scene, int frame, int soundNumber); 0086 void playSounds(int scene, int frame, AudioDriver* audioDriver) const; 0087 void resync(); 0088 void accept(FileNameVisitor& v) const; 0089 }; 0090 0091 #endif /* OBSERVERNOTIFIER_H_ */