reimplemented goto prev/next cut, about dialog, and action search dialog
This commit is contained in:
@@ -96,6 +96,16 @@ public:
|
||||
|
||||
virtual void EditToOut(){}
|
||||
|
||||
virtual void ShuttleLeft(){}
|
||||
|
||||
virtual void ShuttleStop(){}
|
||||
|
||||
virtual void ShuttleRight(){}
|
||||
|
||||
virtual void GoToPrevCut(){}
|
||||
|
||||
virtual void GoToNextCut(){}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Set panel's title
|
||||
|
||||
@@ -238,6 +238,69 @@ void TimelineView::EditToOut()
|
||||
RippleEditTo(olive::timeline::kTrimOut, true);
|
||||
}
|
||||
|
||||
void TimelineView::GoToPrevCut()
|
||||
{
|
||||
if (timeline_node_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playhead_ == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t closest_cut = 0;
|
||||
|
||||
foreach (TrackOutput* track, timeline_node_->Tracks()) {
|
||||
int64_t this_track_closest_cut = 0;
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
int64_t block_out_ts = olive::time_to_timestamp(block->out(), timebase_);
|
||||
|
||||
if (block_out_ts < playhead_) {
|
||||
this_track_closest_cut = block_out_ts;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closest_cut = qMax(closest_cut, this_track_closest_cut);
|
||||
}
|
||||
|
||||
UserSetTime(closest_cut);
|
||||
}
|
||||
|
||||
void TimelineView::GoToNextCut()
|
||||
{
|
||||
if (timeline_node_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t closest_cut = INT64_MAX;
|
||||
|
||||
foreach (TrackOutput* track, timeline_node_->Tracks()) {
|
||||
int64_t this_track_closest_cut = olive::time_to_timestamp(track->in(), timebase_);
|
||||
|
||||
if (this_track_closest_cut <= playhead_) {
|
||||
this_track_closest_cut = INT64_MAX;
|
||||
}
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
int64_t block_in_ts = olive::time_to_timestamp(block->in(), timebase_);
|
||||
|
||||
if (block_in_ts > playhead_) {
|
||||
this_track_closest_cut = block_in_ts;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closest_cut = qMin(closest_cut, this_track_closest_cut);
|
||||
}
|
||||
|
||||
if (closest_cut < INT64_MAX) {
|
||||
UserSetTime(closest_cut);
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineView::SetTime(const int64_t time)
|
||||
{
|
||||
playhead_ = time;
|
||||
@@ -456,11 +519,16 @@ void TimelineView::RippleEditTo(olive::timeline::MovementMode mode, bool insert_
|
||||
|
||||
if (mode == olive::timeline::kTrimIn && !insert_gaps) {
|
||||
int64_t new_time = olive::time_to_timestamp(closest_point_to_playhead, timebase_);
|
||||
SetTime(new_time);
|
||||
emit TimeChanged(new_time);
|
||||
UserSetTime(new_time);
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineView::UserSetTime(const int64_t &time)
|
||||
{
|
||||
SetTime(time);
|
||||
emit TimeChanged(time);
|
||||
}
|
||||
|
||||
void TimelineView::BlockChanged()
|
||||
{
|
||||
TimelineViewRect* rect = block_items_[static_cast<Block*>(sender())];
|
||||
|
||||
@@ -64,6 +64,10 @@ public:
|
||||
|
||||
void EditToOut();
|
||||
|
||||
void GoToPrevCut();
|
||||
|
||||
void GoToNextCut();
|
||||
|
||||
public slots:
|
||||
void SetTimebase(const rational& timebase);
|
||||
|
||||
@@ -358,6 +362,8 @@ private:
|
||||
|
||||
void RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps);
|
||||
|
||||
void UserSetTime(const int64_t& time);
|
||||
|
||||
QGraphicsScene scene_;
|
||||
|
||||
double scale_;
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
viewer_node_(nullptr)
|
||||
viewer_node_(nullptr),
|
||||
playback_speed_(0)
|
||||
{
|
||||
// Set up main layout
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -181,6 +182,24 @@ void ViewerWidget::UpdateTextureFromNode(const rational& time)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::PlayInternal(int speed)
|
||||
{
|
||||
Q_ASSERT(speed != 0);
|
||||
|
||||
if (time_base_.isNull()) {
|
||||
qWarning() << "ViewerWidget can't play with an invalid timebase";
|
||||
return;
|
||||
}
|
||||
|
||||
start_msec_ = QDateTime::currentMSecsSinceEpoch();
|
||||
start_timestamp_ = ruler_->GetTime();
|
||||
playback_speed_ = speed;
|
||||
|
||||
playback_timer_.start();
|
||||
|
||||
controls_->ShowPauseButton();
|
||||
}
|
||||
|
||||
void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
{
|
||||
Pause();
|
||||
@@ -190,17 +209,7 @@ void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
|
||||
void ViewerWidget::Play()
|
||||
{
|
||||
if (time_base_.isNull()) {
|
||||
qWarning() << "ViewerWidget can't play with an invalid timebase";
|
||||
return;
|
||||
}
|
||||
|
||||
start_msec_ = QDateTime::currentMSecsSinceEpoch();
|
||||
start_timestamp_ = ruler_->GetTime();
|
||||
|
||||
playback_timer_.start();
|
||||
|
||||
controls_->ShowPauseButton();
|
||||
PlayInternal(1);
|
||||
}
|
||||
|
||||
void ViewerWidget::Pause()
|
||||
@@ -208,6 +217,8 @@ void ViewerWidget::Pause()
|
||||
playback_timer_.stop();
|
||||
|
||||
controls_->ShowPlayButton();
|
||||
|
||||
playback_speed_ = 0;
|
||||
}
|
||||
|
||||
void ViewerWidget::GoToStart()
|
||||
@@ -238,13 +249,55 @@ void ViewerWidget::GoToEnd()
|
||||
qWarning() << "No end frame support yet";
|
||||
}
|
||||
|
||||
void ViewerWidget::ShuttleLeft()
|
||||
{
|
||||
int current_speed = playback_speed_;
|
||||
|
||||
if (current_speed != 0) {
|
||||
Pause();
|
||||
}
|
||||
|
||||
current_speed--;
|
||||
|
||||
if (current_speed != 0) {
|
||||
PlayInternal(current_speed);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::ShuttleStop()
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
|
||||
void ViewerWidget::ShuttleRight()
|
||||
{
|
||||
int current_speed = playback_speed_;
|
||||
|
||||
if (current_speed != 0) {
|
||||
Pause();
|
||||
}
|
||||
|
||||
current_speed++;
|
||||
|
||||
if (current_speed != 0) {
|
||||
PlayInternal(current_speed);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::PlaybackTimerUpdate()
|
||||
{
|
||||
int64_t real_time = QDateTime::currentMSecsSinceEpoch() - start_msec_;
|
||||
|
||||
int64_t frames_since_start = qRound(static_cast<double>(real_time) / (time_base_dbl_ * 1000));
|
||||
|
||||
SetTime(start_timestamp_ + frames_since_start);
|
||||
int64_t current_time = start_timestamp_ + frames_since_start * playback_speed_;
|
||||
|
||||
if (current_time < 0) {
|
||||
current_time = 0;
|
||||
Pause();
|
||||
}
|
||||
|
||||
SetTime(current_time);
|
||||
}
|
||||
|
||||
void ViewerWidget::ViewerNodeChangedBetween(const rational &start, const rational &end)
|
||||
|
||||
@@ -86,6 +86,12 @@ public slots:
|
||||
|
||||
void GoToEnd();
|
||||
|
||||
void ShuttleLeft();
|
||||
|
||||
void ShuttleStop();
|
||||
|
||||
void ShuttleRight();
|
||||
|
||||
signals:
|
||||
void TimeChanged(const rational&);
|
||||
|
||||
@@ -97,6 +103,8 @@ private:
|
||||
|
||||
void UpdateTextureFromNode(const rational &time);
|
||||
|
||||
void PlayInternal(int speed);
|
||||
|
||||
ViewerGLWidget* gl_widget_;
|
||||
|
||||
PlaybackControls* controls_;
|
||||
@@ -116,6 +124,8 @@ private:
|
||||
|
||||
ViewerOutput* viewer_node_;
|
||||
|
||||
int playback_speed_;
|
||||
|
||||
private slots:
|
||||
void RulerTimeChange(int64_t);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user