implemented playback controls
This commit is contained in:
@@ -44,6 +44,31 @@ void ViewerPanel::ZoomOut()
|
||||
viewer_->SetScale(viewer_->scale() * 0.5);
|
||||
}
|
||||
|
||||
void ViewerPanel::GoToStart()
|
||||
{
|
||||
viewer_->GoToStart();
|
||||
}
|
||||
|
||||
void ViewerPanel::PrevFrame()
|
||||
{
|
||||
viewer_->PrevFrame();
|
||||
}
|
||||
|
||||
void ViewerPanel::PlayPause()
|
||||
{
|
||||
viewer_->TogglePlayPause();
|
||||
}
|
||||
|
||||
void ViewerPanel::NextFrame()
|
||||
{
|
||||
viewer_->NextFrame();
|
||||
}
|
||||
|
||||
void ViewerPanel::GoToEnd()
|
||||
{
|
||||
viewer_->GoToEnd();
|
||||
}
|
||||
|
||||
void ViewerPanel::SetTimebase(const rational &timebase)
|
||||
{
|
||||
viewer_->SetTimebase(timebase);
|
||||
|
||||
@@ -38,6 +38,16 @@ public:
|
||||
|
||||
virtual void ZoomOut() override;
|
||||
|
||||
virtual void GoToStart() override;
|
||||
|
||||
virtual void PrevFrame() override;
|
||||
|
||||
virtual void PlayPause() override;
|
||||
|
||||
virtual void NextFrame() override;
|
||||
|
||||
virtual void GoToEnd() override;
|
||||
|
||||
void SetTimebase(const rational& timebase);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -47,6 +47,26 @@ void PanelWidget::ZoomOut()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::GoToStart()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::PrevFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::PlayPause()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::NextFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::GoToEnd()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::SetTitle(const QString &t)
|
||||
{
|
||||
title_ = t;
|
||||
|
||||
@@ -62,6 +62,23 @@ public:
|
||||
* no-op.
|
||||
*/
|
||||
virtual void ZoomOut();
|
||||
|
||||
virtual void GoToStart();
|
||||
|
||||
virtual void PrevFrame();
|
||||
|
||||
/**
|
||||
* @brief Called whenever this panel is focused and user uses "Play/Pause" (either in menus or as a keyboard shortcut)
|
||||
*
|
||||
* This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a
|
||||
* no-op.
|
||||
*/
|
||||
virtual void PlayPause();
|
||||
|
||||
virtual void NextFrame();
|
||||
|
||||
virtual void GoToEnd();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Set panel's title
|
||||
|
||||
@@ -82,13 +82,11 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
play_btn_->setIcon(olive::icon::Play);
|
||||
playpause_stack_->addWidget(play_btn_);
|
||||
connect(play_btn_, SIGNAL(clicked(bool)), this, SIGNAL(PlayClicked()));
|
||||
connect(play_btn_, SIGNAL(clicked(bool)), this, SLOT(PlayPauseClickedInternal()));
|
||||
|
||||
pause_btn_ = new QPushButton();
|
||||
pause_btn_->setIcon(olive::icon::Pause);
|
||||
playpause_stack_->addWidget(pause_btn_);
|
||||
connect(pause_btn_, SIGNAL(clicked(bool)), this, SIGNAL(PauseClicked()));
|
||||
connect(pause_btn_, SIGNAL(clicked(bool)), this, SLOT(PlayPauseClickedInternal()));
|
||||
|
||||
// Default to showing play button
|
||||
playpause_stack_->setCurrentWidget(play_btn_);
|
||||
@@ -141,12 +139,13 @@ void PlaybackControls::SetTime(const int64_t &r)
|
||||
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, kTimecodeDisplay));
|
||||
}
|
||||
|
||||
void PlaybackControls::PlayPauseClickedInternal()
|
||||
void PlaybackControls::ShowPauseButton()
|
||||
{
|
||||
if (sender() == play_btn_) {
|
||||
// Play was clicked, toggle to pause
|
||||
playpause_stack_->setCurrentWidget(pause_btn_);
|
||||
} else {
|
||||
playpause_stack_->setCurrentWidget(play_btn_);
|
||||
}
|
||||
// Play was clicked, toggle to pause
|
||||
playpause_stack_->setCurrentWidget(pause_btn_);
|
||||
}
|
||||
|
||||
void PlaybackControls::ShowPlayButton()
|
||||
{
|
||||
playpause_stack_->setCurrentWidget(play_btn_);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ public:
|
||||
public slots:
|
||||
void SetTime(const int64_t &r);
|
||||
|
||||
void ShowPauseButton();
|
||||
|
||||
void ShowPlayButton();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when "Go to Start" is clicked
|
||||
@@ -95,7 +99,7 @@ private:
|
||||
QStackedWidget* playpause_stack_;
|
||||
|
||||
private slots:
|
||||
void PlayPauseClickedInternal();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ protected:
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted whenever the time changes on this ruler, either by user or programatically
|
||||
*/
|
||||
void TimeChanged(int64_t);
|
||||
|
||||
private:
|
||||
|
||||
@@ -99,7 +99,21 @@ void ViewerWidget::SetScale(const double &scale_)
|
||||
void ViewerWidget::SetTime(const int64_t &time)
|
||||
{
|
||||
ruler_->SetTime(time);
|
||||
RulerTimeChange(time);
|
||||
UpdateTimeInternal(time);
|
||||
}
|
||||
|
||||
void ViewerWidget::TogglePlayPause()
|
||||
{
|
||||
if (IsPlaying()) {
|
||||
Pause();
|
||||
} else {
|
||||
Play();
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewerWidget::IsPlaying()
|
||||
{
|
||||
return playback_timer_.isActive();
|
||||
}
|
||||
|
||||
void ViewerWidget::SetTexture(GLuint tex)
|
||||
@@ -107,7 +121,7 @@ void ViewerWidget::SetTexture(GLuint tex)
|
||||
gl_widget_->SetTexture(tex);
|
||||
}
|
||||
|
||||
void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
void ViewerWidget::UpdateTimeInternal(int64_t i)
|
||||
{
|
||||
rational time_set = rational(i) * time_base_;
|
||||
|
||||
@@ -116,6 +130,13 @@ void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
emit TimeChanged(time_set);
|
||||
}
|
||||
|
||||
void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
{
|
||||
Pause();
|
||||
|
||||
UpdateTimeInternal(i);
|
||||
}
|
||||
|
||||
void ViewerWidget::Play()
|
||||
{
|
||||
if (time_base_.isNull()) {
|
||||
@@ -127,11 +148,15 @@ void ViewerWidget::Play()
|
||||
start_timestamp_ = ruler_->Time();
|
||||
|
||||
playback_timer_.start();
|
||||
|
||||
controls_->ShowPauseButton();
|
||||
}
|
||||
|
||||
void ViewerWidget::Pause()
|
||||
{
|
||||
playback_timer_.stop();
|
||||
|
||||
controls_->ShowPlayButton();
|
||||
}
|
||||
|
||||
void ViewerWidget::GoToStart()
|
||||
|
||||
+19
-13
@@ -53,6 +53,10 @@ public:
|
||||
|
||||
void SetTime(const int64_t& time);
|
||||
|
||||
void TogglePlayPause();
|
||||
|
||||
bool IsPlaying();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Set the texture to draw and draw it
|
||||
@@ -63,6 +67,18 @@ public slots:
|
||||
*/
|
||||
void SetTexture(GLuint tex);
|
||||
|
||||
void GoToStart();
|
||||
|
||||
void PrevFrame();
|
||||
|
||||
void Play();
|
||||
|
||||
void Pause();
|
||||
|
||||
void NextFrame();
|
||||
|
||||
void GoToEnd();
|
||||
|
||||
signals:
|
||||
void TimeChanged(const rational&);
|
||||
|
||||
@@ -70,6 +86,8 @@ protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
void UpdateTimeInternal(int64_t i);
|
||||
|
||||
ViewerGLWidget* gl_widget_;
|
||||
|
||||
PlaybackControls* controls_;
|
||||
@@ -88,19 +106,7 @@ private:
|
||||
int64_t start_timestamp_;
|
||||
|
||||
private slots:
|
||||
void RulerTimeChange(int64_t i);
|
||||
|
||||
void Play();
|
||||
|
||||
void Pause();
|
||||
|
||||
void GoToStart();
|
||||
|
||||
void PrevFrame();
|
||||
|
||||
void NextFrame();
|
||||
|
||||
void GoToEnd();
|
||||
void RulerTimeChange(int64_t);
|
||||
|
||||
void PlaybackTimerUpdate();
|
||||
|
||||
|
||||
@@ -160,12 +160,12 @@ MainMenu::MainMenu(QWidget *parent) :
|
||||
// PLAYBACK MENU
|
||||
//
|
||||
playback_menu_ = new Menu(this);
|
||||
playback_gotostart_item_ = playback_menu_->AddItem("gotostart", nullptr, nullptr, "Home");
|
||||
playback_prevframe_item_ = playback_menu_->AddItem("prevframe", nullptr, nullptr, "Left");
|
||||
playback_playpause_item_ = playback_menu_->AddItem("playpause", nullptr, nullptr, "Space");
|
||||
playback_gotostart_item_ = playback_menu_->AddItem("gotostart", this, SLOT(GoToStartTriggered()), "Home");
|
||||
playback_prevframe_item_ = playback_menu_->AddItem("prevframe", this, SLOT(PrevFrameTriggered()), "Left");
|
||||
playback_playpause_item_ = playback_menu_->AddItem("playpause", this, SLOT(PlayPauseTriggered()), "Space");
|
||||
playback_playinout_item_ = playback_menu_->AddItem("playintoout", nullptr, nullptr, "Shift+Space");
|
||||
playback_nextframe_item_ = playback_menu_->AddItem("nextframe", nullptr, nullptr, "Right");
|
||||
playback_gotoend_item_ = playback_menu_->AddItem("gotoend", nullptr, nullptr, "End");
|
||||
playback_nextframe_item_ = playback_menu_->AddItem("nextframe", this, SLOT(NextFrameTriggered()), "Right");
|
||||
playback_gotoend_item_ = playback_menu_->AddItem("gotoend", this, SLOT(GoToEndTriggered()), "End");
|
||||
|
||||
playback_menu_->addSeparator();
|
||||
|
||||
@@ -344,6 +344,31 @@ void MainMenu::ZoomOutTriggered()
|
||||
olive::panel_focus_manager->CurrentlyFocused()->ZoomOut();
|
||||
}
|
||||
|
||||
void MainMenu::GoToStartTriggered()
|
||||
{
|
||||
olive::panel_focus_manager->CurrentlyFocused()->GoToStart();
|
||||
}
|
||||
|
||||
void MainMenu::PrevFrameTriggered()
|
||||
{
|
||||
olive::panel_focus_manager->CurrentlyFocused()->PrevFrame();
|
||||
}
|
||||
|
||||
void MainMenu::PlayPauseTriggered()
|
||||
{
|
||||
olive::panel_focus_manager->CurrentlyFocused()->PlayPause();
|
||||
}
|
||||
|
||||
void MainMenu::NextFrameTriggered()
|
||||
{
|
||||
olive::panel_focus_manager->CurrentlyFocused()->NextFrame();
|
||||
}
|
||||
|
||||
void MainMenu::GoToEndTriggered()
|
||||
{
|
||||
olive::panel_focus_manager->CurrentlyFocused()->GoToEnd();
|
||||
}
|
||||
|
||||
void MainMenu::Retranslate()
|
||||
{
|
||||
// MenuShared is not a QWidget and therefore does not receive a LanguageEvent, we use MainMenu's to update it
|
||||
|
||||
@@ -74,6 +74,19 @@ private slots:
|
||||
*/
|
||||
void ZoomOutTriggered();
|
||||
|
||||
void GoToStartTriggered();
|
||||
void PrevFrameTriggered();
|
||||
|
||||
/**
|
||||
* @brief Slot for play/pause
|
||||
*
|
||||
* Finds the currently focused panel and sends it a "play/pause" signal
|
||||
*/
|
||||
void PlayPauseTriggered();
|
||||
|
||||
void NextFrameTriggered();
|
||||
void GoToEndTriggered();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Set strings based on the current application language.
|
||||
|
||||
Reference in New Issue
Block a user