wrote mechanisms that allow the tracks to be resized from the trackview
This commit is contained in:
@@ -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