123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- /*
- * Track.h - declaration of Track class
- *
- * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
- *
- * This file is part of LMMS - https://lmms.io
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program (see COPYING); if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- */
- #ifndef TRACK_H
- #define TRACK_H
- #include <QtCore/QVector>
- #include <QColor>
- #include "AutomatableModel.h"
- #include "JournallingObject.h"
- #include "lmms_basics.h"
- class TimePos;
- class TrackContainer;
- class TrackContainerView;
- class Clip;
- class TrackView;
- /*! The minimum track height in pixels
- *
- * Tracks can be resized by shift-dragging anywhere inside the track
- * display. This sets the minimum size in pixels for a track.
- */
- const int MINIMAL_TRACK_HEIGHT = 32;
- const int DEFAULT_TRACK_HEIGHT = 32;
- char const *const FILENAME_FILTER = "[\\0000-\x1f\"*/:<>?\\\\|\x7f]";
- //! Base-class for all tracks
- class LMMS_EXPORT Track : public Model, public JournallingObject
- {
- Q_OBJECT
- MM_OPERATORS
- mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
- mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
- public:
- typedef QVector<Clip *> clipVector;
- enum TrackTypes
- {
- InstrumentTrack,
- PatternTrack,
- SampleTrack,
- EventTrack,
- VideoTrack,
- AutomationTrack,
- HiddenAutomationTrack,
- NumTrackTypes
- } ;
- Track( TrackTypes type, TrackContainer * tc );
- virtual ~Track();
- static Track * create( TrackTypes tt, TrackContainer * tc );
- static Track * create( const QDomElement & element,
- TrackContainer * tc );
- Track * clone();
- // pure virtual functions
- TrackTypes type() const
- {
- return m_type;
- }
- virtual bool play( const TimePos & start, const fpp_t frames,
- const f_cnt_t frameBase, int clipNum = -1 ) = 0;
- virtual TrackView * createView( TrackContainerView * view ) = 0;
- virtual Clip * createClip( const TimePos & pos ) = 0;
- virtual void saveTrackSpecificSettings( QDomDocument & doc,
- QDomElement & parent ) = 0;
- virtual void loadTrackSpecificSettings( const QDomElement & element ) = 0;
- void saveSettings( QDomDocument & doc, QDomElement & element ) override;
- void loadSettings( const QDomElement & element ) override;
- void setSimpleSerializing()
- {
- m_simpleSerializingMode = true;
- }
- // -- for usage by Clip only ---------------
- Clip * addClip( Clip * clip );
- void removeClip( Clip * clip );
- // -------------------------------------------------------
- void deleteClips();
- int numOfClips();
- Clip * getClip( int clipNum );
- int getClipNum(const Clip* clip );
- const clipVector & getClips() const
- {
- return m_clips;
- }
- void getClipsInRange( clipVector & clipV, const TimePos & start,
- const TimePos & end );
- void swapPositionOfClips( int clipNum1, int clipNum2 );
- void createClipsForPattern(int pattern);
- void insertBar( const TimePos & pos );
- void removeBar( const TimePos & pos );
- bar_t length() const;
- inline TrackContainer* trackContainer() const
- {
- return m_trackContainer;
- }
- // name-stuff
- virtual const QString & name() const
- {
- return m_name;
- }
- QString displayName() const override
- {
- return name();
- }
- using Model::dataChanged;
- inline int getHeight()
- {
- return m_height >= MINIMAL_TRACK_HEIGHT
- ? m_height
- : DEFAULT_TRACK_HEIGHT;
- }
- inline void setHeight( int height )
- {
- m_height = height;
- }
- void lock()
- {
- m_processingLock.lock();
- }
- void unlock()
- {
- m_processingLock.unlock();
- }
- bool tryLock()
- {
- return m_processingLock.tryLock();
- }
-
- QColor color()
- {
- return m_color;
- }
- bool useColor()
- {
- return m_hasColor;
- }
- bool isMutedBeforeSolo() const
- {
- return m_mutedBeforeSolo;
- }
-
- BoolModel* getMutedModel();
- public slots:
- virtual void setName( const QString & newName )
- {
- m_name = newName;
- emit nameChanged();
- }
- void setMutedBeforeSolo(const bool muted)
- {
- m_mutedBeforeSolo = muted;
- }
- void toggleSolo();
- void setColor(const QColor& c);
- void resetColor();
- private:
- TrackContainer* m_trackContainer;
- TrackTypes m_type;
- QString m_name;
- int m_height;
- protected:
- BoolModel m_mutedModel;
- private:
- BoolModel m_soloModel;
- bool m_mutedBeforeSolo;
- bool m_simpleSerializingMode;
- clipVector m_clips;
- QMutex m_processingLock;
-
- QColor m_color;
- bool m_hasColor;
- friend class TrackView;
- signals:
- void destroyedTrack();
- void nameChanged();
- void clipAdded( Clip * );
- void colorChanged();
- } ;
- #endif
|