From 4d3caea8b70b4a19c8aa80d626d52d4f95114f8e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 Oct 2012 02:35:30 +0100 Subject: [PATCH] Clumsy DCI naming dialog. --- src/lib/film.cc | 63 +++++++++++++++++ src/lib/film.h | 49 ++++++++++++- src/lib/film_state.cc | 27 ++++++++ src/lib/film_state.h | 4 +- src/wx/dci_name_dialog.cc | 141 ++++++++++++++++++++++++++++++++++++++ src/wx/dci_name_dialog.h | 50 ++++++++++++++ src/wx/film_editor.cc | 36 ++++++++++ src/wx/film_editor.h | 2 + src/wx/wscript | 17 ++--- 9 files changed, 379 insertions(+), 10 deletions(-) create mode 100644 src/wx/dci_name_dialog.cc create mode 100644 src/wx/dci_name_dialog.h diff --git a/src/lib/film.cc b/src/lib/film.cc index e4e7763d5..541d96f1e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -690,3 +690,66 @@ Film::thumb_subtitle (int n) const return sub; } + +void +Film::set_dci_name_prefix (string v) +{ + _state.dci_name_prefix = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_audio_language (string v) +{ + _state.audio_language = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_subtitle_language (string v) +{ + _state.subtitle_language = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_territory (string v) +{ + _state.territory = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_rating (string v) +{ + _state.rating = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_studio (string v) +{ + _state.studio = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_facility (string v) +{ + _state.facility = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_package_type (string v) +{ + _state.package_type = v; + signal_changed (DCI_METADATA); +} + +void +Film::set_use_dci_name (bool v) +{ + _state.use_dci_name = v; + signal_changed (USE_DCI_NAME); +} diff --git a/src/lib/film.h b/src/lib/film.h index 46c67ad19..9eb39fd64 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -71,6 +71,10 @@ public: return _state.name; } + bool use_dci_name () const { + return _state.use_dci_name; + } + /** @return number of pixels to crop from the sides of the original picture */ Crop crop () const { return _state.crop; @@ -146,6 +150,7 @@ public: void set_dcp_ab (bool); void set_name (std::string); + void set_use_dci_name (bool); void set_content (std::string); void set_top_crop (int); void set_bottom_crop (int); @@ -159,6 +164,14 @@ public: void set_with_subtitles (bool); void set_subtitle_offset (int); void set_subtitle_scale (float); + void set_dci_name_prefix (std::string); + void set_audio_language (std::string); + void set_subtitle_language (std::string); + void set_territory (std::string); + void set_rating (std::string); + void set_studio (std::string); + void set_facility (std::string); + void set_package_type (std::string); /** @return size, in pixels, of the source (ignoring cropping) */ Size size () const { @@ -193,7 +206,39 @@ public: bool has_subtitles () const { return _state.has_subtitles; } + + std::string dci_name_prefix () const { + return _state.dci_name_prefix; + } + + std::string audio_language () const { + return _state.audio_language; + } + + std::string subtitle_language () const { + return _state.subtitle_language; + } + std::string territory () const { + return _state.territory; + } + + std::string rating () const { + return _state.rating; + } + + std::string studio () const { + return _state.studio; + } + + std::string facility () const { + return _state.facility; + } + + std::string package_type () const { + return _state.package_type; + } + std::string j2k_dir () const; std::vector audio_files () const; @@ -241,7 +286,9 @@ public: STILL_DURATION, WITH_SUBTITLES, SUBTITLE_OFFSET, - SUBTITLE_SCALE + SUBTITLE_SCALE, + USE_DCI_NAME, + DCI_METADATA }; boost::shared_ptr state_copy () const; diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index fed506863..862d69d7d 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -49,6 +49,7 @@ FilmState::write_metadata (ofstream& f) const { /* User stuff */ f << "name " << name << "\n"; + f << "use_dci_name " << use_dci_name << "\n"; f << "content " << content << "\n"; if (dcp_content_type) { f << "dcp_content_type " << dcp_content_type->pretty_name () << "\n"; @@ -99,6 +100,14 @@ FilmState::write_metadata (ofstream& f) const f << "audio_sample_format " << audio_sample_format_to_string (audio_sample_format) << "\n"; f << "content_digest " << content_digest << "\n"; f << "has_subtitles " << has_subtitles << "\n"; + f << "dci_name_prefix " << dci_name_prefix << "\n"; + f << "audio_language " << audio_language << "\n"; + f << "subtitle_language " << subtitle_language << "\n"; + f << "territory " << territory << "\n"; + f << "rating " << rating << "\n"; + f << "studio " << studio << "\n"; + f << "facility " << facility << "\n"; + f << "package_type " << package_type << "\n"; } /** Read state from a key / value pair. @@ -111,6 +120,8 @@ FilmState::read_metadata (string k, string v) /* User-specified stuff */ if (k == "name") { name = v; + } else if (k == "use_dci_name") { + use_dci_name = (v == "1"); } else if (k == "content") { content = v; } else if (k == "dcp_content_type") { @@ -178,6 +189,22 @@ FilmState::read_metadata (string k, string v) content_digest = v; } else if (k == "has_subtitles") { has_subtitles = (v == "1"); + } else if (k == "dci_name_prefix") { + dci_name_prefix = v; + } else if (k == "audio_language") { + audio_language = v; + } else if (k == "subtitle_language") { + subtitle_language = v; + } else if (k == "territory") { + territory = v; + } else if (k == "rating") { + rating = v; + } else if (k == "studio") { + studio = v; + } else if (k == "facility") { + facility = v; + } else if (k == "package_type") { + package_type = v; } } diff --git a/src/lib/film_state.h b/src/lib/film_state.h index e58d46b0f..83ae2c594 100644 --- a/src/lib/film_state.h +++ b/src/lib/film_state.h @@ -52,7 +52,8 @@ class FilmState { public: FilmState () - : dcp_content_type (0) + : use_dci_name (false) + , dcp_content_type (0) , frames_per_second (0) , format (0) , scaler (Scaler::from_id ("bicubic")) @@ -100,6 +101,7 @@ public: std::string directory; /** Name for DVD-o-matic */ std::string name; + bool use_dci_name; /** File or directory containing content; may be relative to our directory * or an absolute path. */ diff --git a/src/wx/dci_name_dialog.cc b/src/wx/dci_name_dialog.cc new file mode 100644 index 000000000..9feb4aa86 --- /dev/null +++ b/src/wx/dci_name_dialog.cc @@ -0,0 +1,141 @@ +/* + Copyright (C) 2012 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include "dci_name_dialog.h" +#include "wx_util.h" +#include "film.h" + +DCINameDialog::DCINameDialog (wxWindow* parent, Film* film) + : wxDialog (parent, wxID_ANY, _("DCI name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + , _film (film) +{ + wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); + table->AddGrowableCol (1, 1); + + add_label_to_sizer (table, this, "Short Name (e.g. BLUES-BROS)"); + _dci_name_prefix = new wxTextCtrl (this, wxID_ANY); + table->Add (_dci_name_prefix, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Audio Language (e.g. EN)"); + _audio_language = new wxTextCtrl (this, wxID_ANY); + table->Add (_audio_language, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Subtitle Language (e.g. FR)"); + _subtitle_language = new wxTextCtrl (this, wxID_ANY); + table->Add (_subtitle_language, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Territory (e.g. UK)"); + _territory = new wxTextCtrl (this, wxID_ANY); + table->Add (_territory, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Rating (e.g. 15"); + _rating = new wxTextCtrl (this, wxID_ANY); + table->Add (_rating, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Studio (e.g. TCF)"); + _studio = new wxTextCtrl (this, wxID_ANY); + table->Add (_studio, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Facility (e.g. DLA)"); + _facility = new wxTextCtrl (this, wxID_ANY); + table->Add (_facility, 1, wxEXPAND); + + add_label_to_sizer (table, this, "Package Type (e.g. OV"); + _package_type = new wxTextCtrl (this, wxID_ANY); + table->Add (_package_type, 1, wxEXPAND); + + _dci_name_prefix->SetValue (std_to_wx (_film->dci_name_prefix ())); + _audio_language->SetValue (std_to_wx (_film->audio_language ())); + _subtitle_language->SetValue (std_to_wx (_film->subtitle_language ())); + _territory->SetValue (std_to_wx (_film->territory ())); + _rating->SetValue (std_to_wx (_film->rating ())); + _studio->SetValue (std_to_wx (_film->studio ())); + _facility->SetValue (std_to_wx (_film->facility ())); + _package_type->SetValue (std_to_wx (_film->package_type ())); + + _dci_name_prefix->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::dci_name_prefix_changed), 0, this); + _audio_language->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::audio_language_changed), 0, this); + _subtitle_language->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::subtitle_language_changed), 0, this); + _territory->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::territory_changed), 0, this); + _rating->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::rating_changed), 0, this); + _studio->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::studio_changed), 0, this); + _facility->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::facility_changed), 0, this); + _package_type->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::package_type_changed), 0, this); + + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6); + + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); + if (buttons) { + overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizer (overall_sizer); + overall_sizer->Layout (); + overall_sizer->SetSizeHints (this); +} + +void +DCINameDialog::dci_name_prefix_changed (wxCommandEvent &) +{ + _film->set_dci_name_prefix (wx_to_std (_dci_name_prefix->GetValue ())); +} + +void +DCINameDialog::audio_language_changed (wxCommandEvent &) +{ + _film->set_audio_language (wx_to_std (_audio_language->GetValue ())); +} + +void +DCINameDialog::subtitle_language_changed (wxCommandEvent &) +{ + _film->set_subtitle_language (wx_to_std (_subtitle_language->GetValue ())); +} + +void +DCINameDialog::territory_changed (wxCommandEvent &) +{ + _film->set_territory (wx_to_std (_territory->GetValue ())); +} + +void +DCINameDialog::rating_changed (wxCommandEvent &) +{ + _film->set_rating (wx_to_std (_rating->GetValue ())); +} + +void +DCINameDialog::studio_changed (wxCommandEvent &) +{ + _film->set_studio (wx_to_std (_studio->GetValue ())); +} + +void +DCINameDialog::facility_changed (wxCommandEvent &) +{ + _film->set_facility (wx_to_std (_facility->GetValue ())); +} + +void +DCINameDialog::package_type_changed (wxCommandEvent &) +{ + _film->set_package_type (wx_to_std (_package_type->GetValue ())); +} diff --git a/src/wx/dci_name_dialog.h b/src/wx/dci_name_dialog.h new file mode 100644 index 000000000..95578f779 --- /dev/null +++ b/src/wx/dci_name_dialog.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2012 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include + +class Film; + +class DCINameDialog : public wxDialog +{ +public: + DCINameDialog (wxWindow *, Film *); + +private: + void dci_name_prefix_changed (wxCommandEvent &); + void audio_language_changed (wxCommandEvent &); + void subtitle_language_changed (wxCommandEvent &); + void territory_changed (wxCommandEvent &); + void rating_changed (wxCommandEvent &); + void studio_changed (wxCommandEvent &); + void facility_changed (wxCommandEvent &); + void package_type_changed (wxCommandEvent &); + + wxTextCtrl* _dci_name_prefix; + wxTextCtrl* _audio_language; + wxTextCtrl* _subtitle_language; + wxTextCtrl* _territory; + wxTextCtrl* _rating; + wxTextCtrl* _studio; + wxTextCtrl* _facility; + wxTextCtrl* _package_type; + + Film* _film; +}; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 7fd2eb9fc..946c91e0c 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -43,6 +43,7 @@ #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; @@ -222,6 +223,8 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) /* 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); @@ -503,6 +506,12 @@ FilmEditor::film_changed (Film::Property p) 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; } } @@ -578,6 +587,8 @@ FilmEditor::set_film (Film* f) 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. @@ -587,6 +598,8 @@ void 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); @@ -799,3 +812,26 @@ FilmEditor::setup_subtitle_button () } } +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 (); +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 2a3be6d0c..2d13d2dc9 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -46,6 +46,8 @@ public: private: /* Handle changes to the view */ void name_changed (wxCommandEvent &); + void use_dci_name_toggled (wxCommandEvent &); + void edit_dci_button_clicked (wxCommandEvent &); void left_crop_changed (wxCommandEvent &); void right_crop_changed (wxCommandEvent &); void top_crop_changed (wxCommandEvent &); diff --git a/src/wx/wscript b/src/wx/wscript index 38107bb54..df2edbde1 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -9,20 +9,21 @@ def build(bld): obj.uselib = 'WXWIDGETS' obj.use = 'libdvdomatic' obj.source = """ + config_dialog.cc + dci_name_dialog.cc + dcp_range_dialog.cc + dir_picker_ctrl.cc film_editor.cc - wx_util.cc film_viewer.cc - job_manager_view.cc - job_wrapper.cc - gain_calculator_dialog.cc - config_dialog.cc filter_dialog.cc filter_view.cc - dcp_range_dialog.cc - server_dialog.cc + gain_calculator_dialog.cc + job_manager_view.cc + job_wrapper.cc new_film_dialog.cc - dir_picker_ctrl.cc properties_dialog.cc + server_dialog.cc + wx_util.cc """ # alignment.cc -- 2.30.2