#include "dcp_range_dialog.h"
#include "gain_calculator_dialog.h"
#include "sound_processor.h"
+#include "dci_name_dialog.h"
using namespace std;
using namespace boost;
_name = new wxTextCtrl (this, wxID_ANY);
_sizer->Add (_name, 1, wxEXPAND);
+ _use_dci_name = new wxCheckBox (this, wxID_ANY, wxT ("Use DCI name"));
+ _sizer->Add (_use_dci_name, 1, wxEXPAND);
+ _edit_dci_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
+ _sizer->Add (_edit_dci_button, 0);
+
add_label_to_sizer (_sizer, this, "Content");
_content = new wxFilePickerCtrl (this, wxID_ANY, wxT (""), wxT ("Select Content File"), wxT("*.*"));
_sizer->Add (_content, 1, wxEXPAND);
s->Add (video_control (_audio_gain), 1);
video_control (add_label_to_sizer (s, this, "dB"));
_audio_gain_calculate_button = new wxButton (this, wxID_ANY, _("Calculate..."));
+ video_control (_audio_gain_calculate_button);
s->Add (_audio_gain_calculate_button, 1, wxEXPAND);
_sizer->Add (s);
}
_sizer->Add (s);
}
+ _with_subtitles = new wxCheckBox (this, wxID_ANY, wxT("With Subtitles"));
+ video_control (_with_subtitles);
+ _sizer->Add (_with_subtitles, 1);
+ _sizer->AddSpacer (0);
+
+ video_control (add_label_to_sizer (_sizer, this, "Subtitle Offset"));
+ _subtitle_offset = new wxSpinCtrl (this);
+ _sizer->Add (video_control (_subtitle_offset), 1);
+
+ {
+ video_control (add_label_to_sizer (_sizer, this, "Subtitle Scale"));
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _subtitle_scale = new wxSpinCtrl (this);
+ s->Add (video_control (_subtitle_scale));
+ video_control (add_label_to_sizer (s, this, "%"));
+ _sizer->Add (s);
+ }
+
video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
_frames_per_second = new wxStaticText (this, wxID_ANY, wxT (""));
- _sizer->Add (video_control (_frames_per_second));
+ _sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
video_control (add_label_to_sizer (_sizer, this, "Original Size"));
_original_size = new wxStaticText (this, wxID_ANY, wxT (""));
_audio_gain->SetRange (-60, 60);
_audio_delay->SetRange (-1000, 1000);
_still_duration->SetRange (0, 60 * 60);
-
- vector<Format const *> fmt = Format::all ();
- for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
- _format->Append (std_to_wx ((*i)->name ()));
- }
+ _subtitle_offset->SetRange (-1024, 1024);
+ _subtitle_scale->SetRange (1, 1000);
vector<DCPContentType const *> const ct = DCPContentType::all ();
for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
/* Now connect to them, since initial values are safely set */
_name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
+ _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
+ _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
_format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
_left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
_audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
_still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
_change_dcp_range_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::change_dcp_range_clicked), 0, this);
+ _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
+ _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
+ _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
setup_visibility ();
+ setup_formats ();
}
/** Called when the left crop widget has been changed */
_film->set_content (wx_to_std (_content->GetPath ()));
} catch (std::exception& e) {
_content->SetPath (std_to_wx (_film->directory ()));
- stringstream m;
- m << "Could not set content: " << e.what() << ".";
- error_dialog (this, m.str ());
+ error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
}
_ignore_changes = Film::NONE;
setup_visibility ();
+ setup_formats ();
+ setup_subtitle_button ();
}
/** Called when the DCP A/B switch has been toggled */
_ignore_changes = Film::NONE;
}
+void
+FilmEditor::subtitle_offset_changed (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _ignore_changes = Film::SUBTITLE_OFFSET;
+ _film->set_subtitle_offset (_subtitle_offset->GetValue ());
+ _ignore_changes = Film::NONE;
+}
+
+void
+FilmEditor::subtitle_scale_changed (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _ignore_changes = Film::SUBTITLE_OFFSET;
+ _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
+ _ignore_changes = Film::NONE;
+}
+
+
/** Called when the metadata stored in the Film object has changed;
* so that we can update the GUI.
* @param p Property of the Film that has changed.
case Film::CONTENT:
_content->SetPath (std_to_wx (_film->content ()));
setup_visibility ();
+ setup_formats ();
+ setup_subtitle_button ();
break;
case Film::FORMAT:
- _format->SetSelection (Format::as_index (_film->format ()));
+ {
+ int n = 0;
+ vector<Format const *>::iterator i = _formats.begin ();
+ while (i != _formats.end() && *i != _film->format ()) {
+ ++i;
+ ++n;
+ }
+ _format->SetSelection (n);
break;
+ }
case Film::CROP:
_left_crop->SetValue (_film->crop().left);
_right_crop->SetValue (_film->crop().right);
case Film::STILL_DURATION:
_still_duration->SetValue (_film->still_duration ());
break;
+ case Film::WITH_SUBTITLES:
+ _with_subtitles->SetValue (_film->with_subtitles ());
+ _subtitle_scale->Enable (_film->with_subtitles ());
+ _subtitle_offset->Enable (_film->with_subtitles ());
+ break;
+ case Film::SUBTITLE_OFFSET:
+ _subtitle_offset->SetValue (_film->subtitle_offset ());
+ break;
+ case Film::SUBTITLE_SCALE:
+ _subtitle_scale->SetValue (_film->subtitle_scale() * 100);
+ break;
+ case Film::USE_DCI_NAME:
+ _use_dci_name->SetValue (_film->use_dci_name ());
+ break;
+ case Film::DCI_METADATA:
+ _name->SetValue (std_to_wx (_film->state_copy()->dci_name()));
+ break;
}
}
_ignore_changes = Film::FORMAT;
int const n = _format->GetSelection ();
if (n >= 0) {
- _film->set_format (Format::from_index (n));
+ assert (n < int (_formats.size()));
+ _film->set_format (_formats[n]);
}
_ignore_changes = Film::NONE;
}
film_changed (Film::AUDIO_GAIN);
film_changed (Film::AUDIO_DELAY);
film_changed (Film::STILL_DURATION);
+ film_changed (Film::WITH_SUBTITLES);
+ film_changed (Film::SUBTITLE_OFFSET);
+ film_changed (Film::SUBTITLE_SCALE);
+ film_changed (Film::USE_DCI_NAME);
+ film_changed (Film::DCI_METADATA);
}
/** Updates the sensitivity of lots of widgets to a given value.
FilmEditor::set_things_sensitive (bool s)
{
_name->Enable (s);
+ _use_dci_name->Enable (s);
+ _edit_dci_button->Enable (s);
_frames_per_second->Enable (s);
_format->Enable (s);
_content->Enable (s);
_audio_gain_calculate_button->Enable (s);
_audio_delay->Enable (s);
_still_duration->Enable (s);
+ _with_subtitles->Enable (s);
+ _subtitle_offset->Enable (s);
+ _subtitle_scale->Enable (s);
}
/** Called when the `Edit filters' button has been clicked */
{
GainCalculatorDialog* d = new GainCalculatorDialog (this);
d->ShowModal ();
+
+ if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
+ d->Destroy ();
+ return;
+ }
+
_audio_gain->SetValue (
Config::instance()->sound_processor()->db_for_fader_change (
d->wanted_fader (),
d->actual_fader ()
)
);
+
+ /* This appears to be necessary, as the change is not signalled,
+ I think.
+ */
+ wxCommandEvent dummy;
+ audio_gain_changed (dummy);
+
+ d->Destroy ();
+}
+
+void
+FilmEditor::setup_formats ()
+{
+ ContentType c = VIDEO;
+
+ if (_film) {
+ c = _film->content_type ();
+ }
+
+ _formats.clear ();
+
+ vector<Format const *> fmt = Format::all ();
+ for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
+ if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
+ _formats.push_back (*i);
+ } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
+ _formats.push_back (*i);
+ }
+ }
+
+ _format->Clear ();
+ for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
+ _format->Append (std_to_wx ((*i)->name ()));
+ }
+
+ _sizer->Layout ();
+}
+
+void
+FilmEditor::with_subtitles_toggled (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _ignore_changes = Film::WITH_SUBTITLES;
+ _film->set_with_subtitles (_with_subtitles->GetValue ());
+ _ignore_changes = Film::NONE;
+
+ _subtitle_scale->Enable (_film->with_subtitles ());
+ _subtitle_offset->Enable (_film->with_subtitles ());
+}
+
+void
+FilmEditor::setup_subtitle_button ()
+{
+ _with_subtitles->Enable (_film->has_subtitles ());
+ if (!_film->has_subtitles ()) {
+ _with_subtitles->SetValue (false);
+ }
+}
+
+void
+FilmEditor::use_dci_name_toggled (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _ignore_changes = Film::USE_DCI_NAME;
+ _film->set_use_dci_name (_use_dci_name->GetValue ());
+ _ignore_changes = Film::NONE;
+}
+
+void
+FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ DCINameDialog* d = new DCINameDialog (this, _film);
+ d->ShowModal ();
d->Destroy ();
}