2 Copyright (C) 2012-2013 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 "dci_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)
100 FilmEditor::make_dcp_panel ()
102 _dcp_panel = new wxPanel (_main_notebook);
103 _dcp_sizer = new wxBoxSizer (wxVERTICAL);
104 _dcp_panel->SetSizer (_dcp_sizer);
106 wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
107 _dcp_sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
111 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Name"), true, wxGBPosition (r, 0));
112 _name = new wxTextCtrl (_dcp_panel, wxID_ANY);
113 grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
116 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Name"), true, wxGBPosition (r, 0));
117 _dcp_name = new wxStaticText (_dcp_panel, wxID_ANY, wxT (""));
118 grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
121 int flags = wxALIGN_CENTER_VERTICAL;
123 flags |= wxALIGN_RIGHT;
126 _use_dci_name = new wxCheckBox (_dcp_panel, wxID_ANY, _("Use DCI name"));
127 grid->Add (_use_dci_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
128 _edit_dci_button = new wxButton (_dcp_panel, wxID_ANY, _("Details..."));
129 grid->Add (_edit_dci_button, wxGBPosition (r, 1), wxDefaultSpan);
132 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), true, wxGBPosition (r, 0));
133 _container = new wxChoice (_dcp_panel, wxID_ANY);
134 grid->Add (_container, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
137 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), true, wxGBPosition (r, 0));
138 _dcp_content_type = new wxChoice (_dcp_panel, wxID_ANY);
139 grid->Add (_dcp_content_type, wxGBPosition (r, 1));
143 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Frame Rate"), true, wxGBPosition (r, 0));
144 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
145 _frame_rate = new wxChoice (_dcp_panel, wxID_ANY);
146 s->Add (_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
147 _best_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
148 s->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
149 grid->Add (s, wxGBPosition (r, 1));
153 _encrypted = new wxCheckBox (_dcp_panel, wxID_ANY, _("Encrypted"));
154 grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
157 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Audio channels"), true, wxGBPosition (r, 0));
158 _audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
159 grid->Add (_audio_channels, wxGBPosition (r, 1));
162 _three_d = new wxCheckBox (_dcp_panel, wxID_ANY, _("3D"));
163 grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
166 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Resolution"), true, wxGBPosition (r, 0));
167 _resolution = new wxChoice (_dcp_panel, wxID_ANY);
168 grid->Add (_resolution, wxGBPosition (r, 1));
172 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
173 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
174 _j2k_bandwidth = new wxSpinCtrl (_dcp_panel, wxID_ANY);
175 s->Add (_j2k_bandwidth, 1);
176 add_label_to_sizer (s, _dcp_panel, _("MBps"), false);
177 grid->Add (s, wxGBPosition (r, 1));
181 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Standard"), true, wxGBPosition (r, 0));
182 _standard = new wxChoice (_dcp_panel, wxID_ANY);
183 grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
186 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), true, wxGBPosition (r, 0));
187 _scaler = new wxChoice (_dcp_panel, wxID_ANY);
188 grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
191 vector<Scaler const *> const sc = Scaler::all ();
192 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
193 _scaler->Append (std_to_wx ((*i)->name()));
196 vector<Ratio const *> const ratio = Ratio::all ();
197 for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
198 _container->Append (std_to_wx ((*i)->nickname ()));
201 vector<DCPContentType const *> const ct = DCPContentType::all ();
202 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
203 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
206 list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
207 for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
208 _frame_rate->Append (std_to_wx (boost::lexical_cast<string> (*i)));
211 _audio_channels->SetRange (0, MAX_AUDIO_CHANNELS);
212 _j2k_bandwidth->SetRange (1, 250);
214 _resolution->Append (_("2K"));
215 _resolution->Append (_("4K"));
217 _standard->Append (_("SMPTE"));
218 _standard->Append (_("Interop"));
222 FilmEditor::connect_to_widgets ()
224 _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&FilmEditor::name_changed, this));
225 _use_dci_name->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::use_dci_name_toggled, this));
226 _edit_dci_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::edit_dci_button_clicked, this));
227 _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::container_changed, this));
228 _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
229 _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
230 _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
231 _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_file_clicked, this));
232 _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_folder_clicked, this));
233 _content_remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_remove_clicked, this));
234 _content_earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_earlier_clicked, this));
235 _content_later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_later_clicked, this));
236 _content_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_timeline_clicked, this));
237 _scaler->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::scaler_changed, this));
238 _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::dcp_content_type_changed, this));
239 _frame_rate->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::frame_rate_changed, this));
240 _best_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::best_frame_rate_clicked, this));
241 _encrypted->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::encrypted_toggled, this));
242 _audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::audio_channels_changed, this));
243 _j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
244 _resolution->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::resolution_changed, this));
245 _sequence_video->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::sequence_video_changed, this));
246 _three_d->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::three_d_changed, this));
247 _standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::standard_changed, this));
251 FilmEditor::make_content_panel ()
253 _content_panel = new wxPanel (_main_notebook);
254 _content_sizer = new wxBoxSizer (wxVERTICAL);
255 _content_panel->SetSizer (_content_sizer);
258 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
260 _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
261 s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
263 _content->InsertColumn (0, wxT(""));
264 _content->SetColumnWidth (0, 512);
266 wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
267 _content_add_file = new wxButton (_content_panel, wxID_ANY, _("Add file(s)..."));
268 b->Add (_content_add_file, 1, wxEXPAND | wxLEFT | wxRIGHT);
269 _content_add_folder = new wxButton (_content_panel, wxID_ANY, _("Add folder..."));
270 b->Add (_content_add_folder, 1, wxEXPAND | wxLEFT | wxRIGHT);
271 _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
272 b->Add (_content_remove, 1, wxEXPAND | wxLEFT | wxRIGHT);
273 _content_earlier = new wxButton (_content_panel, wxID_UP);
274 b->Add (_content_earlier, 1, wxEXPAND);
275 _content_later = new wxButton (_content_panel, wxID_DOWN);
276 b->Add (_content_later, 1, wxEXPAND);
277 _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
278 b->Add (_content_timeline, 1, wxEXPAND | wxLEFT | wxRIGHT);
280 s->Add (b, 0, wxALL, 4);
282 _content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
285 _sequence_video = new wxCheckBox (_content_panel, wxID_ANY, _("Keep video in sequence"));
286 _content_sizer->Add (_sequence_video);
288 _content_notebook = new wxNotebook (_content_panel, wxID_ANY);
289 _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
291 _video_panel = new VideoPanel (this);
292 _panels.push_back (_video_panel);
293 _audio_panel = new AudioPanel (this);
294 _panels.push_back (_audio_panel);
295 _subtitle_panel = new SubtitlePanel (this);
296 _panels.push_back (_subtitle_panel);
297 _timing_panel = new TimingPanel (this);
298 _panels.push_back (_timing_panel);
301 /** Called when the name widget has been changed */
303 FilmEditor::name_changed ()
309 _film->set_name (string (_name->GetValue().mb_str()));
313 FilmEditor::j2k_bandwidth_changed ()
319 _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
323 FilmEditor::encrypted_toggled ()
329 _film->set_encrypted (_encrypted->GetValue ());
332 /** Called when the name widget has been changed */
334 FilmEditor::frame_rate_changed ()
340 _film->set_video_frame_rate (
341 boost::lexical_cast<int> (
342 wx_to_std (_frame_rate->GetString (_frame_rate->GetSelection ()))
348 FilmEditor::audio_channels_changed ()
354 _film->set_audio_channels (_audio_channels->GetValue ());
358 FilmEditor::resolution_changed ()
364 _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
368 FilmEditor::standard_changed ()
374 _film->set_interop (_standard->GetSelection() == 1);
377 /** Called when the metadata stored in the Film object has changed;
378 * so that we can update the GUI.
379 * @param p Property of the Film that has changed.
382 FilmEditor::film_changed (Film::Property p)
392 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
393 (*i)->film_changed (p);
402 case Film::CONTAINER:
406 checked_set (_name, _film->name());
409 case Film::WITH_SUBTITLES:
412 case Film::DCP_CONTENT_TYPE:
413 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
417 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
419 case Film::ENCRYPTED:
420 checked_set (_encrypted, _film->encrypted ());
422 case Film::RESOLUTION:
423 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
426 case Film::J2K_BANDWIDTH:
427 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
429 case Film::USE_DCI_NAME:
430 checked_set (_use_dci_name, _film->use_dci_name ());
433 case Film::DCI_METADATA:
436 case Film::VIDEO_FRAME_RATE:
439 for (unsigned int i = 0; i < _frame_rate->GetCount(); ++i) {
440 if (wx_to_std (_frame_rate->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
441 checked_set (_frame_rate, i);
448 checked_set (_frame_rate, -1);
451 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
454 case Film::AUDIO_CHANNELS:
455 checked_set (_audio_channels, _film->audio_channels ());
458 case Film::SEQUENCE_VIDEO:
459 checked_set (_sequence_video, _film->sequence_video ());
462 checked_set (_three_d, _film->three_d ());
466 checked_set (_standard, _film->interop() ? 1 : 0);
472 FilmEditor::film_content_changed (int property)
477 /* We call this method ourselves (as well as using it as a signal handler)
483 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
484 (*i)->film_content_changed (property);
487 if (property == FFmpegContentProperty::AUDIO_STREAM) {
489 } else if (property == ContentProperty::PATH) {
495 FilmEditor::setup_container ()
498 vector<Ratio const *> ratios = Ratio::all ();
499 vector<Ratio const *>::iterator i = ratios.begin ();
500 while (i != ratios.end() && *i != _film->container ()) {
505 if (i == ratios.end()) {
506 checked_set (_container, -1);
508 checked_set (_container, n);
514 /** Called when the container widget has been changed */
516 FilmEditor::container_changed ()
522 int const n = _container->GetSelection ();
524 vector<Ratio const *> ratios = Ratio::all ();
525 assert (n < int (ratios.size()));
526 _film->set_container (ratios[n]);
530 /** Called when the DCP content type widget has been changed */
532 FilmEditor::dcp_content_type_changed ()
538 int const n = _dcp_content_type->GetSelection ();
539 if (n != wxNOT_FOUND) {
540 _film->set_dcp_content_type (DCPContentType::from_index (n));
544 /** Sets the Film that we are editing */
546 FilmEditor::set_film (shared_ptr<Film> f)
548 set_general_sensitivity (f != 0);
557 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
558 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
562 FileChanged (_film->directory ());
567 film_changed (Film::NAME);
568 film_changed (Film::USE_DCI_NAME);
569 film_changed (Film::CONTENT);
570 film_changed (Film::DCP_CONTENT_TYPE);
571 film_changed (Film::CONTAINER);
572 film_changed (Film::RESOLUTION);
573 film_changed (Film::SCALER);
574 film_changed (Film::WITH_SUBTITLES);
575 film_changed (Film::ENCRYPTED);
576 film_changed (Film::J2K_BANDWIDTH);
577 film_changed (Film::DCI_METADATA);
578 film_changed (Film::VIDEO_FRAME_RATE);
579 film_changed (Film::AUDIO_CHANNELS);
580 film_changed (Film::ENCRYPTED);
581 film_changed (Film::SEQUENCE_VIDEO);
582 film_changed (Film::THREE_D);
583 film_changed (Film::INTEROP);
585 if (!_film->content().empty ()) {
586 set_selection (_film->content().front ());
589 content_selection_changed ();
593 FilmEditor::set_general_sensitivity (bool s)
595 _generally_sensitive = s;
597 /* Stuff in the Content / DCP tabs */
599 _use_dci_name->Enable (s);
600 _edit_dci_button->Enable (s);
601 _content->Enable (s);
602 _content_add_file->Enable (s);
603 _content_add_folder->Enable (s);
604 _content_remove->Enable (s);
605 _content_earlier->Enable (s);
606 _content_later->Enable (s);
607 _content_timeline->Enable (s);
608 _dcp_content_type->Enable (s);
609 _encrypted->Enable (s);
610 _frame_rate->Enable (s);
611 _audio_channels->Enable (s);
612 _j2k_bandwidth->Enable (s);
613 _container->Enable (s);
614 _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
615 _sequence_video->Enable (s);
616 _resolution->Enable (s);
618 _three_d->Enable (s);
619 _standard->Enable (s);
621 /* Set the panels in the content notebook */
622 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
627 /** Called when the scaler widget has been changed */
629 FilmEditor::scaler_changed ()
635 int const n = _scaler->GetSelection ();
637 _film->set_scaler (Scaler::from_index (n));
642 FilmEditor::use_dci_name_toggled ()
648 _film->set_use_dci_name (_use_dci_name->GetValue ());
652 FilmEditor::edit_dci_button_clicked ()
658 DCIMetadataDialog* d = new DCIMetadataDialog (this, _film->dci_metadata ());
660 _film->set_dci_metadata (d->dci_metadata ());
665 FilmEditor::active_jobs_changed (bool a)
667 set_general_sensitivity (!a);
671 FilmEditor::setup_dcp_name ()
673 string s = _film->dcp_name (true);
674 if (s.length() > 28) {
675 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
676 _dcp_name->SetToolTip (std_to_wx (s));
678 _dcp_name->SetLabel (std_to_wx (s));
683 FilmEditor::best_frame_rate_clicked ()
689 _film->set_video_frame_rate (_film->best_video_frame_rate ());
693 FilmEditor::setup_content ()
695 string selected_summary;
696 int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
698 selected_summary = wx_to_std (_content->GetItemText (s));
701 _content->DeleteAllItems ();
703 ContentList content = _film->content ();
704 for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
705 int const t = _content->GetItemCount ();
706 bool const valid = (*i)->path_valid ();
708 string s = (*i)->summary ();
710 s = _("MISSING: ") + s;
713 _content->InsertItem (t, std_to_wx (s));
715 if ((*i)->summary() == selected_summary) {
716 _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
720 _content->SetItemTextColour (t, *wxRED);
724 if (selected_summary.empty () && !content.empty ()) {
725 /* Select the item of content if none was selected before */
726 _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
731 FilmEditor::content_add_file_clicked ()
733 /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
734 non-Latin filenames or paths.
736 wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR);
737 int const r = d->ShowModal ();
747 /* XXX: check for lots of files here and do something */
749 for (unsigned int i = 0; i < paths.GetCount(); ++i) {
750 _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
757 FilmEditor::content_add_folder_clicked ()
759 wxDirDialog* d = new wxDirDialog (this, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
760 int const r = d->ShowModal ();
767 _film->examine_and_add_content (
768 shared_ptr<ImageContent> (
769 new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ())))
775 FilmEditor::content_remove_clicked ()
777 ContentList c = selected_content ();
779 _film->remove_content (c.front ());
782 content_selection_changed ();
786 FilmEditor::content_selection_changed ()
788 setup_content_sensitivity ();
790 for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
791 (*i)->content_selection_changed ();
795 /** Set up broad sensitivity based on the type of content that is selected */
797 FilmEditor::setup_content_sensitivity ()
799 _content_add_file->Enable (_generally_sensitive);
800 _content_add_folder->Enable (_generally_sensitive);
802 ContentList selection = selected_content ();
803 VideoContentList video_selection = selected_video_content ();
804 AudioContentList audio_selection = selected_audio_content ();
806 _content_remove->Enable (selection.size() == 1 && _generally_sensitive);
807 _content_earlier->Enable (selection.size() == 1 && _generally_sensitive);
808 _content_later->Enable (selection.size() == 1 && _generally_sensitive);
809 _content_timeline->Enable (_generally_sensitive);
811 _video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
812 _audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
813 _subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<FFmpegContent> (selection.front()) && _generally_sensitive);
814 _timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
818 FilmEditor::selected_content ()
823 s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
828 if (s < int (_film->content().size ())) {
829 sel.push_back (_film->content()[s]);
837 FilmEditor::selected_video_content ()
839 ContentList c = selected_content ();
842 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
843 shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
853 FilmEditor::selected_audio_content ()
855 ContentList c = selected_content ();
858 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
859 shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
869 FilmEditor::selected_subtitle_content ()
871 ContentList c = selected_content ();
872 SubtitleContentList sc;
874 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
875 shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
885 FilmEditor::selected_ffmpeg_content ()
887 ContentList c = selected_content ();
888 FFmpegContentList sc;
890 for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
891 shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (*i);
901 FilmEditor::content_timeline_clicked ()
903 if (_timeline_dialog) {
904 _timeline_dialog->Destroy ();
905 _timeline_dialog = 0;
908 _timeline_dialog = new TimelineDialog (this, _film);
909 _timeline_dialog->Show ();
913 FilmEditor::set_selection (weak_ptr<Content> wc)
915 ContentList content = _film->content ();
916 for (size_t i = 0; i < content.size(); ++i) {
917 if (content[i] == wc.lock ()) {
918 _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
920 _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
926 FilmEditor::sequence_video_changed ()
932 _film->set_sequence_video (_sequence_video->GetValue ());
936 FilmEditor::content_right_click (wxListEvent& ev)
938 _menu.popup (selected_content (), ev.GetPoint ());
942 FilmEditor::three_d_changed ()
948 _film->set_three_d (_three_d->GetValue ());
952 FilmEditor::content_earlier_clicked ()
954 ContentList sel = selected_content ();
955 if (sel.size() == 1) {
956 _film->move_content_earlier (sel.front ());
957 content_selection_changed ();
962 FilmEditor::content_later_clicked ()
964 ContentList sel = selected_content ();
965 if (sel.size() == 1) {
966 _film->move_content_later (sel.front ());
967 content_selection_changed ();