2 Copyright (C) 2012-2014 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.
20 /** @file src/film_editor.cc
21 * @brief A wx widget to edit a film's metadata, and perform various functions.
27 #include <wx/notebook.h>
28 #include <wx/listctrl.h>
29 #include <boost/thread.hpp>
30 #include <boost/filesystem.hpp>
31 #include <boost/lexical_cast.hpp>
33 #include "lib/transcode_job.h"
34 #include "lib/exceptions.h"
35 #include "lib/job_manager.h"
36 #include "lib/filter.h"
37 #include "lib/ratio.h"
38 #include "lib/config.h"
39 #include "lib/image_content.h"
40 #include "lib/ffmpeg_content.h"
41 #include "lib/sndfile_content.h"
42 #include "lib/dcp_content_type.h"
43 #include "lib/sound_processor.h"
44 #include "lib/scaler.h"
45 #include "lib/playlist.h"
46 #include "lib/content.h"
47 #include "lib/content_factory.h"
50 #include "film_editor.h"
51 #include "isdcf_metadata_dialog.h"
52 #include "timeline_dialog.h"
53 #include "timing_panel.h"
54 #include "subtitle_panel.h"
55 #include "audio_panel.h"
56 #include "video_panel.h"
60 using std::stringstream;
63 using std::setprecision;
67 using boost::shared_ptr;
68 using boost::weak_ptr;
69 using boost::dynamic_pointer_cast;
70 using boost::lexical_cast;
72 /** @param f Film to edit */
73 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
76 , _generally_sensitive (true)
77 , _timeline_dialog (0)
79 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
81 _main_notebook = new wxNotebook (this, wxID_ANY);
82 s->Add (_main_notebook, 1);
84 make_content_panel ();
85 _main_notebook->AddPage (_content_panel, _("Content"), true);
87 _main_notebook->AddPage (_dcp_panel, _("DCP"), false);
90 connect_to_widgets ();
92 JobManager::instance()->ActiveJobsChanged.connect (
93 bind (&FilmEditor::active_jobs_changed, this, _1)
96 Config::instance()->Changed.connect (boost::bind (&FilmEditor::config_changed, this));
102 FilmEditor::make_dcp_panel ()
104 _dcp_panel = new wxPanel (_main_notebook);
105 _dcp_sizer = new wxBoxSizer (wxVERTICAL);
106 _dcp_panel->SetSizer (_dcp_sizer);
108 wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
109 _dcp_sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
113 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Name"), true, wxGBPosition (r, 0));
114 _name = new wxTextCtrl (_dcp_panel, wxID_ANY);
115 grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
118 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Name"), true, wxGBPosition (r, 0));
119 _dcp_name = new wxStaticText (_dcp_panel, wxID_ANY, wxT (""));
120 grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
123 int flags = wxALIGN_CENTER_VERTICAL;
125 flags |= wxALIGN_RIGHT;
128 _use_isdcf_name = new wxCheckBox (_dcp_panel, wxID_ANY, _("Use ISDCF name"));
129 grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
130 _edit_isdcf_button = new wxButton (_dcp_panel, wxID_ANY, _("Details..."));
131 grid->Add (_edit_isdcf_button, wxGBPosition (r, 1), wxDefaultSpan);
134 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), true, wxGBPosition (r, 0));
135 _container = new wxChoice (_dcp_panel, wxID_ANY);
136 grid->Add (_container, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
139 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), true, wxGBPosition (r, 0));
140 _dcp_content_type = new wxChoice (_dcp_panel, wxID_ANY);
141 grid->Add (_dcp_content_type, wxGBPosition (r, 1));
145 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Frame Rate"), true, wxGBPosition (r, 0));
146 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
147 _frame_rate_choice = new wxChoice (_dcp_panel, wxID_ANY);
148 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
149 _frame_rate_spin = new wxSpinCtrl (_dcp_panel, wxID_ANY);
150 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
151 setup_frame_rate_widget ();
152 _best_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
153 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
154 grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
158 _signed = new wxCheckBox (_dcp_panel, wxID_ANY, _("Signed"));
159 grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
162 _encrypted = new wxCheckBox (_dcp_panel, wxID_ANY, _("Encrypted"));
163 grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
166 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Audio channels"), true, wxGBPosition (r, 0));
167 _audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
168 grid->Add (_audio_channels, wxGBPosition (r, 1));
171 _three_d = new wxCheckBox (_dcp_panel, wxID_ANY, _("3D"));
172 grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
175 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Resolution"), true, wxGBPosition (r, 0));
176 _resolution = new wxChoice (_dcp_panel, wxID_ANY);
177 grid->Add (_resolution, wxGBPosition (r, 1));
181 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
182 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
183 _j2k_bandwidth = new wxSpinCtrl (_dcp_panel, wxID_ANY);
184 s->Add (_j2k_bandwidth, 1);
185 add_label_to_sizer (s, _dcp_panel, _("Mbit/s"), false);
186 grid->Add (s, wxGBPosition (r, 1));
190 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Standard"), true, wxGBPosition (r, 0));
191 _standard = new wxChoice (_dcp_panel, wxID_ANY);
192 grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
195 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), true, wxGBPosition (r, 0));
196 _scaler = new wxChoice (_dcp_panel, wxID_ANY);
197 grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
200 vector<Scaler const *> const sc = Scaler::all ();
201 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
202 _scaler->Append (std_to_wx ((*i)->name()));
205 vector<Ratio const *> const ratio = Ratio::all ();
206 for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
207 _container->Append (std_to_wx ((*i)->nickname ()));
210 vector<DCPContentType const *> const ct = DCPContentType::all ();
211 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
212 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
215 list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
216 for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
217 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
220 _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS);
221 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
222 _frame_rate_spin->SetRange (1, 480);
224 _resolution->Append (_("2K"));
225 _resolution->Append (_("4K"));
227 _standard->Append (_("SMPTE"));
228 _standard->Append (_("Interop"));
232 FilmEditor::connect_to_widgets ()
234 _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&FilmEditor::name_changed, this));
235 _use_isdcf_name->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::use_isdcf_name_toggled, this));
236 _edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::edit_isdcf_button_clicked, this));
237 _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::container_changed, this));
238 _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
239 _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
240 _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
241 _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_file_clicked, this));
242 _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_folder_clicked, this));
243 _content_remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_remove_clicked, this));
244 _content_earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_earlier_clicked, this));
245 _content_later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_later_clicked, this));
246 _content_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_timeline_clicked, this));
247 _scaler->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::scaler_changed, this));
248 _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::dcp_content_type_changed, this));
249 _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::frame_rate_choice_changed, this));
250 _frame_rate_spin->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::frame_rate_spin_changed, this));
251 _best_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::best_frame_rate_clicked, this));
252 _signed->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::signed_toggled, this));
253 _encrypted->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::encrypted_toggled, this));
254 _audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::audio_channels_changed, this));
255 _j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
256 _resolution->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::resolution_changed, this));
257 _sequence_video->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::sequence_video_changed, this));
258 _three_d->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::three_d_changed, this));
259 _standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::standard_changed, this));
263 FilmEditor::make_content_panel ()
265 _content_panel = new wxPanel (_main_notebook);
266 _content_sizer = new wxBoxSizer (wxVERTICAL);
267 _content_panel->SetSizer (_content_sizer);
270 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
272 _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
273 s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
275 _content->InsertColumn (0, wxT(""));
276 _content->SetColumnWidth (0, 512);
278 wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
279 _content_add_file = new wxButton (_content_panel, wxID_ANY, _("Add file(s)..."));
280 b->Add (_content_add_file, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
281 _content_add_folder = new wxButton (_content_panel, wxID_ANY, _("Add folder..."));
282 b->Add (_content_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
283 _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
284 b->Add (_content_remove, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
285 _content_earlier = new wxButton (_content_panel, wxID_ANY, _("Up"));
286 b->Add (_content_earlier, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
287 _content_later = new wxButton (_content_panel, wxID_ANY, _("Down"));
288 b->Add (_content_later, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
289 _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
290 b->Add (_content_timeline, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
292 s->Add (b, 0, wxALL, 4);
294 _content_sizer->Add (s, 0, wxEXPAND | wxALL, 6);
297 _sequence_video = new wxCheckBox (_content_panel, wxID_ANY, _("Keep video in sequence"));
298 _content_sizer->Add (_sequence_video);
300 _content_notebook = new wxNotebook (_content_panel, wxID_ANY);
301 _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
303 _video_panel = new VideoPanel (this);
304 _panels.push_back (_video_panel);
305 _audio_panel = new AudioPanel (this);
306 _panels.push_back (_audio_panel);
307 _subtitle_panel = new SubtitlePanel (this);
308 _panels.push_back (_subtitle_panel);
309 _timing_panel = new TimingPanel (this);
310 _panels.push_back (_timing_panel);
313 /** Called when the name widget has been changed */
315 FilmEditor::name_changed ()
321 _film->set_name (string (_name->GetValue().mb_str()));
325 FilmEditor::j2k_bandwidth_changed ()
331 _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
335 FilmEditor::signed_toggled ()
341 _film->set_signed (_signed->GetValue ());
345 FilmEditor::encrypted_toggled ()
351 _film->set_encrypted (_encrypted->GetValue ());
354 /** Called when the frame rate choice widget has been changed */
356 FilmEditor::frame_rate_choice_changed ()
362 _film->set_video_frame_rate (
363 boost::lexical_cast<int> (
364 wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
369 /** Called when the frame rate spin widget has been changed */
371 FilmEditor::frame_rate_spin_changed ()
377 _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
381 FilmEditor::audio_channels_changed ()
387 _film->set_audio_channels (_audio_channels->GetValue ());
391 FilmEditor::resolution_changed ()
397 _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
401 FilmEditor::standard_changed ()
407 _film->set_interop (_standard->GetSelection() == 1);
410 /** Called when the metadata stored in the Film object has changed;
411 * so that we can update the GUI.
412 * @param p Property of the Film that has changed.
415 FilmEditor::film_changed (Film::Property p)
425 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
426 (*i)->film_changed (p);
435 case Film::CONTAINER:
439 checked_set (_name, _film->name());
442 case Film::DCP_CONTENT_TYPE:
443 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
447 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
450 checked_set (_signed, _film->is_signed ());
452 case Film::ENCRYPTED:
453 checked_set (_encrypted, _film->encrypted ());
454 if (_film->encrypted ()) {
455 _film->set_signed (true);
456 _signed->Enable (false);
458 _signed->Enable (_generally_sensitive);
461 case Film::RESOLUTION:
462 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
465 case Film::J2K_BANDWIDTH:
466 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
468 case Film::USE_ISDCF_NAME:
469 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
472 case Film::ISDCF_METADATA:
475 case Film::VIDEO_FRAME_RATE:
478 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
479 if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
480 checked_set (_frame_rate_choice, i);
487 checked_set (_frame_rate_choice, -1);
490 _frame_rate_spin->SetValue (_film->video_frame_rate ());
492 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
495 case Film::AUDIO_CHANNELS:
496 checked_set (_audio_channels, _film->audio_channels ());
499 case Film::SEQUENCE_VIDEO:
500 checked_set (_sequence_video, _film->sequence_video ());
503 checked_set (_three_d, _film->three_d ());
507 checked_set (_standard, _film->interop() ? 1 : 0);
513 FilmEditor::film_content_changed (int property)
518 /* We call this method ourselves (as well as using it as a signal handler)
524 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
525 (*i)->film_content_changed (property);
528 if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::SUBTITLE_USE) {
530 } else if (property == ContentProperty::PATH) {
536 FilmEditor::setup_container ()
539 vector<Ratio const *> ratios = Ratio::all ();
540 vector<Ratio const *>::iterator i = ratios.begin ();
541 while (i != ratios.end() && *i != _film->container ()) {
546 if (i == ratios.end()) {
547 checked_set (_container, -1);
549 checked_set (_container, n);
555 /** Called when the container widget has been changed */
557 FilmEditor::container_changed ()
563 int const n = _container->GetSelection ();
565 vector<Ratio const *> ratios = Ratio::all ();
566 assert (n < int (ratios.size()));
567 _film->set_container (ratios[n]);
571 /** Called when the DCP content type widget has been changed */
573 FilmEditor::dcp_content_type_changed ()
579 int const n = _dcp_content_type->GetSelection ();
580 if (n != wxNOT_FOUND) {
581 _film->set_dcp_content_type (DCPContentType::from_index (n));
585 /** Sets the Film that we are editing */
587 FilmEditor::set_film (shared_ptr<Film> f)
589 set_general_sensitivity (f != 0);
598 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
599 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
603 FileChanged (_film->directory ());
608 film_changed (Film::NAME);
609 film_changed (Film::USE_ISDCF_NAME);
610 film_changed (Film::CONTENT);
611 film_changed (Film::DCP_CONTENT_TYPE);
612 film_changed (Film::CONTAINER);
613 film_changed (Film::RESOLUTION);
614 film_changed (Film::SCALER);
615 film_changed (Film::SIGNED);
616 film_changed (Film::ENCRYPTED);
617 film_changed (Film::J2K_BANDWIDTH);
618 film_changed (Film::ISDCF_METADATA);
619 film_changed (Film::VIDEO_FRAME_RATE);
620 film_changed (Film::AUDIO_CHANNELS);
621 film_changed (Film::SEQUENCE_VIDEO);
622 film_changed (Film::THREE_D);
623 film_changed (Film::INTEROP);
625 if (!_film->content().empty ()) {
626 set_selection (_film->content().front ());
629 content_selection_changed ();
633 FilmEditor::set_general_sensitivity (bool s)
635 _generally_sensitive = s;
637 /* Stuff in the Content / DCP tabs */
639 _use_isdcf_name->Enable (s);
640 _edit_isdcf_button->Enable (s);
641 _content->Enable (s);
642 _content_add_file->Enable (s);
643 _content_add_folder->Enable (s);
644 _content_remove->Enable (s);
645 _content_earlier->Enable (s);
646 _content_later->Enable (s);
647 _content_timeline->Enable (s);
648 _dcp_content_type->Enable (s);
651 if (_film && _film->encrypted ()) {
654 _signed->Enable (si);
656 _encrypted->Enable (s);
657 _frame_rate_choice->Enable (s);
658 _frame_rate_spin->Enable (s);
659 _audio_channels->Enable (s);
660 _j2k_bandwidth->Enable (s);
661 _container->Enable (s);
662 _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
663 _sequence_video->Enable (s);
664 _resolution->Enable (s);
666 _three_d->Enable (s);
667 _standard->Enable (s);
669 /* Set the panels in the content notebook */
670 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
675 /** Called when the scaler widget has been changed */
677 FilmEditor::scaler_changed ()
683 int const n = _scaler->GetSelection ();
685 _film->set_scaler (Scaler::from_index (n));
690 FilmEditor::use_isdcf_name_toggled ()
696 _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
700 FilmEditor::edit_isdcf_button_clicked ()
706 ISDCFMetadataDialog* d = new ISDCFMetadataDialog (this, _film->isdcf_metadata ());
708 _film->set_isdcf_metadata (d->isdcf_metadata ());
713 FilmEditor::active_jobs_changed (bool a)
715 set_general_sensitivity (!a);
719 FilmEditor::setup_dcp_name ()
721 string s = _film->dcp_name (true);
722 if (s.length() > 28) {
723 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
724 _dcp_name->SetToolTip (std_to_wx (s));
726 _dcp_name->SetLabel (std_to_wx (s));
731 FilmEditor::best_frame_rate_clicked ()
737 _film->set_video_frame_rate (_film->best_video_frame_rate ());
741 FilmEditor::setup_content ()
743 string selected_summary;
744 int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
746 selected_summary = wx_to_std (_content->GetItemText (s));
749 _content->DeleteAllItems ();
751 ContentList content = _film->content ();
752 for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
753 int const t = _content->GetItemCount ();
754 bool const valid = (*i)->paths_valid ();
756 string s = (*i)->summary ();
758 s = _("MISSING: ") + s;
761 _content->InsertItem (t, std_to_wx (s));
763 if ((*i)->summary() == selected_summary) {
764 _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
768 _content->SetItemTextColour (t, *wxRED);
772 if (selected_summary.empty () && !content.empty ()) {
773 /* Select the item of content if none was selected before */
774 _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
779 FilmEditor::content_add_file_clicked ()
781 /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
782 non-Latin filenames or paths.
784 wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR);
785 int const r = d->ShowModal ();
795 /* XXX: check for lots of files here and do something */
797 for (unsigned int i = 0; i < paths.GetCount(); ++i) {
798 _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
805 FilmEditor::content_add_folder_clicked ()
807 wxDirDialog* d = new wxDirDialog (this, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
808 int const r = d->ShowModal ();
815 shared_ptr<ImageContent> ic;
818 ic.reset (new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
819 } catch (FileError& e) {
820 error_dialog (this, std_to_wx (e.what ()));
824 _film->examine_and_add_content (ic);
828 FilmEditor::content_remove_clicked ()
830 ContentList c = selected_content ();
832 _film->remove_content (c.front ());
835 content_selection_changed ();
839 FilmEditor::content_selection_changed ()
841 setup_content_sensitivity ();
843 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
844 (*i)->content_selection_changed ();
848 /** Set up broad sensitivity based on the type of content that is selected */
850 FilmEditor::setup_content_sensitivity ()
852 _content_add_file->Enable (_generally_sensitive);
853 _content_add_folder->Enable (_generally_sensitive);
855 ContentList selection = selected_content ();
856 VideoContentList video_selection = selected_video_content ();
857 AudioContentList audio_selection = selected_audio_content ();
859 _content_remove->Enable (selection.size() == 1 && _generally_sensitive);
860 _content_earlier->Enable (selection.size() == 1 && _generally_sensitive);
861 _content_later->Enable (selection.size() == 1 && _generally_sensitive);
862 _content_timeline->Enable (!_film->content().empty() && _generally_sensitive);
864 _video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
865 _audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
866 _subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<SubtitleContent> (selection.front()) && _generally_sensitive);
867 _timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
871 FilmEditor::selected_content ()
876 s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
881 if (s < int (_film->content().size ())) {
882 sel.push_back (_film->content()[s]);
890 FilmEditor::selected_video_content ()
892 ContentList c = selected_content ();
895 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
896 shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
906 FilmEditor::selected_audio_content ()
908 ContentList c = selected_content ();
911 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
912 shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
922 FilmEditor::selected_subtitle_content ()
924 ContentList c = selected_content ();
925 SubtitleContentList sc;
927 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
928 shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
938 FilmEditor::selected_ffmpeg_content ()
940 ContentList c = selected_content ();
941 FFmpegContentList sc;
943 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
944 shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (*i);
954 FilmEditor::content_timeline_clicked ()
956 if (_timeline_dialog) {
957 _timeline_dialog->Destroy ();
958 _timeline_dialog = 0;
961 _timeline_dialog = new TimelineDialog (this, _film);
962 _timeline_dialog->Show ();
966 FilmEditor::set_selection (weak_ptr<Content> wc)
968 ContentList content = _film->content ();
969 for (size_t i = 0; i < content.size(); ++i) {
970 if (content[i] == wc.lock ()) {
971 _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
973 _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
979 FilmEditor::sequence_video_changed ()
985 _film->set_sequence_video (_sequence_video->GetValue ());
989 FilmEditor::content_right_click (wxListEvent& ev)
991 _menu.popup (_film, selected_content (), ev.GetPoint ());
995 FilmEditor::three_d_changed ()
1001 _film->set_three_d (_three_d->GetValue ());
1005 FilmEditor::content_earlier_clicked ()
1007 ContentList sel = selected_content ();
1008 if (sel.size() == 1) {
1009 _film->move_content_earlier (sel.front ());
1010 content_selection_changed ();
1015 FilmEditor::content_later_clicked ()
1017 ContentList sel = selected_content ();
1018 if (sel.size() == 1) {
1019 _film->move_content_later (sel.front ());
1020 content_selection_changed ();
1025 FilmEditor::config_changed ()
1027 _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
1028 setup_frame_rate_widget ();
1032 FilmEditor::setup_frame_rate_widget ()
1034 if (Config::instance()->allow_any_dcp_frame_rate ()) {
1035 _frame_rate_choice->Hide ();
1036 _frame_rate_spin->Show ();
1038 _frame_rate_choice->Show ();
1039 _frame_rate_spin->Hide ();
1042 _frame_rate_sizer->Layout ();