/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "standard_controls.h"
+
#include "film_viewer.h"
-#include <wx/wx.h>
+#include "standard_controls.h"
#include <wx/tglbtn.h>
+#include <wx/wx.h>
+
+
+using std::shared_ptr;
-using boost::shared_ptr;
StandardControls::StandardControls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls)
: Controls (parent, viewer, editor_controls)
, _play_button (new wxToggleButton(this, wxID_ANY, _("Play")))
{
- _button_sizer->Add (_play_button, 0, wxEXPAND);
+ _button_sizer->Add (_play_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
_play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind(&StandardControls::play_clicked, this));
}
+
void
StandardControls::started ()
{
_play_button->SetValue (true);
}
+
void
StandardControls::stopped ()
{
_play_button->SetValue (false);
}
+
void
StandardControls::play_clicked ()
{
check_play_state ();
}
+
void
StandardControls::check_play_state ()
{
- if (!_film || _film->video_frame_rate() == 0) {
+ auto viewer = _viewer.lock ();
+ if (!_film || _film->video_frame_rate() == 0 || !viewer) {
return;
}
if (_play_button->GetValue()) {
- _viewer->start ();
+ viewer->start ();
} else {
- _viewer->stop ();
+ viewer->stop ();
}
}
+
void
StandardControls::setup_sensitivity ()
{
_play_button->Enable (_film && !_film->content().empty() && !active_job);
}
+
void
StandardControls::play ()
{
play_clicked ();
}
+
void
StandardControls::stop ()
{