2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "dcp_range_dialog.h"
24 using boost::shared_ptr;
26 DCPRangeDialog::DCPRangeDialog (wxWindow* p, shared_ptr<Film> f)
27 : wxDialog (p, wxID_ANY, wxString (_("DCP Range")))
30 wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
32 _whole = new wxRadioButton (this, wxID_ANY, _("Whole film"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
33 table->Add (_whole, 1);
36 _first = new wxRadioButton (this, wxID_ANY, _("First"));
39 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
40 _n_frames = new wxSpinCtrl (this, wxID_ANY);
42 add_label_to_sizer (s, this, "frames");
47 _cut = new wxRadioButton (this, wxID_ANY, _("Cut remainder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
51 _black_out = new wxRadioButton (this, wxID_ANY, _("Black-out remainder"));
52 table->Add (_black_out);
54 _n_frames->SetRange (1, INT_MAX - 1);
55 if (_film->dcp_frames()) {
56 _whole->SetValue (false);
57 _first->SetValue (true);
58 _n_frames->SetValue (_film->dcp_frames().get());
60 _whole->SetValue (true);
61 _first->SetValue (false);
62 _n_frames->SetValue (24);
65 _black_out->Enable (_film->dcp_trim_action() == BLACK_OUT);
66 _cut->Enable (_film->dcp_trim_action() == CUT);
68 _whole->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::whole_toggled), 0, this);
69 _first->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::first_toggled), 0, this);
70 _cut->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::cut_toggled), 0, this);
71 _n_frames->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::n_frames_changed), 0, this);
73 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
74 overall_sizer->Add (table, 0, wxALL, 6);
76 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
78 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
81 SetSizer (overall_sizer);
82 overall_sizer->SetSizeHints (this);
88 DCPRangeDialog::whole_toggled (wxCommandEvent &)
95 DCPRangeDialog::first_toggled (wxCommandEvent &)
102 DCPRangeDialog::set_sensitivity ()
104 _n_frames->Enable (_first->GetValue ());
105 _black_out->Enable (_first->GetValue ());
106 _cut->Enable (_first->GetValue ());
110 DCPRangeDialog::cut_toggled (wxCommandEvent &)
117 DCPRangeDialog::n_frames_changed (wxCommandEvent &)
123 DCPRangeDialog::emit_changed ()
126 if (!_whole->GetValue ()) {
127 frames = _n_frames->GetValue ();
130 TrimAction action = CUT;
131 if (_black_out->GetValue ()) {
135 Changed (frames, action);