mirror of
https://github.com/LMMS/lmms.git
synced 2025-12-23 22:58:33 -05:00
This bug was noticed when testing out #7559, but the PR had been open for over a year, so it was decided to merge it and fix it in this one. Basically, when adding or removing a track, the TrackContainer sends out signals such as trackAdded or trackRemoved which PatternClipView uses to know when to update. However, it does not send out a signal when a track has been moved. This is because for some reason, it's done by the GUI TrackContainerView instead of the core TrackContainer. This PR changes that by moving the core code to the core where it probably belongs, adding an appropriate trackMoved signal to TrackContainer, and connecting that to PatternClipView to update properly. --------- Co-authored-by: Fawn <rubiefawn@gmail.com>
125 lines
2.6 KiB
C++
125 lines
2.6 KiB
C++
/*
|
|
* TrackContainer.h - base-class for all track-containers like Song-Editor,
|
|
* Pattern Editor...
|
|
*
|
|
* Copyright (c) 2004-2009 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 LMMS_TRACK_CONTAINER_H
|
|
#define LMMS_TRACK_CONTAINER_H
|
|
|
|
#include <QReadWriteLock>
|
|
|
|
#include "Track.h"
|
|
#include "JournallingObject.h"
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
class AutomationClip;
|
|
class InstrumentTrack;
|
|
|
|
namespace gui
|
|
{
|
|
|
|
class TrackContainerView;
|
|
|
|
}
|
|
|
|
|
|
class LMMS_EXPORT TrackContainer : public Model, public JournallingObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
using TrackList = std::vector<Track*>;
|
|
enum class Type
|
|
{
|
|
Pattern,
|
|
Song
|
|
} ;
|
|
|
|
TrackContainer();
|
|
~TrackContainer() override;
|
|
|
|
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
|
|
|
|
void loadSettings( const QDomElement & _this ) override;
|
|
|
|
int countTracks( Track::Type _tt = Track::Type::Count ) const;
|
|
|
|
|
|
void addTrack( Track * _track );
|
|
void removeTrack( Track * _track );
|
|
void moveTrack(Track* track, int indexTo);
|
|
|
|
virtual void updateAfterTrackAdd();
|
|
|
|
void clearAllTracks();
|
|
|
|
const TrackList & tracks() const
|
|
{
|
|
return m_tracks;
|
|
}
|
|
|
|
bool isEmpty() const;
|
|
|
|
static const QString classNodeName()
|
|
{
|
|
return "trackcontainer";
|
|
}
|
|
|
|
inline void setType( Type newType )
|
|
{
|
|
m_TrackContainerType = newType;
|
|
}
|
|
|
|
inline Type type() const
|
|
{
|
|
return m_TrackContainerType;
|
|
}
|
|
|
|
virtual AutomatedValueMap automatedValuesAt(TimePos time, int clipNum = -1) const;
|
|
|
|
signals:
|
|
void trackAdded( lmms::Track * _track );
|
|
void trackRemoved();
|
|
void trackMoved();
|
|
|
|
protected:
|
|
static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int clipNum = -1);
|
|
|
|
mutable QReadWriteLock m_tracksMutex;
|
|
|
|
private:
|
|
TrackList m_tracks;
|
|
|
|
Type m_TrackContainerType;
|
|
|
|
|
|
friend class gui::TrackContainerView;
|
|
friend class Track;
|
|
|
|
} ;
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_TRACK_CONTAINER_H
|