2 Copyright (C) 2012-2021 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/>.
22 /** @file src/wx/film_editor.cc
23 * @brief FilmEditor class.
28 #include "film_editor.h"
29 #include "dcp_panel.h"
30 #include "content_panel.h"
32 #include "lib/job_manager.h"
33 #include "lib/content.h"
34 #include "lib/dcp_content.h"
36 #include <wx/notebook.h>
43 using std::shared_ptr;
45 using boost::optional;
46 #if BOOST_VERSION >= 106100
47 using namespace boost::placeholders;
51 FilmEditor::FilmEditor (wxWindow* parent, weak_ptr<FilmViewer> viewer)
54 auto s = new wxBoxSizer (wxVERTICAL);
56 _main_notebook = new wxNotebook (this, wxID_ANY);
57 s->Add (_main_notebook, 1);
59 _content_panel = new ContentPanel (_main_notebook, _film, viewer);
60 _main_notebook->AddPage (_content_panel->window(), _("Content"), true);
61 _dcp_panel = new DCPPanel (_main_notebook, _film, viewer);
62 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
64 JobManager::instance()->ActiveJobsChanged.connect (
65 bind(&FilmEditor::active_jobs_changed, this, _2)
68 set_film (shared_ptr<Film> ());
73 /** Called when the metadata stored in the Film object has changed;
74 * so that we can update the GUI.
75 * @param p Property of the Film that has changed.
78 FilmEditor::film_change (ChangeType type, Film::Property p)
80 if (type != ChangeType::DONE) {
90 _content_panel->film_changed (p);
91 _dcp_panel->film_changed (p);
93 if (p == Film::Property::CONTENT && !_film->content().empty()) {
94 /* Select newly-added content */
95 _content_panel->set_selection (_film->content().back ());
101 FilmEditor::film_content_change (ChangeType type, int property)
103 if (type != ChangeType::DONE) {
110 /* We call this method ourselves (as well as using it as a signal handler)
116 _content_panel->film_content_changed (property);
117 _dcp_panel->film_content_changed (property);
121 /** Sets the Film that we are editing */
123 FilmEditor::set_film (shared_ptr<Film> film)
125 set_general_sensitivity (film != nullptr);
133 _content_panel->set_film (_film);
134 _dcp_panel->set_film (_film);
141 _film->Change.connect (bind(&FilmEditor::film_change, this, _1, _2));
142 _film->ContentChange.connect (bind(&FilmEditor::film_content_change, this, _1, _3));
144 if (_film->directory()) {
145 FileChanged (_film->directory().get());
150 if (!_film->content().empty()) {
151 _content_panel->set_selection (_film->content().front());
157 FilmEditor::set_general_sensitivity (bool s)
159 _content_panel->set_general_sensitivity (s);
160 _dcp_panel->set_general_sensitivity (s);
165 FilmEditor::active_jobs_changed (optional<string> j)
167 set_general_sensitivity (!j);
172 FilmEditor::first_shown ()
174 _content_panel->first_shown ();