Tidying.
[dcpomatic.git] / src / wx / kdm_advanced_dialog.cc
1 /*
2     Copyright (C) 2018-2019 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
22 #include "check_box.h"
23 #include "kdm_advanced_dialog.h"
24 #include "wx_util.h"
25 #include <wx/spinctrl.h>
26
27
28 using boost::optional;
29
30
31 KDMAdvancedDialog::KDMAdvancedDialog (wxWindow* parent, bool forensic_mark_video, bool forensic_mark_audio, optional<int> forensic_mark_audio_up_to)
32         : TableDialog (parent, _("Advanced KDM options"), 2, 1, false)
33 {
34         _forensic_mark_video = new CheckBox (this, _("Forensically mark video"));
35         _forensic_mark_video->SetValue (forensic_mark_video);
36         add (_forensic_mark_video);
37         add_spacer ();
38         _forensic_mark_audio = new CheckBox (this, _("Forensically mark audio"));
39         _forensic_mark_audio->SetValue (forensic_mark_audio);
40         add (_forensic_mark_audio);
41         add_spacer ();
42
43         _forensic_mark_all_audio = new wxRadioButton (this, wxID_ANY, _("Mark all audio channels"));
44         _table->Add (_forensic_mark_all_audio, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP);
45         add_spacer ();
46         wxBoxSizer* hbox = new wxBoxSizer (wxHORIZONTAL);
47         _forensic_mark_some_audio = new wxRadioButton (this, wxID_ANY, _("Mark audio channels up to (and including)"));
48         hbox->Add (_forensic_mark_some_audio, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
49         _forensic_mark_audio_up_to = new wxSpinCtrl (this, wxID_ANY);
50         hbox->Add (_forensic_mark_audio_up_to, 0, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
51         _table->Add (hbox, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
52         add_spacer ();
53
54         if (forensic_mark_audio_up_to) {
55                 _forensic_mark_audio_up_to->SetValue (*forensic_mark_audio_up_to);
56                 _forensic_mark_some_audio->SetValue (true);
57         }
58
59         layout ();
60         setup_sensitivity ();
61
62         _forensic_mark_audio_up_to->SetRange (1, 15);
63         _forensic_mark_audio->Bind (wxEVT_CHECKBOX, boost::bind(&KDMAdvancedDialog::setup_sensitivity, this));
64         _forensic_mark_all_audio->Bind (wxEVT_RADIOBUTTON, boost::bind(&KDMAdvancedDialog::setup_sensitivity, this));
65         _forensic_mark_some_audio->Bind (wxEVT_RADIOBUTTON, boost::bind(&KDMAdvancedDialog::setup_sensitivity, this));
66 }
67
68 bool
69 KDMAdvancedDialog::forensic_mark_video () const
70 {
71         return _forensic_mark_video->GetValue ();
72 }
73
74 bool
75 KDMAdvancedDialog::forensic_mark_audio () const
76 {
77         return _forensic_mark_audio->GetValue ();
78 }
79
80 optional<int>
81 KDMAdvancedDialog::forensic_mark_audio_up_to () const
82 {
83         if (!_forensic_mark_some_audio->GetValue()) {
84                 return optional<int>();
85         }
86
87         return _forensic_mark_audio_up_to->GetValue();
88 }
89
90 void
91 KDMAdvancedDialog::setup_sensitivity ()
92 {
93         _forensic_mark_all_audio->Enable (_forensic_mark_audio->GetValue());
94         _forensic_mark_some_audio->Enable (_forensic_mark_audio->GetValue());
95         _forensic_mark_audio_up_to->Enable (_forensic_mark_audio->GetValue() && _forensic_mark_some_audio->GetValue());
96 }