Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • managers
playbackmanager.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#ifndef PLAYBACKMANAGER_H
19#define PLAYBACKMANAGER_H
20
21#include "basemanager.h"
22#include <QVector>
23
24class QTimer;
25class QElapsedTimer;
26class SoundClip;
27
28
29class PlaybackManager : public BaseManager
30{
31 Q_OBJECT
32public:
33 explicit PlaybackManager(Editor* editor);
34 ~PlaybackManager() override;
35
36 bool init() override;
37 Status load(Object*) override;
38 Status save(Object*) override;
39
40 bool isPlaying();
41 bool isLooping() { return mIsLooping; }
42 void setCheckForSoundsHalfway(bool newCheck) { mCheckForSoundsHalfway = newCheck; }
43
44 void play();
45 void stop();
46 void playFlipRoll();
47 void playFlipInBetween();
48 void playScrub(int frame);
49 void setSoundScrubMsec(int mSec) { mMsecSoundScrub = mSec; }
50 int getSoundScrubMsec() { return mMsecSoundScrub; }
51 void setSoundScrubActive(bool b) { mSoundScrub = b; }
52 bool getSoundScrubActive() { return mSoundScrub; }
53
54 int fps() { return mFps; }
55 int startFrame() { return mStartFrame; }
56 int endFrame() { return mEndFrame; }
57
58 bool isRangedPlaybackOn() { return mIsRangedPlayback; }
59 int markInFrame() { return mMarkInFrame; }
60 int markOutFrame() { return mMarkOutFrame; }
61
62 void setFps(int fps);
63 void setLooping(bool isLoop);
64 void enableRangedPlayback(bool b);
65 void setRangedStartFrame(int frame);
66 void setRangedEndFrame(int frame);
67 void enableSound(bool b);
68
69 void stopSounds();
70
71private slots:
72 void stopScrubPlayback();
73
74signals:
75 void fpsChanged(int fps);
76 void loopStateChanged(bool b);
77 void rangedPlaybackStateChanged(bool b);
78 void playStateChanged(bool isPlaying);
79
80private:
81 void timerTick();
82 void flipTimerTick();
83 void playSounds(int frame);
84 bool skipFrame();
85
86 int mStartFrame = 1;
87 int mEndFrame = 60;
88
89 void updateStartFrame();
90 void updateEndFrame();
91
92 bool mIsLooping = false;
93 bool mIsPlaySound = true;
94
95 bool mIsRangedPlayback = false;
96 int mMarkInFrame = 1;
97 int mMarkOutFrame = 10;
98 int mActiveSoundFrame = 0;
99
100 int mFps = 12;
101
102 int mFlipRollInterval = 100;
103 int mFlipInbetweenInterval = 100;
104 int mFlipRollMax = 5;
105 int mMsecSoundScrub = 100;
106 bool mSoundScrub = false;
107
108 QTimer* mTimer = nullptr;
109 QTimer* mFlipTimer = nullptr;
110 QTimer* mScrubTimer = nullptr;
111 QElapsedTimer* mElapsedTimer = nullptr;
112 int mPlayingFrameCounter = 0; // how many frames has passed after pressing play
113
114 bool mCheckForSoundsHalfway = false;
115 QVector<int> mListOfActiveSoundFrames;
116 QVector<SoundClip*> mSoundclipsToPLay;
117 QVector<int> mFlipList;
118};
119
120#endif // PLAYBACKMANAGER_H
BaseManager
Definition: basemanager.h:29
Editor
Definition: editor.h:71
Object
Definition: object.h:42
PlaybackManager
Definition: playbackmanager.h:30
PlaybackManager::skipFrame
bool skipFrame()
PlaybackManager::skipFrame() Small errors accumulate while playing animation If the error is greater ...
Definition: playbackmanager.cpp:338
SoundClip
Definition: soundclip.h:27
Status
Definition: pencilerror.h:40
QElapsedTimer
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QTimer
QVector
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39