wrote mechanisms that allow the tracks to be resized from the trackview
This commit is contained in:
@@ -46,6 +46,7 @@ TimelineOutput::TimelineOutput()
|
||||
connect(list, SIGNAL(BlockRemoved(Block*)), this, SIGNAL(BlockRemoved(Block*)));
|
||||
connect(list, SIGNAL(TrackAdded(TrackOutput*)), this, SLOT(TrackListAddedTrack(TrackOutput*)));
|
||||
connect(list, SIGNAL(TrackRemoved(TrackOutput*)), this, SIGNAL(TrackRemoved(TrackOutput*)));
|
||||
connect(list, SIGNAL(TrackHeightChanged(int, int)), this, SLOT(TrackHeightChangedSlot(int, int)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,3 +197,8 @@ void TimelineOutput::TrackListAddedTrack(TrackOutput *track)
|
||||
TrackType type = static_cast<TrackList*>(sender())->TrackType();
|
||||
emit TrackAdded(track, type);
|
||||
}
|
||||
|
||||
void TimelineOutput::TrackHeightChangedSlot(int index, int height)
|
||||
{
|
||||
emit TrackHeightChanged(static_cast<TrackList*>(sender())->type(), index, height);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ signals:
|
||||
void TrackAdded(TrackOutput* track, TrackType type);
|
||||
void TrackRemoved(TrackOutput* track);
|
||||
|
||||
void TrackHeightChanged(TrackType type, int index, int height);
|
||||
|
||||
protected:
|
||||
virtual NodeValueTable Value(const NodeValueDatabase& value) const override;
|
||||
|
||||
@@ -93,6 +95,8 @@ private slots:
|
||||
|
||||
void TrackListAddedTrack(TrackOutput* track);
|
||||
|
||||
void TrackHeightChangedSlot(int index, int height);
|
||||
|
||||
};
|
||||
|
||||
#endif // TIMELINEOUTPUT_H
|
||||
|
||||
@@ -33,6 +33,11 @@ TrackList::TrackList(TimelineOutput* parent, const enum TrackType &type, NodeInp
|
||||
connect(track_input, SIGNAL(SizeChanged(int)), this, SLOT(TrackListSizeChanged(int)));
|
||||
}
|
||||
|
||||
const TrackType &TrackList::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
void TrackList::TrackAddedBlock(Block *block)
|
||||
{
|
||||
emit BlockAdded(block, static_cast<TrackOutput*>(sender())->Index());
|
||||
@@ -55,12 +60,12 @@ void TrackList::TrackListSizeChanged(int size)
|
||||
}
|
||||
}
|
||||
|
||||
const QVector<TrackOutput *> &TrackList::Tracks()
|
||||
const QVector<TrackOutput *> &TrackList::Tracks() const
|
||||
{
|
||||
return track_cache_;
|
||||
}
|
||||
|
||||
TrackOutput *TrackList::TrackAt(int index)
|
||||
TrackOutput *TrackList::TrackAt(int index) const
|
||||
{
|
||||
if (index < 0 || index >= track_cache_.size()) {
|
||||
return nullptr;
|
||||
@@ -69,16 +74,21 @@ TrackOutput *TrackList::TrackAt(int index)
|
||||
return track_cache_.at(index);
|
||||
}
|
||||
|
||||
const rational &TrackList::TrackLength()
|
||||
const rational &TrackList::TrackLength() const
|
||||
{
|
||||
return total_length_;
|
||||
}
|
||||
|
||||
const enum TrackType &TrackList::TrackType()
|
||||
const enum TrackType &TrackList::TrackType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
int TrackList::TrackCount() const
|
||||
{
|
||||
return track_cache_.size();
|
||||
}
|
||||
|
||||
TrackOutput* TrackList::AddTrack()
|
||||
{
|
||||
TrackOutput* track = new TrackOutput();
|
||||
@@ -104,9 +114,6 @@ TrackOutput* TrackList::AddTrack()
|
||||
}*/
|
||||
// End test code
|
||||
|
||||
// Connect this track to the current last track
|
||||
NodeParam::ConnectEdge(track->output(), assoc_input);
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
@@ -132,13 +139,14 @@ void TrackList::TrackConnected(NodeEdgePtr edge)
|
||||
Node* connected_node = edge->output()->parentNode();
|
||||
|
||||
if (connected_node->IsTrack()) {
|
||||
TrackOutput* connected_track = static_cast<TrackOutput*>(connected_node);// Traverse through Tracks caching and connecting them
|
||||
TrackOutput* connected_track = static_cast<TrackOutput*>(connected_node);
|
||||
|
||||
track_cache_.replace(track_index, connected_track);
|
||||
|
||||
connect(connected_track, SIGNAL(BlockAdded(Block*)), this, SLOT(TrackAddedBlock(Block*)));
|
||||
connect(connected_track, SIGNAL(BlockRemoved(Block*)), this, SLOT(TrackRemovedBlock(Block*)));
|
||||
connect(connected_track, SIGNAL(TrackLengthChanged()), this, SLOT(UpdateTotalLength()));
|
||||
connect(connected_track, SIGNAL(TrackHeightChanged(int)), this, SLOT(TrackHeightChangedSlot(int)));
|
||||
|
||||
connected_track->SetIndex(track_index);
|
||||
connected_track->set_track_type(type_);
|
||||
@@ -175,6 +183,7 @@ void TrackList::TrackDisconnected(NodeEdgePtr edge)
|
||||
disconnect(track, SIGNAL(BlockAdded(Block*)), this, SLOT(TrackAddedBlock(Block*)));
|
||||
disconnect(track, SIGNAL(BlockRemoved(Block*)), this, SLOT(TrackRemovedBlock(Block*)));
|
||||
disconnect(track, SIGNAL(TrackLengthChanged()), this, SLOT(UpdateTotalLength()));
|
||||
disconnect(track, SIGNAL(TrackHeightChanged(int)), this, SLOT(TrackHeightChangedSlot(int)));
|
||||
|
||||
emit TrackListChanged();
|
||||
|
||||
@@ -182,7 +191,7 @@ void TrackList::TrackDisconnected(NodeEdgePtr edge)
|
||||
}
|
||||
}
|
||||
|
||||
NodeGraph *TrackList::GetParentGraph()
|
||||
NodeGraph *TrackList::GetParentGraph() const
|
||||
{
|
||||
return static_cast<NodeGraph*>(parent()->parent());
|
||||
}
|
||||
@@ -199,3 +208,8 @@ void TrackList::UpdateTotalLength()
|
||||
|
||||
emit LengthChanged(total_length_);
|
||||
}
|
||||
|
||||
void TrackList::TrackHeightChangedSlot(int height)
|
||||
{
|
||||
emit TrackHeightChanged(static_cast<TrackOutput*>(sender())->Index(), height);
|
||||
}
|
||||
|
||||
@@ -34,17 +34,21 @@ class TrackList : public QObject {
|
||||
public:
|
||||
TrackList(TimelineOutput *parent, const enum TrackType& type, NodeInputArray* track_input);
|
||||
|
||||
const QVector<TrackOutput*>& Tracks();
|
||||
const enum TrackType& type() const;
|
||||
|
||||
TrackOutput* TrackAt(int index);
|
||||
const QVector<TrackOutput*>& Tracks() const;
|
||||
|
||||
TrackOutput* TrackAt(int index) const;
|
||||
|
||||
TrackOutput *AddTrack();
|
||||
|
||||
void RemoveTrack();
|
||||
|
||||
const rational& TrackLength();
|
||||
const rational& TrackLength() const;
|
||||
|
||||
const enum TrackType& TrackType();
|
||||
const enum TrackType& TrackType() const;
|
||||
|
||||
int TrackCount() const;
|
||||
|
||||
signals:
|
||||
void BlockAdded(Block* block, int index);
|
||||
@@ -59,8 +63,10 @@ signals:
|
||||
|
||||
void LengthChanged(const rational &length);
|
||||
|
||||
void TrackHeightChanged(int index, int height);
|
||||
|
||||
private:
|
||||
NodeGraph* GetParentGraph();
|
||||
NodeGraph* GetParentGraph() const;
|
||||
|
||||
/**
|
||||
* @brief A cache of connected Tracks
|
||||
@@ -104,6 +110,11 @@ private slots:
|
||||
*/
|
||||
void UpdateTotalLength();
|
||||
|
||||
/**
|
||||
* @brief Slot when a track height changes, transforms to the TrackHeightChanged signal which includes a track index
|
||||
*/
|
||||
void TrackHeightChangedSlot(int height);
|
||||
|
||||
};
|
||||
|
||||
#endif // TRACKLIST_H
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
#include "track.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/graph.h"
|
||||
@@ -35,6 +37,9 @@ TrackOutput::TrackOutput() :
|
||||
connect(block_input_, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SLOT(BlockConnected(NodeEdgePtr)));
|
||||
connect(block_input_, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SLOT(BlockDisconnected(NodeEdgePtr)));
|
||||
connect(block_input_, SIGNAL(SizeChanged(int)), this, SLOT(BlockListSizeChanged(int)));
|
||||
|
||||
// Set default height
|
||||
track_height_ = GetDefaultTrackHeight();
|
||||
}
|
||||
|
||||
void TrackOutput::set_track_type(const TrackType &track_type)
|
||||
@@ -78,6 +83,26 @@ QString TrackOutput::Description() const
|
||||
"a Sequence.");
|
||||
}
|
||||
|
||||
QString TrackOutput::GetTrackName()
|
||||
{
|
||||
if (track_name_.isEmpty()) {
|
||||
return GetDefaultTrackName(track_type_, index_);
|
||||
}
|
||||
|
||||
return track_name_;
|
||||
}
|
||||
|
||||
const int &TrackOutput::GetTrackHeight() const
|
||||
{
|
||||
return track_height_;
|
||||
}
|
||||
|
||||
void TrackOutput::SetTrackHeight(const int &height)
|
||||
{
|
||||
track_height_ = height;
|
||||
emit TrackHeightChanged(track_height_);
|
||||
}
|
||||
|
||||
void TrackOutput::Retranslate()
|
||||
{
|
||||
block_input_->set_name(tr("Blocks"));
|
||||
@@ -310,6 +335,33 @@ bool TrackOutput::IsTrack() const
|
||||
return true;
|
||||
}
|
||||
|
||||
int TrackOutput::GetDefaultTrackHeight()
|
||||
{
|
||||
return qApp->fontMetrics().height() * 3;
|
||||
}
|
||||
|
||||
QString TrackOutput::GetDefaultTrackName(TrackType type, int index)
|
||||
{
|
||||
// Starts tracks at 1 rather than 0
|
||||
int user_friendly_index = index+1;
|
||||
|
||||
switch (type) {
|
||||
case kTrackTypeVideo: return tr("Video %1").arg(user_friendly_index);
|
||||
case kTrackTypeAudio: return tr("Audio %1").arg(user_friendly_index);
|
||||
case kTrackTypeSubtitle: return tr("Subtitle %1").arg(user_friendly_index);
|
||||
case kTrackTypeNone:
|
||||
case kTrackTypeCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return tr("Track %1").arg(user_friendly_index);
|
||||
}
|
||||
|
||||
void TrackOutput::SetTrackName(const QString &name)
|
||||
{
|
||||
track_name_ = name;
|
||||
}
|
||||
|
||||
void TrackOutput::UpdateInOutFrom(int index)
|
||||
{
|
||||
Q_ASSERT(index >= 0);
|
||||
|
||||
@@ -45,6 +45,11 @@ public:
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
QString GetTrackName();
|
||||
|
||||
const int& GetTrackHeight() const;
|
||||
void SetTrackHeight(const int& height);
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
const int& Index();
|
||||
@@ -127,6 +132,13 @@ public:
|
||||
|
||||
virtual bool IsTrack() const override;
|
||||
|
||||
static int GetDefaultTrackHeight();
|
||||
|
||||
static QString GetDefaultTrackName(TrackType type, int index);
|
||||
|
||||
public slots:
|
||||
void SetTrackName(const QString& name);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when a Block is added to this Track
|
||||
@@ -143,6 +155,11 @@ signals:
|
||||
*/
|
||||
void TrackLengthChanged();
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the height of the track has changed
|
||||
*/
|
||||
void TrackHeightChanged(int height);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
@@ -158,6 +175,10 @@ private:
|
||||
|
||||
rational track_length_;
|
||||
|
||||
int track_height_;
|
||||
|
||||
QString track_name_;
|
||||
|
||||
int block_invalidate_cache_stack_;
|
||||
|
||||
int index_;
|
||||
|
||||
Reference in New Issue
Block a user