2 Copyright (C) 2012-2016 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 "film_editor.h"
27 #include "dcp_panel.h"
28 #include "content_panel.h"
30 #include "lib/job_manager.h"
31 #include "lib/content.h"
32 #include "lib/dcp_content.h"
34 #include <wx/notebook.h>
40 using std::shared_ptr;
42 using boost::optional;
43 #if BOOST_VERSION >= 106100
44 using namespace boost::placeholders;
47 FilmEditor::FilmEditor (wxWindow* parent, weak_ptr<FilmViewer> viewer)
50 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
52 _main_notebook = new wxNotebook (this, wxID_ANY);
53 s->Add (_main_notebook, 1);
55 _content_panel = new ContentPanel (_main_notebook, _film, viewer);
56 _main_notebook->AddPage (_content_panel->window(), _("Content"), true);
57 _dcp_panel = new DCPPanel (_main_notebook, _film, viewer);
58 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
60 JobManager::instance()->ActiveJobsChanged.connect (
61 bind (&FilmEditor::active_jobs_changed, this, _2)
64 set_film (shared_ptr<Film> ());
69 /** Called when the metadata stored in the Film object has changed;
70 * so that we can update the GUI.
71 * @param p Property of the Film that has changed.
74 FilmEditor::film_change (ChangeType type, Film::Property p)
76 if (type != ChangeType::DONE) {
86 _content_panel->film_changed (p);
87 _dcp_panel->film_changed (p);
89 if (p == Film::Property::CONTENT && !_film->content().empty()) {
90 /* Select newly-added content */
91 _content_panel->set_selection (_film->content().back ());
96 FilmEditor::film_content_change (ChangeType type, int property)
98 if (type != ChangeType::DONE) {
105 /* We call this method ourselves (as well as using it as a signal handler)
111 _content_panel->film_content_changed (property);
112 _dcp_panel->film_content_changed (property);
115 /** Sets the Film that we are editing */
117 FilmEditor::set_film (shared_ptr<Film> film)
119 set_general_sensitivity (film != 0);
127 _content_panel->set_film (_film);
128 _dcp_panel->set_film (_film);
135 _film->Change.connect (bind (&FilmEditor::film_change, this, _1, _2));
136 _film->ContentChange.connect (bind (&FilmEditor::film_content_change, this, _1, _3));
138 if (_film->directory()) {
139 FileChanged (_film->directory().get());
144 if (!_film->content().empty()) {
145 _content_panel->set_selection (_film->content().front ());
150 FilmEditor::set_general_sensitivity (bool s)
152 _content_panel->set_general_sensitivity (s);
153 _dcp_panel->set_general_sensitivity (s);
157 FilmEditor::active_jobs_changed (optional<string> j)
159 set_general_sensitivity (!j);
164 FilmEditor::first_shown ()
166 _content_panel->first_shown ();