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/scaler.h"
44 #include "lib/playlist.h"
45 #include "lib/content.h"
46 #include "lib/content_factory.h"
47 #include "lib/dcp_content.h"
48 #include "lib/safe_stringstream.h"
51 #include "film_editor.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"
57 #include "content_panel.h"
58 #include "dcp_panel.h"
64 using std::setprecision;
68 using boost::shared_ptr;
69 using boost::weak_ptr;
70 using boost::dynamic_pointer_cast;
71 using boost::lexical_cast;
73 /** @param f Film to edit */
74 FilmEditor::FilmEditor (wxWindow* parent)
77 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
79 _main_notebook = new wxNotebook (this, wxID_ANY);
80 s->Add (_main_notebook, 1);
82 _content_panel = new ContentPanel (_main_notebook, _film);
83 _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
84 _dcp_panel = new DCPPanel (_main_notebook, _film);
85 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
87 JobManager::instance()->ActiveJobsChanged.connect (
88 bind (&FilmEditor::active_jobs_changed, this, _1)
91 set_film (shared_ptr<Film> ());
97 /** Called when the metadata stored in the Film object has changed;
98 * so that we can update the GUI.
99 * @param p Property of the Film that has changed.
102 FilmEditor::film_changed (Film::Property p)
110 _content_panel->film_changed (p);
111 _dcp_panel->film_changed (p);
115 FilmEditor::film_content_changed (int property)
120 /* We call this method ourselves (as well as using it as a signal handler)
126 _content_panel->film_content_changed (property);
127 _dcp_panel->film_content_changed (property);
130 /** Sets the Film that we are editing */
132 FilmEditor::set_film (shared_ptr<Film> f)
134 set_general_sensitivity (f != 0);
142 _content_panel->set_film (_film);
143 _dcp_panel->set_film (_film);
146 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
147 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
151 FileChanged (_film->directory ());
156 if (!_film->content().empty ()) {
157 _content_panel->set_selection (_film->content().front ());
162 FilmEditor::set_general_sensitivity (bool s)
164 _content_panel->set_general_sensitivity (s);
165 _dcp_panel->set_general_sensitivity (s);
169 FilmEditor::active_jobs_changed (bool a)
171 set_general_sensitivity (!a);