X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdcp_range_dialog.cc;h=9eced92d67cf60ebf76af0acf3387118f0982ec9;hb=b7466a9653345bc51db4cb1d7e960bfc4c12721f;hp=aed6808cbd595470a1969745e445c640034e2a15;hpb=c0ed407fb02891f0dd364e78b6192f0e6dbe1d8d;p=dcpomatic.git diff --git a/src/wx/dcp_range_dialog.cc b/src/wx/dcp_range_dialog.cc index aed6808cb..9eced92d6 100644 --- a/src/wx/dcp_range_dialog.cc +++ b/src/wx/dcp_range_dialog.cc @@ -21,52 +21,34 @@ #include "dcp_range_dialog.h" #include "wx_util.h" -DCPRangeDialog::DCPRangeDialog (wxWindow* p, Film* f) +using boost::shared_ptr; + +DCPRangeDialog::DCPRangeDialog (wxWindow* p, shared_ptr f) : wxDialog (p, wxID_ANY, wxString (_("DCP Range"))) , _film (f) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); - - _whole = new wxRadioButton (this, wxID_ANY, _("Whole film"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); - table->Add (_whole, 1); - table->AddSpacer (0); - - _first = new wxRadioButton (this, wxID_ANY, _("First")); - table->Add (_first); - { - wxSizer* s = new wxBoxSizer (wxHORIZONTAL); - _n_frames = new wxSpinCtrl (this, wxID_ANY); - s->Add (_n_frames); - add_label_to_sizer (s, this, "frames"); - table->Add (s); - } + wxFlexGridSizer* table = new wxFlexGridSizer (3, 6, 6); - table->AddSpacer (0); - _cut = new wxRadioButton (this, wxID_ANY, _("Cut remainder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); - table->Add (_cut); + add_label_to_sizer (table, this, "Trim start"); + _trim_start = new wxSpinCtrl (this, wxID_ANY); + table->Add (_trim_start, 1); + add_label_to_sizer (table, this, "frames"); - table->AddSpacer (0); - _black_out = new wxRadioButton (this, wxID_ANY, _("Black-out remainder")); - table->Add (_black_out); + add_label_to_sizer (table, this, "Trim end"); + _trim_end = new wxSpinCtrl (this, wxID_ANY); + table->Add (_trim_end, 1); + add_label_to_sizer (table, this, "frames"); - _n_frames->SetRange (1, INT_MAX - 1); - if (_film->dcp_frames() > 0) { - _whole->SetValue (false); - _first->SetValue (true); - _n_frames->SetValue (_film->dcp_frames ()); - } else { - _whole->SetValue (true); - _first->SetValue (false); - _n_frames->SetValue (24); + if (_film->length()) { + _trim_start->SetRange (0, _film->length().get()); + _trim_end->SetRange (0, _film->length().get()); } - _black_out->Enable (_film->dcp_trim_action() == BLACK_OUT); - _cut->Enable (_film->dcp_trim_action() == CUT); + _trim_start->SetValue (_film->dcp_trim_start()); + _trim_end->SetValue (_film->dcp_trim_end()); - _whole->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::whole_toggled), 0, this); - _first->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::first_toggled), 0, this); - _cut->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::cut_toggled), 0, this); - _n_frames->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::n_frames_changed), 0, this); + _trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::emit_changed), 0, this); + _trim_end->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::emit_changed), 0, this); wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (table, 0, wxALL, 6); @@ -78,57 +60,10 @@ DCPRangeDialog::DCPRangeDialog (wxWindow* p, Film* f) SetSizer (overall_sizer); overall_sizer->SetSizeHints (this); - - set_sensitivity (); } void -DCPRangeDialog::whole_toggled (wxCommandEvent &) +DCPRangeDialog::emit_changed (wxCommandEvent &) { - set_sensitivity (); - emit_changed (); -} - -void -DCPRangeDialog::first_toggled (wxCommandEvent &) -{ - set_sensitivity (); - emit_changed (); -} - -void -DCPRangeDialog::set_sensitivity () -{ - _n_frames->Enable (_first->GetValue ()); - _black_out->Enable (_first->GetValue ()); - _cut->Enable (_first->GetValue ()); -} - -void -DCPRangeDialog::cut_toggled (wxCommandEvent &) -{ - set_sensitivity (); - emit_changed (); -} - -void -DCPRangeDialog::n_frames_changed (wxCommandEvent &) -{ - emit_changed (); -} - -void -DCPRangeDialog::emit_changed () -{ - int frames = 0; - if (!_whole->GetValue ()) { - frames = _n_frames->GetValue (); - } - - TrimAction action = CUT; - if (_black_out->GetValue ()) { - action = BLACK_OUT; - } - - Changed (frames, action); + Changed (_trim_start->GetValue(), _trim_end->GetValue()); }