X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fstandard_controls.cc;h=cef06d29cf695c1af92e8e9e1255b2fc7ac2b2f0;hb=b9a1ad3df5f9d85fb7439efd93fede72b9b078af;hp=956f82c961111619137d5616fcb454a36a4484f1;hpb=6349c88c4fb9d4ac76ef14b277d455e3a2b006a6;p=dcpomatic.git diff --git a/src/wx/standard_controls.cc b/src/wx/standard_controls.cc index 956f82c96..cef06d29c 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 "lib/warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include +#include +DCPOMATIC_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 (); +}