2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/wx/film_editor.cc
22 * @brief FilmEditor class.
26 #include "lib/job_manager.h"
27 #include "lib/content.h"
28 #include "lib/dcp_content.h"
30 #include "film_editor.h"
31 #include "dcp_panel.h"
32 #include "content_panel.h"
34 #include <wx/notebook.h>
39 using boost::shared_ptr;
40 using boost::optional;
42 /** @param f Film to edit */
43 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
46 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
48 _main_notebook = new wxNotebook (this, wxID_ANY);
49 s->Add (_main_notebook, 1);
51 _content_panel = new ContentPanel (_main_notebook, _film, viewer);
52 _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
53 _dcp_panel = new DCPPanel (_main_notebook, _film);
54 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
56 JobManager::instance()->ActiveJobsChanged.connect (
57 bind (&FilmEditor::active_jobs_changed, this, _2)
60 set_film (shared_ptr<Film> ());
65 /** Called when the metadata stored in the Film object has changed;
66 * so that we can update the GUI.
67 * @param p Property of the Film that has changed.
70 FilmEditor::film_changed (Film::Property p)
78 _content_panel->film_changed (p);
79 _dcp_panel->film_changed (p);
81 if (p == Film::CONTENT && !_film->content().empty ()) {
82 /* Select newly-added content */
83 _content_panel->set_selection (_film->content().back ());
88 FilmEditor::film_content_changed (int property)
93 /* We call this method ourselves (as well as using it as a signal handler)
99 _content_panel->film_content_changed (property);
100 _dcp_panel->film_content_changed (property);
103 /** Sets the Film that we are editing */
105 FilmEditor::set_film (shared_ptr<Film> film)
107 set_general_sensitivity (film != 0);
115 _content_panel->set_film (_film);
116 _dcp_panel->set_film (_film);
119 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
120 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
124 FileChanged (_film->directory ());
129 if (!_film->content().empty ()) {
130 _content_panel->set_selection (_film->content().front ());
135 FilmEditor::set_general_sensitivity (bool s)
137 _content_panel->set_general_sensitivity (s);
138 _dcp_panel->set_general_sensitivity (s);
142 FilmEditor::active_jobs_changed (optional<string> j)
144 set_general_sensitivity (!j || *j == "analyse_audio");