2 Copyright (C) 2012-2015 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/wx/film_editor.cc
21 * @brief FilmEditor class.
25 #include "lib/job_manager.h"
26 #include "lib/content.h"
27 #include "lib/dcp_content.h"
29 #include "film_editor.h"
30 #include "dcp_panel.h"
31 #include "content_panel.h"
33 #include <wx/notebook.h>
38 using boost::shared_ptr;
39 using boost::optional;
41 /** @param f Film to edit */
42 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
45 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
47 _main_notebook = new wxNotebook (this, wxID_ANY);
48 s->Add (_main_notebook, 1);
50 _content_panel = new ContentPanel (_main_notebook, _film, viewer);
51 _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
52 _dcp_panel = new DCPPanel (_main_notebook, _film);
53 _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
55 JobManager::instance()->ActiveJobsChanged.connect (
56 bind (&FilmEditor::active_jobs_changed, this, _2)
59 set_film (shared_ptr<Film> ());
64 /** Called when the metadata stored in the Film object has changed;
65 * so that we can update the GUI.
66 * @param p Property of the Film that has changed.
69 FilmEditor::film_changed (Film::Property p)
77 _content_panel->film_changed (p);
78 _dcp_panel->film_changed (p);
80 if (p == Film::CONTENT && !_film->content().empty ()) {
81 /* Select newly-added content */
82 _content_panel->set_selection (_film->content().back ());
87 FilmEditor::film_content_changed (int property)
92 /* We call this method ourselves (as well as using it as a signal handler)
98 _content_panel->film_content_changed (property);
99 _dcp_panel->film_content_changed (property);
102 /** Sets the Film that we are editing */
104 FilmEditor::set_film (shared_ptr<Film> film)
106 set_general_sensitivity (film != 0);
114 _content_panel->set_film (_film);
115 _dcp_panel->set_film (_film);
118 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
119 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
123 FileChanged (_film->directory ());
128 if (!_film->content().empty ()) {
129 _content_panel->set_selection (_film->content().front ());
134 FilmEditor::set_general_sensitivity (bool s)
136 _content_panel->set_general_sensitivity (s);
137 _dcp_panel->set_general_sensitivity (s);
141 FilmEditor::active_jobs_changed (optional<string> j)
143 set_general_sensitivity (!j || *j == "analyse_audio");