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 "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>
35 #include <boost/foreach.hpp>
41 using boost::shared_ptr;
42 using boost::optional;
44 /** @param f Film to edit */
45 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
48 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
50 _main_notebook = new wxNotebook (this, wxID_ANY);
51 s->Add (_main_notebook, 1);
53 _content_panel = new ContentPanel (_main_notebook, _film, viewer);
54 _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
55 _dcp_panel = new DCPPanel (_main_notebook, _film);
56 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
58 JobManager::instance()->ActiveJobsChanged.connect (
59 bind (&FilmEditor::active_jobs_changed, this, _2)
62 set_film (shared_ptr<Film> ());
67 /** Called when the metadata stored in the Film object has changed;
68 * so that we can update the GUI.
69 * @param p Property of the Film that has changed.
72 FilmEditor::film_changed (Film::Property p)
80 list<string> notes = _film->fix_conflicting_settings ();
81 BOOST_FOREACH (string i, notes) {
82 message_dialog (this, std_to_wx (i));
85 _content_panel->film_changed (p);
86 _dcp_panel->film_changed (p);
88 if (p == Film::CONTENT && !_film->content().empty ()) {
89 /* Select newly-added content */
90 _content_panel->set_selection (_film->content().back ());
95 FilmEditor::film_content_changed (int property)
100 /* We call this method ourselves (as well as using it as a signal handler)
106 _content_panel->film_content_changed (property);
107 _dcp_panel->film_content_changed (property);
110 /** Sets the Film that we are editing */
112 FilmEditor::set_film (shared_ptr<Film> film)
114 set_general_sensitivity (film != 0);
122 _content_panel->set_film (_film);
123 _dcp_panel->set_film (_film);
126 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
127 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
130 if (_film && _film->directory()) {
131 FileChanged (_film->directory().get());
136 if (!_film->content().empty ()) {
137 _content_panel->set_selection (_film->content().front ());
142 FilmEditor::set_general_sensitivity (bool s)
144 _content_panel->set_general_sensitivity (s);
145 _dcp_panel->set_general_sensitivity (s);
149 FilmEditor::active_jobs_changed (optional<string> j)
151 set_general_sensitivity (!j || *j == "analyse_audio");