implemented speed/duration dialog and most of its functionality

An earlier commit implementing media in and out parameters was primarily for
this addition. A simple control dialog for the clip's speed presentation
reimplemented from the old codebase.
This commit is contained in:
itsmattkc
2019-12-17 03:58:12 +11:00
parent 4ba024e3ae
commit d4ee33405b
16 changed files with 336 additions and 2 deletions
@@ -6,8 +6,10 @@
#include "core.h"
#include "common/timecodefunctions.h"
#include "dialog/speedduration/speedduration.h"
#include "tool/tool.h"
#include "trackview/trackview.h"
#include "widget/menu/menu.h"
#include "widget/nodeview/nodeviewundo.h"
TimelineWidget::TimelineWidget(QWidget *parent) :
@@ -86,6 +88,7 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
connect(ruler_, SIGNAL(TimeChanged(const int64_t&)), view, SLOT(SetTime(const int64_t&)));
connect(view, SIGNAL(TimeChanged(const int64_t&)), ruler_, SLOT(SetTime(const int64_t&)));
connect(view, SIGNAL(TimeChanged(const int64_t&)), this, SIGNAL(TimeChanged(const int64_t&)));
connect(view, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ShowContextMenu()));
connect(horizontal_scroll_, SIGNAL(valueChanged(int)), view->horizontalScrollBar(), SLOT(setValue(int)));
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)), horizontal_scroll_, SLOT(setValue(int)));
@@ -802,6 +805,32 @@ void TimelineWidget::TrackHeightChanged(TrackType type, int index, int height)
}
}
void TimelineWidget::ShowContextMenu()
{
Menu menu(this);
//QList<TimelineViewBlockItem*> selected = GetSelectedBlocks();
QAction* speed_duration_action = menu.addAction(tr("Speed/Duration"));
connect(speed_duration_action, SIGNAL(triggered(bool)), this, SLOT(ShowSpeedDurationDialog()));
menu.exec(QCursor::pos());
}
void TimelineWidget::ShowSpeedDurationDialog()
{
QList<TimelineViewBlockItem*> selected = GetSelectedBlocks();
QList<ClipBlock*> selected_clips;
foreach (TimelineViewBlockItem* item, selected) {
if (item->block()->type() == Block::kClip) {
selected_clips.append(static_cast<ClipBlock*>(item->block()));
}
}
SpeedDurationDialog speed_diag(timebase(), selected_clips, this);
speed_diag.exec();
}
void TimelineWidget::AddGhost(TimelineViewGhostItem *ghost)
{
ghost->SetScale(scale_);
@@ -415,6 +415,10 @@ private slots:
void TrackHeightChanged(TrackType type, int index, int height);
void ShowContextMenu();
void ShowSpeedDurationDialog();
};
#endif // TIMELINEWIDGET_H
@@ -182,6 +182,10 @@ void TimelineWidget::ImportTool::DragMove(TimelineViewMouseEvent *event)
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
parent()->timebase(),
olive::CurrentTimecodeDisplay());
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
// of the cursor)
QToolTip::hideText();
QToolTip::showText(QCursor::pos(),
tooltip_text,
parent());
@@ -331,6 +331,10 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po
parent()->timebase(),
olive::CurrentTimecodeDisplay(),
true);
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
// of the cursor)
QToolTip::hideText();
QToolTip::showText(QCursor::pos(),
tooltip_text,
parent());
+3
View File
@@ -56,6 +56,9 @@ void TimelineWidget::SlipTool::ProcessDrag(const TimelineCoordinate &mouse_pos)
parent()->timebase(),
olive::CurrentTimecodeDisplay(),
true);
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
// of the cursor)
QToolTip::hideText();
QToolTip::showText(QCursor::pos(),
tooltip_text,
parent());
+20 -2
View File
@@ -57,6 +57,24 @@ void BlockResizeCommand::undo()
block_->set_length_and_media_out(old_length_);
}
BlockResizeWithoutMediaOutCommand::BlockResizeWithoutMediaOutCommand(Block *block, rational new_length, QUndoCommand *parent) :
QUndoCommand(parent),
block_(block),
old_length_(block->length()),
new_length_(new_length)
{
}
void BlockResizeWithoutMediaOutCommand::redo()
{
block_->set_length(new_length_);
}
void BlockResizeWithoutMediaOutCommand::undo()
{
block_->set_length(old_length_);
}
BlockResizeWithMediaInCommand::BlockResizeWithMediaInCommand(Block *block, rational new_length, QUndoCommand *parent) :
QUndoCommand(parent),
block_(block),
@@ -103,12 +121,12 @@ BlockSetMediaOutCommand::BlockSetMediaOutCommand(Block *block, rational new_medi
void BlockSetMediaOutCommand::redo()
{
block_->set_media_in(new_media_out_);
block_->set_media_out(new_media_out_);
}
void BlockSetMediaOutCommand::undo()
{
block_->set_media_in(old_media_out_);
block_->set_media_out(old_media_out_);
}
TrackRippleRemoveBlockCommand::TrackRippleRemoveBlockCommand(TrackOutput *track, Block *block, QUndoCommand *parent) :
+13
View File
@@ -41,6 +41,19 @@ private:
rational new_length_;
};
class BlockResizeWithoutMediaOutCommand : public QUndoCommand {
public:
BlockResizeWithoutMediaOutCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
virtual void redo() override;
virtual void undo() override;
private:
Block* block_;
rational old_length_;
rational new_length_;
};
class BlockResizeWithMediaInCommand : public QUndoCommand {
public:
BlockResizeWithMediaInCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
@@ -46,6 +46,7 @@ TimelineView::TimelineView(const TrackType &type, Qt::Alignment vertical_alignme
setDragMode(NoDrag);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setBackgroundRole(QPalette::Window);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(&scene_, SIGNAL(changed(const QList<QRectF>&)), this, SLOT(UpdateSceneRect()));