X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fstandard_controls.cc;h=a2914d77ba0727f866bf1b874e63e9babd2b50a2;hb=600e0c67c61b29427602918daebb38a4822f95cb;hp=956f82c961111619137d5616fcb454a36a4484f1;hpb=6349c88c4fb9d4ac76ef14b277d455e3a2b006a6;p=dcpomatic.git diff --git a/src/wx/standard_controls.cc b/src/wx/standard_controls.cc index 956f82c96..a2914d77b 100644 --- a/src/wx/standard_controls.cc +++ b/src/wx/standard_controls.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,21 +18,28 @@ */ -#include "standard_controls.h" + #include "film_viewer.h" -#include +#include "standard_controls.h" +#include +LIBDCP_DISABLE_WARNINGS #include +#include +LIBDCP_ENABLE_WARNINGS + + +using std::shared_ptr; -using boost::shared_ptr; StandardControls::StandardControls (wxWindow* parent, shared_ptr 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 () { @@ -40,6 +47,7 @@ StandardControls::started () _play_button->SetValue (true); } + void StandardControls::stopped () { @@ -47,26 +55,30 @@ 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 () { @@ -74,3 +86,19 @@ StandardControls::setup_sensitivity () bool const active_job = _active_job && *_active_job != "examine_content"; _play_button->Enable (_film && !_film->content().empty() && !active_job); } + + +void +StandardControls::play () +{ + _play_button->SetValue (true); + play_clicked (); +} + + +void +StandardControls::stop () +{ + _play_button->SetValue (false); + play_clicked (); +}