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