NAP
sequencecontroller.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 #include "sequenceplayer.h"
8 #include "sequence.h"
9 
10 #include <nap/core.h>
11 #include <functional>
12 
13 namespace nap
14 {
16 
17  // forward declares
18  class SequenceController;
19  class SequenceEditor;
20  class SequenceService;
21 
25  class NAPAPI SequenceController
26  {
27  RTTI_ENABLE()
28  public:
36  : mService(service), mPlayer(player), mEditor(editor) {};
37 
41  virtual ~SequenceController() = default;
42 
48  void changeTrackName(const std::string& trackID, const std::string& name);
49 
56  void changeSegmentLabel(const std::string& trackID, const std::string& segmentID, const std::string& newLabel);
57 
64  void assignNewOutputID(const std::string& trackID, const std::string& outputID);
65 
70  void deleteTrack(const std::string& deleteTrackID);
71 
76  void moveTrackUp(const std::string& trackID);
77 
82  void moveTrackDown(const std::string& trackID);
83 
88  virtual void insertTrack(rttr::type type) = 0;
89 
96  virtual const SequenceTrackSegment* insertSegment(const std::string& trackID, double time) = 0;
97 
103  virtual void deleteSegment(const std::string& trackID, const std::string& segmentID) = 0;
104 
110  const SequenceTrack* getTrack(const std::string& trackID) const;
111 
118  const SequenceTrackSegment* getSegment(const std::string& trackID, const std::string& segmentID) const;
119 
125  void changeTrackHeight(const std::string& trackID, float newHeight);
126 
127  protected:
131  Sequence& getSequence() { return mPlayer.getSequence(); }
132 
133 
140  SequenceTrackSegment* findSegment(const std::string& trackID, const std::string& segmentID);
141 
147  SequenceTrack* findTrack(const std::string& trackID);
148 
153  void deleteObjectFromSequencePlayer(const std::string &id);
154 
158  void updateTracks();
159 
164  void performEditAction(std::function<void()> action);
165 
166 
167  // objects owned by sequence player
168  std::vector<std::unique_ptr<rtti::Object>>& getPlayerOwnedObjects() { return mPlayer.mReadObjects; };
169 
170 
171  // read object ids from sequence
172  std::unordered_set<std::string>& getPlayerReadObjectIDs() { return mPlayer.mReadObjectIDs; };
173 
174  // reference to player
175  SequencePlayer &mPlayer;
176 
177  // reference to editor
179 
180  // reference to service
182  };
183 }
nap::SequencePlayer
Definition: sequenceplayer.h:36
nap::SequenceEditor
Definition: sequenceeditor.h:32
nap::SequenceController
Definition: sequencecontroller.h:25
nap::SequenceService
Definition: sequenceservice.h:42
nap::SequenceTrackSegment
Definition: sequencetracksegment.h:19
nap::SequenceTrack
Definition: sequencetrack.h:22
nap::SequenceController::getSequence
Sequence & getSequence()
Definition: sequencecontroller.h:131
nap::SequenceController::mService
SequenceService & mService
Definition: sequencecontroller.h:181
nap::SequenceController::mEditor
SequenceEditor & mEditor
Definition: sequencecontroller.h:178
nap::SequenceController::getPlayerOwnedObjects
std::vector< std::unique_ptr< rtti::Object > > & getPlayerOwnedObjects()
Definition: sequencecontroller.h:168
nap
Definition: templateapp.h:17
nap::Sequence
Definition: sequence.h:22
nap::SequenceController::SequenceController
SequenceController(SequenceService &service, SequencePlayer &player, SequenceEditor &editor)
Definition: sequencecontroller.h:35