moved timeline tracktypes into timelinecommon.h
This commit is contained in:
@@ -10,6 +10,14 @@ public:
|
||||
kTrimOut
|
||||
};
|
||||
|
||||
enum TrackType {
|
||||
kTrackTypeNone = -1,
|
||||
kTrackTypeVideo,
|
||||
kTrackTypeAudio,
|
||||
kTrackTypeSubtitle,
|
||||
kTrackTypeCount
|
||||
};
|
||||
|
||||
static bool IsATrimMode(MovementMode mode) {return mode == kTrimIn || mode == kTrimOut;}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "node/graph.h"
|
||||
|
||||
TrackOutput::TrackOutput() :
|
||||
track_type_(kTrackTypeNone),
|
||||
track_type_(Timeline::kTrackTypeNone),
|
||||
block_invalidate_cache_stack_(0),
|
||||
index_(-1),
|
||||
locked_(false)
|
||||
@@ -48,12 +48,12 @@ TrackOutput::TrackOutput() :
|
||||
track_height_ = GetDefaultTrackHeight();
|
||||
}
|
||||
|
||||
void TrackOutput::set_track_type(const TrackType &track_type)
|
||||
void TrackOutput::set_track_type(const Timeline::TrackType &track_type)
|
||||
{
|
||||
track_type_ = track_type;
|
||||
}
|
||||
|
||||
const TrackType& TrackOutput::track_type()
|
||||
const Timeline::TrackType& TrackOutput::track_type()
|
||||
{
|
||||
return track_type_;
|
||||
}
|
||||
@@ -343,17 +343,17 @@ int TrackOutput::GetTrackHeightMinimum()
|
||||
return qApp->fontMetrics().height() * 3 / 2;
|
||||
}
|
||||
|
||||
QString TrackOutput::GetDefaultTrackName(TrackType type, int index)
|
||||
QString TrackOutput::GetDefaultTrackName(Timeline::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:
|
||||
case Timeline::kTrackTypeVideo: return tr("Video %1").arg(user_friendly_index);
|
||||
case Timeline::kTrackTypeAudio: return tr("Audio %1").arg(user_friendly_index);
|
||||
case Timeline::kTrackTypeSubtitle: return tr("Subtitle %1").arg(user_friendly_index);
|
||||
case Timeline::kTrackTypeNone:
|
||||
case Timeline::kTrackTypeCount:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#ifndef TRACKOUTPUT_H
|
||||
#define TRACKOUTPUT_H
|
||||
|
||||
#include "common/timelinecommon.h"
|
||||
#include "node/block/block.h"
|
||||
#include "timeline/tracktypes.h"
|
||||
|
||||
/**
|
||||
* @brief A time traversal Node for sorting through one channel/track of Blocks
|
||||
@@ -33,8 +33,8 @@ class TrackOutput : public Block
|
||||
public:
|
||||
TrackOutput();
|
||||
|
||||
const TrackType& track_type();
|
||||
void set_track_type(const TrackType& track_type);
|
||||
const Timeline::TrackType& track_type();
|
||||
void set_track_type(const Timeline::TrackType& track_type);
|
||||
|
||||
virtual Type type() const override;
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
|
||||
static int GetTrackHeightMinimum();
|
||||
|
||||
static QString GetDefaultTrackName(TrackType type, int index);
|
||||
static QString GetDefaultTrackName(Timeline::TrackType type, int index);
|
||||
|
||||
bool IsMuted() const;
|
||||
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
|
||||
NodeInput* muted_input_;
|
||||
|
||||
TrackType track_type_;
|
||||
Timeline::TrackType track_type_;
|
||||
|
||||
rational track_length_;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "node/factory.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
|
||||
TrackList::TrackList(ViewerOutput *parent, const enum TrackType &type, NodeInputArray *track_input) :
|
||||
TrackList::TrackList(ViewerOutput *parent, const Timeline::TrackType &type, NodeInputArray *track_input) :
|
||||
QObject(parent),
|
||||
track_input_(track_input),
|
||||
type_(type)
|
||||
@@ -33,7 +33,7 @@ TrackList::TrackList(ViewerOutput *parent, const enum TrackType &type, NodeInput
|
||||
connect(track_input, SIGNAL(SizeChanged(int)), this, SLOT(TrackListSizeChanged(int)));
|
||||
}
|
||||
|
||||
const TrackType &TrackList::type() const
|
||||
const Timeline::TrackType &TrackList::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
@@ -79,11 +79,6 @@ const rational &TrackList::TrackLength() const
|
||||
return total_length_;
|
||||
}
|
||||
|
||||
const enum TrackType &TrackList::TrackType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
int TrackList::TrackCount() const
|
||||
{
|
||||
return track_cache_.size();
|
||||
@@ -195,7 +190,7 @@ void TrackList::TrackDisconnected(NodeEdgePtr edge)
|
||||
emit TrackRemoved(track);
|
||||
|
||||
track->SetIndex(-1);
|
||||
track->set_track_type(kTrackTypeNone);
|
||||
track->set_track_type(Timeline::kTrackTypeNone);
|
||||
|
||||
disconnect(track, SIGNAL(BlockAdded(Block*)), this, SLOT(TrackAddedBlock(Block*)));
|
||||
disconnect(track, SIGNAL(BlockRemoved(Block*)), this, SLOT(TrackRemovedBlock(Block*)));
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "common/timelinecommon.h"
|
||||
#include "node/graph.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "timeline/tracktypes.h"
|
||||
|
||||
class ViewerOutput;
|
||||
|
||||
class TrackList : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TrackList(ViewerOutput *parent, const enum TrackType& type, NodeInputArray* track_input);
|
||||
TrackList(ViewerOutput *parent, const Timeline::TrackType& type, NodeInputArray* track_input);
|
||||
|
||||
const enum TrackType& type() const;
|
||||
const Timeline::TrackType& type() const;
|
||||
|
||||
const QVector<TrackOutput*>& Tracks() const;
|
||||
|
||||
@@ -46,8 +46,6 @@ public:
|
||||
|
||||
const rational& TrackLength() const;
|
||||
|
||||
const enum TrackType& TrackType() const;
|
||||
|
||||
int TrackCount() const;
|
||||
|
||||
signals:
|
||||
@@ -77,7 +75,7 @@ private:
|
||||
|
||||
rational total_length_;
|
||||
|
||||
enum TrackType type_;
|
||||
enum Timeline::TrackType type_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
|
||||
@@ -32,16 +32,16 @@ ViewerOutput::ViewerOutput()
|
||||
AddInput(length_input_);
|
||||
|
||||
// Create TrackList instances
|
||||
track_inputs_.resize(kTrackTypeCount);
|
||||
track_lists_.resize(kTrackTypeCount);
|
||||
track_inputs_.resize(Timeline::kTrackTypeCount);
|
||||
track_lists_.resize(Timeline::kTrackTypeCount);
|
||||
|
||||
for (int i=0;i<kTrackTypeCount;i++) {
|
||||
for (int i=0;i<Timeline::kTrackTypeCount;i++) {
|
||||
// Create track input
|
||||
NodeInputArray* track_input = new NodeInputArray(QStringLiteral("track_in_%1").arg(i), NodeParam::kAny);
|
||||
AddInput(track_input);
|
||||
track_inputs_.replace(i, track_input);
|
||||
|
||||
TrackList* list = new TrackList(this, static_cast<TrackType>(i), track_input);
|
||||
TrackList* list = new TrackList(this, static_cast<Timeline::TrackType>(i), track_input);
|
||||
track_lists_.replace(i, list);
|
||||
connect(list, SIGNAL(TrackListChanged()), this, SLOT(UpdateTrackCache()));
|
||||
connect(list, SIGNAL(LengthChanged(const rational &)), this, SLOT(UpdateLength(const rational &)));
|
||||
@@ -213,18 +213,18 @@ void ViewerOutput::Retranslate()
|
||||
for (int i=0;i<track_inputs_.size();i++) {
|
||||
QString input_name;
|
||||
|
||||
switch (static_cast<TrackType>(i)) {
|
||||
case kTrackTypeVideo:
|
||||
switch (static_cast<Timeline::TrackType>(i)) {
|
||||
case Timeline::kTrackTypeVideo:
|
||||
input_name = tr("Video Tracks");
|
||||
break;
|
||||
case kTrackTypeAudio:
|
||||
case Timeline::kTrackTypeAudio:
|
||||
input_name = tr("Audio Tracks");
|
||||
break;
|
||||
case kTrackTypeSubtitle:
|
||||
case Timeline::kTrackTypeSubtitle:
|
||||
input_name = tr("Subtitle Tracks");
|
||||
break;
|
||||
case kTrackTypeNone:
|
||||
case kTrackTypeCount:
|
||||
case Timeline::kTrackTypeNone:
|
||||
case Timeline::kTrackTypeCount:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -238,25 +238,25 @@ const QVector<TrackOutput *>& ViewerOutput::Tracks() const
|
||||
return track_cache_;
|
||||
}
|
||||
|
||||
NodeInput *ViewerOutput::track_input(TrackType type) const
|
||||
NodeInput *ViewerOutput::track_input(Timeline::TrackType type) const
|
||||
{
|
||||
return track_inputs_.at(type);
|
||||
}
|
||||
|
||||
TrackList *ViewerOutput::track_list(TrackType type) const
|
||||
TrackList *ViewerOutput::track_list(Timeline::TrackType type) const
|
||||
{
|
||||
return track_lists_.at(type);
|
||||
}
|
||||
|
||||
void ViewerOutput::TrackListAddedBlock(Block *block, int index)
|
||||
{
|
||||
TrackType type = static_cast<TrackList*>(sender())->TrackType();
|
||||
Timeline::TrackType type = static_cast<TrackList*>(sender())->type();
|
||||
emit BlockAdded(block, TrackReference(type, index));
|
||||
}
|
||||
|
||||
void ViewerOutput::TrackListAddedTrack(TrackOutput *track)
|
||||
{
|
||||
TrackType type = static_cast<TrackList*>(sender())->TrackType();
|
||||
Timeline::TrackType type = static_cast<TrackList*>(sender())->type();
|
||||
emit TrackAdded(track, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "render/videoparams.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "timeline/trackreference.h"
|
||||
#include "timeline/tracktypes.h"
|
||||
|
||||
/**
|
||||
* @brief A bridge between a node system and a ViewerPanel
|
||||
@@ -69,9 +68,9 @@ public:
|
||||
|
||||
const QVector<TrackOutput *> &Tracks() const;
|
||||
|
||||
NodeInput* track_input(TrackType type) const;
|
||||
NodeInput* track_input(Timeline::TrackType type) const;
|
||||
|
||||
TrackList* track_list(TrackType type) const;
|
||||
TrackList* track_list(Timeline::TrackType type) const;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
@@ -96,10 +95,10 @@ signals:
|
||||
void BlockAdded(Block* block, TrackReference track);
|
||||
void BlockRemoved(Block* block);
|
||||
|
||||
void TrackAdded(TrackOutput* track, TrackType type);
|
||||
void TrackAdded(TrackOutput* track, Timeline::TrackType type);
|
||||
void TrackRemoved(TrackOutput* track);
|
||||
|
||||
void TrackHeightChanged(TrackType type, int index, int height);
|
||||
void TrackHeightChanged(Timeline::TrackType type, int index, int height);
|
||||
|
||||
private:
|
||||
QUuid uuid_;
|
||||
|
||||
@@ -58,8 +58,8 @@ void Sequence::add_default_nodes()
|
||||
AddNode(viewer_output_);
|
||||
|
||||
// Create tracks and connect them to the viewer
|
||||
Node* video_track_output = viewer_output_->track_list(TrackType::kTrackTypeVideo)->AddTrack();
|
||||
Node* audio_track_output = viewer_output_->track_list(TrackType::kTrackTypeAudio)->AddTrack();
|
||||
Node* video_track_output = viewer_output_->track_list(Timeline::kTrackTypeVideo)->AddTrack();
|
||||
Node* audio_track_output = viewer_output_->track_list(Timeline::kTrackTypeAudio)->AddTrack();
|
||||
NodeParam::ConnectEdge(video_track_output->output(), viewer_output_->texture_input());
|
||||
NodeParam::ConnectEdge(audio_track_output->output(), viewer_output_->samples_input());
|
||||
//timeline_output_->track_list(TrackType::kTrackTypeVideo)->AddTrack();
|
||||
|
||||
@@ -20,6 +20,5 @@ set(OLIVE_SOURCES
|
||||
timeline/timelinecoordinate.cpp
|
||||
timeline/trackreference.h
|
||||
timeline/trackreference.cpp
|
||||
timeline/tracktypes.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "timelinecoordinate.h"
|
||||
|
||||
TimelineCoordinate::TimelineCoordinate() :
|
||||
track_(kTrackTypeNone, 0)
|
||||
track_(Timeline::kTrackTypeNone, 0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ TimelineCoordinate::TimelineCoordinate(const rational &frame, const TrackReferen
|
||||
{
|
||||
}
|
||||
|
||||
TimelineCoordinate::TimelineCoordinate(const rational &frame, const TrackType &track_type, const int &track_index) :
|
||||
TimelineCoordinate::TimelineCoordinate(const rational &frame, const Timeline::TrackType &track_type, const int &track_index) :
|
||||
frame_(frame),
|
||||
track_(track_type, track_index)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class TimelineCoordinate
|
||||
public:
|
||||
TimelineCoordinate();
|
||||
TimelineCoordinate(const rational& frame, const TrackReference& track);
|
||||
TimelineCoordinate(const rational& frame, const TrackType& track_type, const int& track_index);
|
||||
TimelineCoordinate(const rational& frame, const Timeline::TrackType& track_type, const int& track_index);
|
||||
|
||||
const rational& GetFrame() const;
|
||||
const TrackReference& GetTrack() const;
|
||||
|
||||
@@ -21,18 +21,18 @@
|
||||
#include "trackreference.h"
|
||||
|
||||
TrackReference::TrackReference() :
|
||||
type_(kTrackTypeNone),
|
||||
type_(Timeline::kTrackTypeNone),
|
||||
index_(0)
|
||||
{
|
||||
}
|
||||
|
||||
TrackReference::TrackReference(const TrackType &type, const int &index) :
|
||||
TrackReference::TrackReference(const Timeline::TrackType &type, const int &index) :
|
||||
type_(type),
|
||||
index_(index)
|
||||
{
|
||||
}
|
||||
|
||||
const TrackType &TrackReference::type() const
|
||||
const Timeline::TrackType &TrackReference::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
@@ -21,23 +21,23 @@
|
||||
#ifndef TRACKREFERENCE_H
|
||||
#define TRACKREFERENCE_H
|
||||
|
||||
#include "timeline/tracktypes.h"
|
||||
#include "common/timelinecommon.h"
|
||||
|
||||
class TrackReference
|
||||
{
|
||||
public:
|
||||
TrackReference();
|
||||
|
||||
TrackReference(const TrackType& type, const int& index);
|
||||
TrackReference(const Timeline::TrackType& type, const int& index);
|
||||
|
||||
const TrackType& type() const;
|
||||
const Timeline::TrackType& type() const;
|
||||
|
||||
const int& index() const;
|
||||
|
||||
bool operator==(const TrackReference& ref) const;
|
||||
|
||||
private:
|
||||
TrackType type_;
|
||||
Timeline::TrackType type_;
|
||||
|
||||
int index_;
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef TRACKTYPES_H
|
||||
#define TRACKTYPES_H
|
||||
|
||||
enum TrackType {
|
||||
kTrackTypeNone = -1,
|
||||
kTrackTypeVideo,
|
||||
kTrackTypeAudio,
|
||||
kTrackTypeSubtitle,
|
||||
kTrackTypeCount
|
||||
};
|
||||
|
||||
#endif // TRACKTYPES_H
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QScrollBar>
|
||||
|
||||
TimelineAndTrackView::TimelineAndTrackView(const TrackType &type, Qt::Alignment vertical_alignment, QWidget *parent) :
|
||||
TimelineAndTrackView::TimelineAndTrackView(Qt::Alignment vertical_alignment, QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
@@ -17,7 +17,7 @@ TimelineAndTrackView::TimelineAndTrackView(const TrackType &type, Qt::Alignment
|
||||
track_view_ = new TrackView(vertical_alignment);
|
||||
splitter_->addWidget(track_view_);
|
||||
|
||||
view_ = new TimelineView(type, vertical_alignment);
|
||||
view_ = new TimelineView(vertical_alignment);
|
||||
splitter_->addWidget(view_);
|
||||
|
||||
connect(view_->verticalScrollBar(), &QScrollBar::valueChanged, this, &TimelineAndTrackView::ViewValueChanged);
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
class TimelineAndTrackView : public QWidget
|
||||
{
|
||||
public:
|
||||
TimelineAndTrackView(const TrackType& type,
|
||||
Qt::Alignment vertical_alignment = Qt::AlignTop,
|
||||
TimelineAndTrackView(Qt::Alignment vertical_alignment = Qt::AlignTop,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
QSplitter* splitter() const;
|
||||
|
||||
@@ -45,10 +45,10 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
|
||||
vert_layout->addWidget(view_splitter);
|
||||
|
||||
// Video view
|
||||
views_.append(new TimelineAndTrackView(kTrackTypeVideo, Qt::AlignBottom));
|
||||
views_.append(new TimelineAndTrackView(Qt::AlignBottom));
|
||||
|
||||
// Audio view
|
||||
views_.append(new TimelineAndTrackView(kTrackTypeAudio, Qt::AlignTop));
|
||||
views_.append(new TimelineAndTrackView(Qt::AlignTop));
|
||||
|
||||
// Create tools
|
||||
tools_.resize(::Tool::kCount);
|
||||
@@ -216,7 +216,7 @@ void TimelineWidget::ConnectTimelineNode(ViewerOutput *node)
|
||||
SetTimebase(timeline_node_->video_params().time_base());
|
||||
|
||||
for (int i=0;i<views_.size();i++) {
|
||||
TrackType track_type = static_cast<TrackType>(i);
|
||||
Timeline::TrackType track_type = static_cast<Timeline::TrackType>(i);
|
||||
TimelineView* view = views_.at(i)->view();
|
||||
TrackList* track_list = timeline_node_->track_list(track_type);
|
||||
TrackView* track_view = views_.at(i)->track_view();
|
||||
@@ -757,7 +757,7 @@ void TimelineWidget::RemoveBlock(Block *block)
|
||||
block_items_.remove(block);
|
||||
}
|
||||
|
||||
void TimelineWidget::AddTrack(TrackOutput *track, TrackType type)
|
||||
void TimelineWidget::AddTrack(TrackOutput *track, Timeline::TrackType type)
|
||||
{
|
||||
foreach (Block* b, track->Blocks()) {
|
||||
AddBlock(b, TrackReference(type, track->Index()));
|
||||
@@ -802,7 +802,7 @@ void TimelineWidget::UpdateTimecodeWidthFromSplitters(QSplitter* s)
|
||||
timecode_label_->setFixedWidth(s->sizes().first() + s->handleWidth());
|
||||
}
|
||||
|
||||
void TimelineWidget::TrackHeightChanged(TrackType type, int index, int height)
|
||||
void TimelineWidget::TrackHeightChanged(Timeline::TrackType type, int index, int height)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
Q_UNUSED(height)
|
||||
|
||||
@@ -188,7 +188,7 @@ private:
|
||||
private:
|
||||
Timeline::MovementMode IsCursorInTrimHandle(TimelineViewBlockItem* block, qreal cursor_x);
|
||||
|
||||
void InitiateDrag(const TimelineCoordinate &mouse_pos);
|
||||
void InitiateDrag(TimelineViewMouseEvent *mouse_pos);
|
||||
|
||||
void AddGhostInternal(TimelineViewGhostItem* ghost, Timeline::MovementMode mode);
|
||||
|
||||
@@ -202,7 +202,7 @@ private:
|
||||
bool track_movement_allowed_;
|
||||
bool rubberband_selecting_;
|
||||
|
||||
TrackType drag_track_type_;
|
||||
Timeline::TrackType drag_track_type_;
|
||||
};
|
||||
|
||||
class ImportTool : public Tool
|
||||
@@ -404,7 +404,7 @@ private slots:
|
||||
void AddBlock(Block* block, TrackReference track);
|
||||
void RemoveBlock(Block* block);
|
||||
|
||||
void AddTrack(TrackOutput* track, TrackType type);
|
||||
void AddTrack(TrackOutput* track, Timeline::TrackType type);
|
||||
void RemoveTrack(TrackOutput* track);
|
||||
|
||||
/**
|
||||
@@ -419,7 +419,7 @@ private slots:
|
||||
|
||||
void UpdateTimecodeWidthFromSplitters(QSplitter *s);
|
||||
|
||||
void TrackHeightChanged(TrackType type, int index, int height);
|
||||
void TrackHeightChanged(Timeline::TrackType type, int index, int height);
|
||||
|
||||
void ShowContextMenu();
|
||||
|
||||
|
||||
@@ -32,23 +32,23 @@
|
||||
#include "node/input/media/video/video.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
|
||||
TrackType TrackTypeFromStreamType(Stream::Type stream_type)
|
||||
Timeline::TrackType TrackTypeFromStreamType(Stream::Type stream_type)
|
||||
{
|
||||
switch (stream_type) {
|
||||
case Stream::kVideo:
|
||||
case Stream::kImage:
|
||||
return kTrackTypeVideo;
|
||||
return Timeline::kTrackTypeVideo;
|
||||
case Stream::kAudio:
|
||||
return kTrackTypeAudio;
|
||||
return Timeline::kTrackTypeAudio;
|
||||
case Stream::kSubtitle:
|
||||
return kTrackTypeSubtitle;
|
||||
return Timeline::kTrackTypeSubtitle;
|
||||
case Stream::kUnknown:
|
||||
case Stream::kData:
|
||||
case Stream::kAttachment:
|
||||
break;
|
||||
}
|
||||
|
||||
return kTrackTypeNone;
|
||||
return Timeline::kTrackTypeNone;
|
||||
}
|
||||
|
||||
TimelineWidget::ImportTool::ImportTool(TimelineWidget *parent) :
|
||||
@@ -96,17 +96,17 @@ void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
||||
Footage* footage = static_cast<Footage*>(item);
|
||||
|
||||
// Each stream is offset by one track per track "type", we keep track of them in this vector
|
||||
QVector<int> track_offsets(kTrackTypeCount);
|
||||
QVector<int> track_offsets(Timeline::kTrackTypeCount);
|
||||
track_offsets.fill(drag_start_.GetTrack().index());
|
||||
|
||||
rational footage_duration;
|
||||
|
||||
// Loop through all streams in footage
|
||||
foreach (StreamPtr stream, footage->streams()) {
|
||||
TrackType track_type = TrackTypeFromStreamType(stream->type());
|
||||
Timeline::TrackType track_type = TrackTypeFromStreamType(stream->type());
|
||||
|
||||
// Check if this stream has a compatible TrackList
|
||||
if (track_type == kTrackTypeNone || !stream->enabled()) {
|
||||
if (track_type == Timeline::kTrackTypeNone || !stream->enabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void TimelineWidget::PointerTool::MouseMove(TimelineViewMouseEvent *event)
|
||||
// Now that the cursor has moved, we will assume the intention is to drag
|
||||
|
||||
// If we haven't started dragging yet, we'll initiate a drag here
|
||||
InitiateDrag(event->GetCoordinates());
|
||||
InitiateDrag(event);
|
||||
|
||||
// Set dragging to true here so no matter what, the drag isn't re-initiated until it's completed
|
||||
dragging_ = true;
|
||||
@@ -284,10 +284,10 @@ rational TimelineWidget::PointerTool::FrameValidateInternal(rational time_moveme
|
||||
return time_movement;
|
||||
}
|
||||
|
||||
void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_pos)
|
||||
void TimelineWidget::PointerTool::InitiateDrag(TimelineViewMouseEvent *mouse_pos)
|
||||
{
|
||||
// Record where the drag started in timeline coordinates
|
||||
drag_start_ = mouse_pos;
|
||||
drag_start_ = mouse_pos->GetCoordinates();
|
||||
|
||||
// Get the item that was clicked
|
||||
TimelineViewBlockItem* clicked_item = GetItemAtScenePos(drag_start_);
|
||||
@@ -300,12 +300,10 @@ void TimelineWidget::PointerTool::InitiateDrag(const TimelineCoordinate &mouse_p
|
||||
snap_points_.clear();
|
||||
|
||||
// Record where the drag started in timeline coordinates
|
||||
track_start_ = mouse_pos.GetTrack();
|
||||
|
||||
qreal mouse_x = parent()->TimeToScene(mouse_pos.GetFrame());
|
||||
track_start_ = mouse_pos->GetTrack();
|
||||
|
||||
// Determine whether we're trimming or moving based on the position of the cursor
|
||||
Timeline::MovementMode trim_mode = IsCursorInTrimHandle(clicked_item, mouse_x);
|
||||
Timeline::MovementMode trim_mode = IsCursorInTrimHandle(clicked_item, mouse_pos->GetSceneX());
|
||||
|
||||
// Some derived classes don't allow movement
|
||||
if (trim_mode == Timeline::kNone && movement_allowed_) {
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
#include "node/input/media/media.h"
|
||||
#include "project/item/footage/footage.h"
|
||||
|
||||
TimelineView::TimelineView(const TrackType &type, Qt::Alignment vertical_alignment, QWidget *parent) :
|
||||
TimelineView::TimelineView(Qt::Alignment vertical_alignment, QWidget *parent) :
|
||||
TimelineViewBase(parent),
|
||||
connected_track_list_(nullptr),
|
||||
type_(type)
|
||||
connected_track_list_(nullptr)
|
||||
{
|
||||
Q_ASSERT(vertical_alignment == Qt::AlignTop || vertical_alignment == Qt::AlignBottom);
|
||||
setAlignment(Qt::AlignLeft | vertical_alignment);
|
||||
@@ -227,17 +226,26 @@ void TimelineView::ToolChangedEvent(Tool::Item tool)
|
||||
}
|
||||
}
|
||||
|
||||
Stream::Type TimelineView::TrackTypeToStreamType(TrackType track_type)
|
||||
Timeline::TrackType TimelineView::ConnectedTrackType()
|
||||
{
|
||||
if (connected_track_list_) {
|
||||
return connected_track_list_->type();
|
||||
}
|
||||
|
||||
return Timeline::kTrackTypeNone;
|
||||
}
|
||||
|
||||
Stream::Type TimelineView::TrackTypeToStreamType(Timeline::TrackType track_type)
|
||||
{
|
||||
switch (track_type) {
|
||||
case kTrackTypeNone:
|
||||
case kTrackTypeCount:
|
||||
case Timeline::kTrackTypeNone:
|
||||
case Timeline::kTrackTypeCount:
|
||||
break;
|
||||
case kTrackTypeVideo:
|
||||
case Timeline::kTrackTypeVideo:
|
||||
return Stream::kVideo;
|
||||
case kTrackTypeAudio:
|
||||
case Timeline::kTrackTypeAudio:
|
||||
return Stream::kAudio;
|
||||
case kTrackTypeSubtitle:
|
||||
case Timeline::kTrackTypeSubtitle:
|
||||
return Stream::kSubtitle;
|
||||
}
|
||||
|
||||
@@ -251,7 +259,7 @@ TimelineCoordinate TimelineView::ScreenToCoordinate(const QPoint& pt)
|
||||
|
||||
TimelineCoordinate TimelineView::SceneToCoordinate(const QPointF& pt)
|
||||
{
|
||||
return TimelineCoordinate(SceneToTime(pt.x()), TrackReference(type_, SceneToTrack(pt.y())));
|
||||
return TimelineCoordinate(SceneToTime(pt.x()), TrackReference(ConnectedTrackType(), SceneToTrack(pt.y())));
|
||||
}
|
||||
|
||||
TimelineViewMouseEvent TimelineView::CreateMouseEvent(const QPoint& pos, Qt::KeyboardModifiers modifiers)
|
||||
@@ -261,7 +269,7 @@ TimelineViewMouseEvent TimelineView::CreateMouseEvent(const QPoint& pos, Qt::Key
|
||||
TimelineViewMouseEvent timeline_event(scene_pt.x(),
|
||||
scale_,
|
||||
timebase(),
|
||||
TrackReference(type_, SceneToTrack(scene_pt.y())),
|
||||
TrackReference(ConnectedTrackType(), SceneToTrack(scene_pt.y())),
|
||||
modifiers);
|
||||
|
||||
return timeline_event;
|
||||
|
||||
@@ -44,8 +44,7 @@ class TimelineView : public TimelineViewBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TimelineView(const TrackType& type,
|
||||
Qt::Alignment vertical_alignment = Qt::AlignTop,
|
||||
TimelineView(Qt::Alignment vertical_alignment = Qt::AlignTop,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
void SelectAll();
|
||||
@@ -89,8 +88,8 @@ protected:
|
||||
virtual void ToolChangedEvent(Tool::Item tool) override;
|
||||
|
||||
private:
|
||||
TrackType ConnectedTrackType();
|
||||
Stream::Type TrackTypeToStreamType(TrackType track_type);
|
||||
Timeline::TrackType ConnectedTrackType();
|
||||
Stream::Type TrackTypeToStreamType(Timeline::TrackType track_type);
|
||||
|
||||
TimelineCoordinate ScreenToCoordinate(const QPoint& pt);
|
||||
TimelineCoordinate SceneToCoordinate(const QPointF& pt);
|
||||
@@ -105,8 +104,6 @@ private:
|
||||
|
||||
TrackList* connected_track_list_;
|
||||
|
||||
TrackType type_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIMELINEVIEW_H
|
||||
|
||||
Reference in New Issue
Block a user