Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
playbackmanager.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2017 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but 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 */
17 
18 #ifndef PLAYBACKMANAGER_H
19 #define PLAYBACKMANAGER_H
20 
21 #include "basemanager.h"
22 
23 class QTimer;
24 
25 
27 {
28  Q_OBJECT
29 public:
30  explicit PlaybackManager( QObject* parent );
31 
32  bool init() override;
33  Status load( Object* ) override;
34  Status save( Object* ) override;
35 
36  bool isPlaying();
37  bool isLooping() { return mIsLooping; }
38 
39  void play();
40  void stop();
41 
42  int fps() { return mFps; }
43  int startFrame() { return mStartFrame; }
44  int endFrame() { return mEndFrame; }
45 
46  bool isRangedPlaybackOn() { return mIsRangedPlayback; }
47  int markInFrame() { return mMarkInFrame; }
48  int markOutFrame() { return mMarkOutFrame; }
49 
50  void setFps( int fps );
51  void setLooping( bool isLoop );
52  void enableRangedPlayback( bool b );
53  void setRangedStartFrame( int frame ) { mMarkInFrame = frame; }
54  void setRangedEndFrame( int frame ) { mMarkOutFrame = frame; }
55  void enableSound( bool b );
56 
57 Q_SIGNALS:
58  void fpsChanged( int fps );
59  void loopStateChanged( bool b );
60  void rangedPlaybackStateChanged( bool b );
61  void playStateChanged( bool isPlaying );
62 
63 private:
64  void timerTick();
65 
66  void playSounds( int frame );
67  void stopSounds();
68 
69  int mStartFrame = 1;
70  int mEndFrame = 60;
71 
72  bool mIsLooping = false;
73  bool mIsPlaySound = true;
74 
75  bool mIsRangedPlayback = false;
76  int mMarkInFrame = 1;
77  int mMarkOutFrame = 10;
78  int mActiveSoundFrame = 0;
79 
80  int mFps = 12;
81 
82  QTimer* mTimer = nullptr;
83 
84  bool mCheckForSoundsHalfway = false;
85 };
86 
87 #endif // PLAYBACKMANAGER_H
Definition: object.h:71