moved timeline tracktypes into timelinecommon.h

This commit is contained in:
itsmattkc
2020-01-06 15:34:12 +11:00
parent dae09abf45
commit 7bf2422c44
22 changed files with 106 additions and 117 deletions
@@ -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;
+5 -5
View File
@@ -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)
+4 -4
View File
@@ -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();
+8 -8
View File
@@ -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;
}
+5 -7
View File
@@ -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_) {
+19 -11
View File
@@ -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