First hacks on OOBE help.
[dcpomatic.git] / src / wx / standard_controls.cc
1 /*
2     Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "film_viewer.h"
22 #include "standard_controls.h"
23 #include "wx_help.h"
24 #include <wx/wx.h>
25 #include <wx/tglbtn.h>
26
27 using boost::shared_ptr;
28
29 StandardControls::StandardControls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls)
30         : Controls (parent, viewer, editor_controls)
31         , _play_button (new wxToggleButton(this, wxID_ANY, _("Play")))
32 {
33         _button_sizer->Add (_play_button, 0, wxEXPAND);
34         _play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind(&StandardControls::play_clicked, this));
35         HelpGUI::instance()->landmark (_play_button, HelpGUI::PLAY_BUTTON);
36 }
37
38 void
39 StandardControls::started ()
40 {
41         Controls::started ();
42         _play_button->SetValue (true);
43 }
44
45 void
46 StandardControls::stopped ()
47 {
48         Controls::stopped ();
49         _play_button->SetValue (false);
50 }
51
52 void
53 StandardControls::play_clicked ()
54 {
55         check_play_state ();
56 }
57
58 void
59 StandardControls::check_play_state ()
60 {
61         if (!_film || _film->video_frame_rate() == 0) {
62                 return;
63         }
64
65         if (_play_button->GetValue()) {
66                 _viewer->start ();
67         } else {
68                 _viewer->stop ();
69         }
70 }
71
72 void
73 StandardControls::setup_sensitivity ()
74 {
75         Controls::setup_sensitivity ();
76         bool const active_job = _active_job && *_active_job != "examine_content";
77         _play_button->Enable (_film && !_film->content().empty() && !active_job);
78 }
79
80 void
81 StandardControls::play ()
82 {
83         _play_button->SetValue (true);
84         play_clicked ();
85 }
86
87 void
88 StandardControls::stop ()
89 {
90         _play_button->SetValue (false);
91         play_clicked ();
92 }