summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-11 15:06:52 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-13 12:39:52 +0100
commite8c5f14cb6736bdfa3610b2559c6c331c1c56984 (patch)
treecb1a18b733411ce2b5a80aa0396d4aafdb11ff92 /src
parent66527e65e21c2981d2b94f83ad9decfa99f46aad (diff)
Separate code for the content panel out into a separate class.
Diffstat (limited to 'src')
-rw-r--r--src/tools/dcpomatic.cc6
-rw-r--r--src/wx/audio_panel.cc20
-rw-r--r--src/wx/audio_panel.h6
-rw-r--r--src/wx/content_menu.h4
-rw-r--r--src/wx/content_panel.cc450
-rw-r--r--src/wx/content_panel.h101
-rw-r--r--src/wx/content_sub_panel.cc (renamed from src/wx/film_editor_panel.cc)12
-rw-r--r--src/wx/content_sub_panel.h (renamed from src/wx/film_editor_panel.h)14
-rw-r--r--src/wx/content_widget.h1
-rw-r--r--src/wx/film_editor.cc392
-rw-r--r--src/wx/film_editor.h48
-rw-r--r--src/wx/subtitle_panel.cc24
-rw-r--r--src/wx/subtitle_panel.h6
-rw-r--r--src/wx/timeline.cc6
-rw-r--r--src/wx/timeline.h6
-rw-r--r--src/wx/timeline_dialog.cc6
-rw-r--r--src/wx/timeline_dialog.h2
-rw-r--r--src/wx/timing_panel.cc32
-rw-r--r--src/wx/timing_panel.h6
-rw-r--r--src/wx/video_panel.cc18
-rw-r--r--src/wx/video_panel.h6
-rw-r--r--src/wx/wscript3
22 files changed, 659 insertions, 510 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index fb63ae997..95d0d22a5 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -489,7 +489,7 @@ private:
void content_scale_to_fit_width ()
{
- VideoContentList vc = _film_editor->selected_video_content ();
+ VideoContentList vc = _film_editor->content_panel()->selected_video ();
for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
(*i)->scale_and_crop_to_fit_width ();
}
@@ -497,7 +497,7 @@ private:
void content_scale_to_fit_height ()
{
- VideoContentList vc = _film_editor->selected_video_content ();
+ VideoContentList vc = _film_editor->content_panel()->selected_video ();
for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
(*i)->scale_and_crop_to_fit_height ();
}
@@ -603,7 +603,7 @@ private:
}
bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
bool const have_cpl = film && !film->cpls().empty ();
- bool const have_selected_video_content = !_film_editor->selected_video_content().empty();
+ bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
index 179d7db71..10b5a5f76 100644
--- a/src/wx/audio_panel.cc
+++ b/src/wx/audio_panel.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,8 +37,8 @@ using boost::dynamic_pointer_cast;
using boost::lexical_cast;
using boost::shared_ptr;
-AudioPanel::AudioPanel (FilmEditor* e)
- : FilmEditorPanel (e, _("Audio"))
+AudioPanel::AudioPanel (ContentPanel* p)
+ : ContentSubPanel (p, _("Audio"))
, _audio_dialog (0)
{
wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
@@ -106,7 +106,7 @@ AudioPanel::film_changed (Film::Property property)
{
switch (property) {
case Film::AUDIO_CHANNELS:
- _mapping->set_channels (_editor->film()->audio_channels ());
+ _mapping->set_channels (_parent->film()->audio_channels ());
_sizer->Layout ();
break;
default:
@@ -117,7 +117,7 @@ AudioPanel::film_changed (Film::Property property)
void
AudioPanel::film_content_changed (int property)
{
- AudioContentList ac = _editor->selected_audio_content ();
+ AudioContentList ac = _parent->selected_audio ();
shared_ptr<AudioContent> acs;
shared_ptr<FFmpegContent> fcs;
if (ac.size() == 1) {
@@ -182,7 +182,7 @@ AudioPanel::show_clicked ()
_audio_dialog = 0;
}
- AudioContentList ac = _editor->selected_audio_content ();
+ AudioContentList ac = _parent->selected_audio ();
if (ac.size() != 1) {
return;
}
@@ -195,7 +195,7 @@ AudioPanel::show_clicked ()
void
AudioPanel::stream_changed ()
{
- FFmpegContentList fc = _editor->selected_ffmpeg_content ();
+ FFmpegContentList fc = _parent->selected_ffmpeg ();
if (fc.size() != 1) {
return;
}
@@ -223,7 +223,7 @@ AudioPanel::stream_changed ()
void
AudioPanel::setup_stream_description ()
{
- FFmpegContentList fc = _editor->selected_ffmpeg_content ();
+ FFmpegContentList fc = _parent->selected_ffmpeg ();
if (fc.size() != 1) {
_description->SetLabel ("");
return;
@@ -248,7 +248,7 @@ AudioPanel::setup_stream_description ()
void
AudioPanel::mapping_changed (AudioMapping m)
{
- AudioContentList c = _editor->selected_audio_content ();
+ AudioContentList c = _parent->selected_audio ();
if (c.size() == 1) {
c.front()->set_audio_mapping (m);
}
@@ -257,7 +257,7 @@ AudioPanel::mapping_changed (AudioMapping m)
void
AudioPanel::content_selection_changed ()
{
- AudioContentList sel = _editor->selected_audio_content ();
+ AudioContentList sel = _parent->selected_audio ();
if (_audio_dialog && sel.size() == 1) {
_audio_dialog->set_content (sel.front ());
diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h
index 2ba5a9ffc..02faf6cd4 100644
--- a/src/wx/audio_panel.h
+++ b/src/wx/audio_panel.h
@@ -18,7 +18,7 @@
*/
#include "lib/audio_mapping.h"
-#include "film_editor_panel.h"
+#include "content_sub_panel.h"
#include "content_widget.h"
class wxSpinCtrlDouble;
@@ -28,10 +28,10 @@ class wxStaticText;
class AudioMappingView;
class AudioDialog;
-class AudioPanel : public FilmEditorPanel
+class AudioPanel : public ContentSubPanel
{
public:
- AudioPanel (FilmEditor *);
+ AudioPanel (ContentPanel *);
void film_changed (Film::Property);
void film_content_changed (int);
diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h
index a9f9093c6..f2ad3aa75 100644
--- a/src/wx/content_menu.h
+++ b/src/wx/content_menu.h
@@ -30,9 +30,9 @@ class Film;
class ContentMenu
{
public:
- ContentMenu (wxWindow *);
+ ContentMenu (wxWindow* p);
~ContentMenu ();
-
+
void popup (boost::weak_ptr<Film>, ContentList, wxPoint);
private:
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
new file mode 100644
index 000000000..13ae2d88a
--- /dev/null
+++ b/src/wx/content_panel.cc
@@ -0,0 +1,450 @@
+/*
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <wx/wx.h>
+#include <wx/notebook.h>
+#include <wx/listctrl.h>
+#include "lib/audio_content.h"
+#include "lib/subtitle_content.h"
+#include "lib/video_content.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/content_factory.h"
+#include "lib/image_content.h"
+#include "lib/dcp_content.h"
+#include "lib/playlist.h"
+#include "content_panel.h"
+#include "wx_util.h"
+#include "video_panel.h"
+#include "audio_panel.h"
+#include "subtitle_panel.h"
+#include "timing_panel.h"
+#include "timeline_dialog.h"
+
+using std::list;
+using std::string;
+using boost::shared_ptr;
+using boost::weak_ptr;
+using boost::dynamic_pointer_cast;
+
+ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f)
+ : _timeline_dialog (0)
+ , _film (f)
+ , _generally_sensitive (true)
+{
+ _panel = new wxPanel (n);
+ _sizer = new wxBoxSizer (wxVERTICAL);
+ _panel->SetSizer (_sizer);
+
+ _menu = new ContentMenu (_panel);
+
+ {
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+
+ _content = new wxListCtrl (_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
+ s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
+
+ _content->InsertColumn (0, wxT(""));
+ _content->SetColumnWidth (0, 512);
+
+ wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
+ _add_file = new wxButton (_panel, wxID_ANY, _("Add file(s)..."));
+ b->Add (_add_file, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ _add_folder = new wxButton (_panel, wxID_ANY, _("Add folder..."));
+ b->Add (_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ _remove = new wxButton (_panel, wxID_ANY, _("Remove"));
+ b->Add (_remove, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ _earlier = new wxButton (_panel, wxID_ANY, _("Up"));
+ b->Add (_earlier, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ _later = new wxButton (_panel, wxID_ANY, _("Down"));
+ b->Add (_later, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+ _timeline = new wxButton (_panel, wxID_ANY, _("Timeline..."));
+ b->Add (_timeline, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+
+ s->Add (b, 0, wxALL, 4);
+
+ _sizer->Add (s, 0, wxEXPAND | wxALL, 6);
+ }
+
+ _sequence_video = new wxCheckBox (_panel, wxID_ANY, _("Keep video in sequence"));
+ _sizer->Add (_sequence_video);
+
+ _notebook = new wxNotebook (_panel, wxID_ANY);
+ _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
+
+ _video_panel = new VideoPanel (this);
+ _panels.push_back (_video_panel);
+ _audio_panel = new AudioPanel (this);
+ _panels.push_back (_audio_panel);
+ _subtitle_panel = new SubtitlePanel (this);
+ _panels.push_back (_subtitle_panel);
+ _timing_panel = new TimingPanel (this);
+ _panels.push_back (_timing_panel);
+
+ _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::selection_changed, this));
+ _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&ContentPanel::selection_changed, this));
+ _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&ContentPanel::right_click, this, _1));
+ _add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_file_clicked, this));
+ _add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_folder_clicked, this));
+ _remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::remove_clicked, this));
+ _earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::earlier_clicked, this));
+ _later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::later_clicked, this));
+ _timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::timeline_clicked, this));
+ _sequence_video->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentPanel::sequence_video_changed, this));
+}
+
+ContentList
+ContentPanel::selected ()
+{
+ ContentList sel;
+ long int s = -1;
+ while (true) {
+ s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s == -1) {
+ break;
+ }
+
+ if (s < int (_film->content().size ())) {
+ sel.push_back (_film->content()[s]);
+ }
+ }
+
+ return sel;
+}
+
+VideoContentList
+ContentPanel::selected_video ()
+{
+ ContentList c = selected ();
+ VideoContentList vc;
+
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
+ if (t) {
+ vc.push_back (t);
+ }
+ }
+
+ return vc;
+}
+
+AudioContentList
+ContentPanel::selected_audio ()
+{
+ ContentList c = selected ();
+ AudioContentList ac;
+
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
+ if (t) {
+ ac.push_back (t);
+ }
+ }
+
+ return ac;
+}
+
+SubtitleContentList
+ContentPanel::selected_subtitle ()
+{
+ ContentList c = selected ();
+ SubtitleContentList sc;
+
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
+ if (t) {
+ sc.push_back (t);
+ }
+ }
+
+ return sc;
+}
+
+FFmpegContentList
+ContentPanel::selected_ffmpeg ()
+{
+ ContentList c = selected ();
+ FFmpegContentList sc;
+
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (*i);
+ if (t) {
+ sc.push_back (t);
+ }
+ }
+
+ return sc;
+}
+
+void
+ContentPanel::sequence_video_changed ()
+{
+ if (!_film) {
+ return;
+ }
+
+ _film->set_sequence_video (_sequence_video->GetValue ());
+}
+
+void
+ContentPanel::film_changed (Film::Property p)
+{
+ switch (p) {
+ case Film::CONTENT:
+ setup ();
+ break;
+ case Film::SEQUENCE_VIDEO:
+ checked_set (_sequence_video, _film->sequence_video ());
+ break;
+ default:
+ break;
+ }
+
+ for (list<ContentSubPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+ (*i)->film_changed (p);
+ }
+}
+
+void
+ContentPanel::selection_changed ()
+{
+ setup_sensitivity ();
+
+ for (list<ContentSubPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+ (*i)->content_selection_changed ();
+ }
+}
+
+void
+ContentPanel::add_file_clicked ()
+{
+ /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
+ non-Latin filenames or paths.
+ */
+ wxFileDialog* d = new wxFileDialog (_panel, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR);
+ int const r = d->ShowModal ();
+
+ if (r != wxID_OK) {
+ d->Destroy ();
+ return;
+ }
+
+ wxArrayString paths;
+ d->GetPaths (paths);
+
+ /* XXX: check for lots of files here and do something */
+
+ for (unsigned int i = 0; i < paths.GetCount(); ++i) {
+ _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
+ }
+
+ d->Destroy ();
+}
+
+void
+ContentPanel::add_folder_clicked ()
+{
+ wxDirDialog* d = new wxDirDialog (_panel, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
+ int const r = d->ShowModal ();
+ d->Destroy ();
+
+ if (r != wxID_OK) {
+ return;
+ }
+
+ shared_ptr<Content> content;
+
+ try {
+ content.reset (new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+ } catch (...) {
+ try {
+ content.reset (new DCPContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
+ } catch (...) {
+ error_dialog (_panel, _("Could not find any images nor a DCP in that folder"));
+ return;
+ }
+ }
+
+ if (content) {
+ _film->examine_and_add_content (content);
+ }
+}
+
+void
+ContentPanel::remove_clicked ()
+{
+ ContentList c = selected ();
+ if (c.size() == 1) {
+ _film->remove_content (c.front ());
+ }
+
+ selection_changed ();
+}
+
+void
+ContentPanel::timeline_clicked ()
+{
+ if (_timeline_dialog) {
+ _timeline_dialog->Destroy ();
+ _timeline_dialog = 0;
+ }
+
+ _timeline_dialog = new TimelineDialog (this, _film);
+ _timeline_dialog->Show ();
+}
+
+void
+ContentPanel::right_click (wxListEvent& ev)
+{
+ _menu->popup (_film, selected (), ev.GetPoint ());
+}
+
+/** Set up broad sensitivity based on the type of content that is selected */
+void
+ContentPanel::setup_sensitivity ()
+{
+ _add_file->Enable (_generally_sensitive);
+ _add_folder->Enable (_generally_sensitive);
+
+ ContentList selection = selected ();
+ VideoContentList video_selection = selected_video ();
+ AudioContentList audio_selection = selected_audio ();
+
+ _remove->Enable (selection.size() == 1 && _generally_sensitive);
+ _earlier->Enable (selection.size() == 1 && _generally_sensitive);
+ _later->Enable (selection.size() == 1 && _generally_sensitive);
+ _timeline->Enable (!_film->content().empty() && _generally_sensitive);
+
+ _video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
+ _audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
+ _subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<SubtitleContent> (selection.front()) && _generally_sensitive);
+ _timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
+}
+
+void
+ContentPanel::set_film (shared_ptr<Film> f)
+{
+ _film = f;
+ selection_changed ();
+}
+
+void
+ContentPanel::set_general_sensitivity (bool s)
+{
+ _generally_sensitive = s;
+
+ _content->Enable (s);
+ _add_file->Enable (s);
+ _add_folder->Enable (s);
+ _remove->Enable (s);
+ _earlier->Enable (s);
+ _later->Enable (s);
+ _timeline->Enable (s);
+ _sequence_video->Enable (s);
+
+ /* Set the panels in the content notebook */
+ for (list<ContentSubPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+ (*i)->Enable (s);
+ }
+}
+
+void
+ContentPanel::earlier_clicked ()
+{
+ ContentList sel = selected ();
+ if (sel.size() == 1) {
+ _film->move_content_earlier (sel.front ());
+ selection_changed ();
+ }
+}
+
+void
+ContentPanel::later_clicked ()
+{
+ ContentList sel = selected ();
+ if (sel.size() == 1) {
+ _film->move_content_later (sel.front ());
+ selection_changed ();
+ }
+}
+
+void
+ContentPanel::set_selection (weak_ptr<Content> wc)
+{
+ ContentList content = _film->content ();
+ for (size_t i = 0; i < content.size(); ++i) {
+ if (content[i] == wc.lock ()) {
+ _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ } else {
+ _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
+ }
+ }
+}
+
+void
+ContentPanel::film_content_changed (int property)
+{
+ if (property == ContentProperty::PATH || property == ContentProperty::POSITION) {
+ setup ();
+ }
+
+ for (list<ContentSubPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
+ (*i)->film_content_changed (property);
+ }
+}
+
+void
+ContentPanel::setup ()
+{
+ string selected_summary;
+ int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s != -1) {
+ selected_summary = wx_to_std (_content->GetItemText (s));
+ }
+
+ _content->DeleteAllItems ();
+
+ ContentList content = _film->content ();
+ sort (content.begin(), content.end(), ContentSorter ());
+
+ for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
+ int const t = _content->GetItemCount ();
+ bool const valid = (*i)->paths_valid ();
+
+ string s = (*i)->summary ();
+ if (!valid) {
+ s = _("MISSING: ") + s;
+ }
+
+ _content->InsertItem (t, std_to_wx (s));
+
+ if ((*i)->summary() == selected_summary) {
+ _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+
+ if (!valid) {
+ _content->SetItemTextColour (t, *wxRED);
+ }
+ }
+
+ if (selected_summary.empty () && !content.empty ()) {
+ /* Select the item of content if none was selected before */
+ _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ }
+}
+
diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h
new file mode 100644
index 000000000..5701696e5
--- /dev/null
+++ b/src/wx/content_panel.h
@@ -0,0 +1,101 @@
+/*
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <list>
+#include <boost/shared_ptr.hpp>
+#include "lib/types.h"
+#include "lib/film.h"
+#include "content_menu.h"
+
+class wxNotebook;
+class wxPanel;
+class wxSizer;
+class wxListCtrl;
+class wxListEvent;
+class TimelineDialog;
+class FilmEditor;
+class ContentSubPanel;
+class Film;
+
+class ContentPanel
+{
+public:
+ ContentPanel (wxNotebook *, boost::shared_ptr<Film>);
+
+ boost::shared_ptr<Film> film () const {
+ return _film;
+ }
+
+ void set_film (boost::shared_ptr<Film> f);
+ void set_general_sensitivity (bool s);
+ void set_selection (boost::weak_ptr<Content>);
+
+ void film_changed (Film::Property p);
+ void film_content_changed (int p);
+
+ wxPanel* panel () const {
+ return _panel;
+ }
+
+ wxNotebook* notebook () const {
+ return _notebook;
+ }
+
+ ContentList selected ();
+ VideoContentList selected_video ();
+ AudioContentList selected_audio ();
+ SubtitleContentList selected_subtitle ();
+ FFmpegContentList selected_ffmpeg ();
+
+private:
+ void sequence_video_changed ();
+ void selection_changed ();
+ void add_file_clicked ();
+ void add_folder_clicked ();
+ void remove_clicked ();
+ void earlier_clicked ();
+ void later_clicked ();
+ void right_click (wxListEvent &);
+ void timeline_clicked ();
+
+ void setup ();
+ void setup_sensitivity ();
+
+ wxPanel* _panel;
+ wxSizer* _sizer;
+ wxNotebook* _notebook;
+ wxListCtrl* _content;
+ wxButton* _add_file;
+ wxButton* _add_folder;
+ wxButton* _remove;
+ wxButton* _earlier;
+ wxButton* _later;
+ wxButton* _timeline;
+ wxCheckBox* _sequence_video;
+ ContentSubPanel* _video_panel;
+ ContentSubPanel* _audio_panel;
+ ContentSubPanel* _subtitle_panel;
+ ContentSubPanel* _timing_panel;
+ std::list<ContentSubPanel *> _panels;
+ ContentMenu* _menu;
+ TimelineDialog* _timeline_dialog;
+
+ boost::shared_ptr<Film> _film;
+ bool _generally_sensitive;
+};
diff --git a/src/wx/film_editor_panel.cc b/src/wx/content_sub_panel.cc
index a637df1fe..f0962cc24 100644
--- a/src/wx/film_editor_panel.cc
+++ b/src/wx/content_sub_panel.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,17 +18,17 @@
*/
#include <wx/notebook.h>
-#include "film_editor_panel.h"
+#include "content_sub_panel.h"
#include "film_editor.h"
using boost::shared_ptr;
-FilmEditorPanel::FilmEditorPanel (FilmEditor* e, wxString name)
- : wxPanel (e->content_notebook (), wxID_ANY)
- , _editor (e)
+ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name)
+ : wxPanel (p->notebook(), wxID_ANY)
+ , _parent (p)
, _sizer (new wxBoxSizer (wxVERTICAL))
{
- e->content_notebook()->AddPage (this, name, false);
+ p->notebook()->AddPage (this, name, false);
SetSizer (_sizer);
}
diff --git a/src/wx/film_editor_panel.h b/src/wx/content_sub_panel.h
index e0514ba99..5a1b739ef 100644
--- a/src/wx/film_editor_panel.h
+++ b/src/wx/content_sub_panel.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,20 +17,20 @@
*/
-#ifndef DCPOMATIC_FILM_EDITOR_PANEL_H
-#define DCPOMATIC_FILM_EDITOR_PANEL_H
+#ifndef DCPOMATIC_CONTENT_SUB_PANEL_H
+#define DCPOMATIC_CONTENT_SUB_PANEL_H
#include <boost/shared_ptr.hpp>
#include <wx/wx.h>
#include "lib/film.h"
-class FilmEditor;
+class ContentPanel;
class Content;
-class FilmEditorPanel : public wxPanel
+class ContentSubPanel : public wxPanel
{
public:
- FilmEditorPanel (FilmEditor *, wxString);
+ ContentSubPanel (ContentPanel *, wxString);
virtual void film_changed (Film::Property) {}
/** Called when a given property of one of the selected Contents changes */
@@ -39,7 +39,7 @@ public:
virtual void content_selection_changed () = 0;
protected:
- FilmEditor* _editor;
+ ContentPanel* _parent;
wxSizer* _sizer;
};
diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h
index 9e1338b7c..bbe160399 100644
--- a/src/wx/content_widget.h
+++ b/src/wx/content_widget.h
@@ -27,6 +27,7 @@
#include <vector>
#include <wx/wx.h>
#include <wx/gbsizer.h>
+#include <wx/spinctrl.h>
#include <boost/function.hpp>
#include "wx_util.h"
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index c53943e20..151130f27 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -73,17 +73,15 @@ using boost::lexical_cast;
/** @param f Film to edit */
FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
: wxPanel (parent)
- , _menu (this)
, _generally_sensitive (true)
- , _timeline_dialog (0)
{
wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
_main_notebook = new wxNotebook (this, wxID_ANY);
s->Add (_main_notebook, 1);
- make_content_panel ();
- _main_notebook->AddPage (_content_panel, _("Content"), true);
+ _content_panel = new ContentPanel (_main_notebook, _film);
+ _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
make_dcp_panel ();
_main_notebook->AddPage (_dcp_panel, _("DCP"), false);
@@ -240,15 +238,6 @@ FilmEditor::connect_to_widgets ()
_use_isdcf_name->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::use_isdcf_name_toggled, this));
_edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::edit_isdcf_button_clicked, this));
_container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::container_changed, this));
- _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
- _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&FilmEditor::content_selection_changed, this));
- _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&FilmEditor::content_right_click, this, _1));
- _content_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_file_clicked, this));
- _content_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_add_folder_clicked, this));
- _content_remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_remove_clicked, this));
- _content_earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_earlier_clicked, this));
- _content_later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_later_clicked, this));
- _content_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FilmEditor::content_timeline_clicked, this));
_scaler->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::scaler_changed, this));
_dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::dcp_content_type_changed, this));
_frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::frame_rate_choice_changed, this));
@@ -260,62 +249,10 @@ FilmEditor::connect_to_widgets ()
_audio_channels->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::audio_channels_changed, this));
_j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
_resolution->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::resolution_changed, this));
- _sequence_video->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::sequence_video_changed, this));
_three_d->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilmEditor::three_d_changed, this));
_standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&FilmEditor::standard_changed, this));
}
-void
-FilmEditor::make_content_panel ()
-{
- _content_panel = new wxPanel (_main_notebook);
- _content_sizer = new wxBoxSizer (wxVERTICAL);
- _content_panel->SetSizer (_content_sizer);
-
- {
- wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-
- _content = new wxListCtrl (_content_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
- s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
-
- _content->InsertColumn (0, wxT(""));
- _content->SetColumnWidth (0, 512);
-
- wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
- _content_add_file = new wxButton (_content_panel, wxID_ANY, _("Add file(s)..."));
- b->Add (_content_add_file, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
- _content_add_folder = new wxButton (_content_panel, wxID_ANY, _("Add folder..."));
- b->Add (_content_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
- _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
- b->Add (_content_remove, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
- _content_earlier = new wxButton (_content_panel, wxID_ANY, _("Up"));
- b->Add (_content_earlier, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
- _content_later = new wxButton (_content_panel, wxID_ANY, _("Down"));
- b->Add (_content_later, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
- _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
- b->Add (_content_timeline, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
-
- s->Add (b, 0, wxALL, 4);
-
- _content_sizer->Add (s, 0, wxEXPAND | wxALL, 6);
- }
-
- _sequence_video = new wxCheckBox (_content_panel, wxID_ANY, _("Keep video in sequence"));
- _content_sizer->Add (_sequence_video);
-
- _content_notebook = new wxNotebook (_content_panel, wxID_ANY);
- _content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
-
- _video_panel = new VideoPanel (this);
- _panels.push_back (_video_panel);
- _audio_panel = new AudioPanel (this);
- _panels.push_back (_audio_panel);
- _subtitle_panel = new SubtitlePanel (this);
- _panels.push_back (_subtitle_panel);
- _timing_panel = new TimingPanel (this);
- _panels.push_back (_timing_panel);
-}
-
/** Called when the name widget has been changed */
void
FilmEditor::name_changed ()
@@ -438,16 +375,11 @@ FilmEditor::film_changed (Film::Property p)
stringstream s;
- for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
- (*i)->film_changed (p);
- }
-
+ _content_panel->film_changed (p);
+
switch (p) {
case Film::NONE:
break;
- case Film::CONTENT:
- setup_content ();
- break;
case Film::CONTAINER:
setup_container ();
break;
@@ -515,9 +447,6 @@ FilmEditor::film_changed (Film::Property p)
checked_set (_audio_channels, _film->audio_channels ());
setup_dcp_name ();
break;
- case Film::SEQUENCE_VIDEO:
- checked_set (_sequence_video, _film->sequence_video ());
- break;
case Film::THREE_D:
checked_set (_three_d, _film->three_d ());
setup_dcp_name ();
@@ -525,6 +454,8 @@ FilmEditor::film_changed (Film::Property p)
case Film::INTEROP:
checked_set (_standard, _film->interop() ? 1 : 0);
break;
+ default:
+ break;
}
}
@@ -540,16 +471,10 @@ FilmEditor::film_content_changed (int property)
return;
}
- for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
- (*i)->film_content_changed (property);
- }
+ _content_panel->film_content_changed (property);
if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::USE_SUBTITLES) {
setup_dcp_name ();
- } else if (property == ContentProperty::PATH) {
- setup_content ();
- } else if (property == ContentProperty::POSITION) {
- setup_content ();
}
}
@@ -615,6 +540,8 @@ FilmEditor::set_film (shared_ptr<Film> f)
_film = f;
+ _content_panel->set_film (_film);
+
if (_film) {
_film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
_film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
@@ -645,10 +572,8 @@ FilmEditor::set_film (shared_ptr<Film> f)
film_changed (Film::INTEROP);
if (!_film->content().empty ()) {
- set_selection (_film->content().front ());
+ _content_panel->set_selection (_film->content().front ());
}
-
- content_selection_changed ();
}
void
@@ -656,17 +581,12 @@ FilmEditor::set_general_sensitivity (bool s)
{
_generally_sensitive = s;
+ _content_panel->set_general_sensitivity (s);
+
/* Stuff in the Content / DCP tabs */
_name->Enable (s);
_use_isdcf_name->Enable (s);
_edit_isdcf_button->Enable (s);
- _content->Enable (s);
- _content_add_file->Enable (s);
- _content_add_folder->Enable (s);
- _content_remove->Enable (s);
- _content_earlier->Enable (s);
- _content_later->Enable (s);
- _content_timeline->Enable (s);
_dcp_content_type->Enable (s);
bool si = s;
@@ -683,16 +603,10 @@ FilmEditor::set_general_sensitivity (bool s)
_j2k_bandwidth->Enable (s);
_container->Enable (s);
_best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
- _sequence_video->Enable (s);
_resolution->Enable (s);
_scaler->Enable (s);
_three_d->Enable (s);
_standard->Enable (s);
-
- /* Set the panels in the content notebook */
- for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
- (*i)->Enable (s);
- }
}
/** Called when the scaler widget has been changed */
@@ -761,268 +675,6 @@ FilmEditor::best_frame_rate_clicked ()
}
void
-FilmEditor::setup_content ()
-{
- string selected_summary;
- int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (s != -1) {
- selected_summary = wx_to_std (_content->GetItemText (s));
- }
-
- _content->DeleteAllItems ();
-
- ContentList content = _film->content ();
- sort (content.begin(), content.end(), ContentSorter ());
-
- for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
- int const t = _content->GetItemCount ();
- bool const valid = (*i)->paths_valid ();
-
- string s = (*i)->summary ();
- if (!valid) {
- s = _("MISSING: ") + s;
- }
-
- _content->InsertItem (t, std_to_wx (s));
-
- if ((*i)->summary() == selected_summary) {
- _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- }
-
- if (!valid) {
- _content->SetItemTextColour (t, *wxRED);
- }
- }
-
- if (selected_summary.empty () && !content.empty ()) {
- /* Select the item of content if none was selected before */
- _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- }
-}
-
-void
-FilmEditor::content_add_file_clicked ()
-{
- /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
- non-Latin filenames or paths.
- */
- wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR);
- int const r = d->ShowModal ();
-
- if (r != wxID_OK) {
- d->Destroy ();
- return;
- }
-
- wxArrayString paths;
- d->GetPaths (paths);
-
- /* XXX: check for lots of files here and do something */
-
- for (unsigned int i = 0; i < paths.GetCount(); ++i) {
- _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
- }
-
- d->Destroy ();
-}
-
-void
-FilmEditor::content_add_folder_clicked ()
-{
- wxDirDialog* d = new wxDirDialog (this, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
- int const r = d->ShowModal ();
- d->Destroy ();
-
- if (r != wxID_OK) {
- return;
- }
-
- shared_ptr<Content> content;
-
- try {
- content.reset (new ImageContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
- } catch (...) {
- try {
- content.reset (new DCPContent (_film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
- } catch (...) {
- error_dialog (this, _("Could not find any images nor a DCP in that folder"));
- return;
- }
- }
-
- if (content) {
- _film->examine_and_add_content (content);
- }
-}
-
-void
-FilmEditor::content_remove_clicked ()
-{
- ContentList c = selected_content ();
- if (c.size() == 1) {
- _film->remove_content (c.front ());
- }
-
- content_selection_changed ();
-}
-
-void
-FilmEditor::content_selection_changed ()
-{
- setup_content_sensitivity ();
-
- for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
- (*i)->content_selection_changed ();
- }
-}
-
-/** Set up broad sensitivity based on the type of content that is selected */
-void
-FilmEditor::setup_content_sensitivity ()
-{
- _content_add_file->Enable (_generally_sensitive);
- _content_add_folder->Enable (_generally_sensitive);
-
- ContentList selection = selected_content ();
- VideoContentList video_selection = selected_video_content ();
- AudioContentList audio_selection = selected_audio_content ();
-
- _content_remove->Enable (selection.size() == 1 && _generally_sensitive);
- _content_earlier->Enable (selection.size() == 1 && _generally_sensitive);
- _content_later->Enable (selection.size() == 1 && _generally_sensitive);
- _content_timeline->Enable (!_film->content().empty() && _generally_sensitive);
-
- _video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
- _audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
- _subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<SubtitleContent> (selection.front()) && _generally_sensitive);
- _timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
-}
-
-ContentList
-FilmEditor::selected_content ()
-{
- ContentList sel;
- long int s = -1;
- while (true) {
- s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (s == -1) {
- break;
- }
-
- if (s < int (_film->content().size ())) {
- sel.push_back (_film->content()[s]);
- }
- }
-
- return sel;
-}
-
-VideoContentList
-FilmEditor::selected_video_content ()
-{
- ContentList c = selected_content ();
- VideoContentList vc;
-
- for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
- shared_ptr<VideoContent> t = dynamic_pointer_cast<VideoContent> (*i);
- if (t) {
- vc.push_back (t);
- }
- }
-
- return vc;
-}
-
-AudioContentList
-FilmEditor::selected_audio_content ()
-{
- ContentList c = selected_content ();
- AudioContentList ac;
-
- for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
- shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (*i);
- if (t) {
- ac.push_back (t);
- }
- }
-
- return ac;
-}
-
-SubtitleContentList
-FilmEditor::selected_subtitle_content ()
-{
- ContentList c = selected_content ();
- SubtitleContentList sc;
-
- for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
- shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (*i);
- if (t) {
- sc.push_back (t);
- }
- }
-
- return sc;
-}
-
-FFmpegContentList
-FilmEditor::selected_ffmpeg_content ()
-{
- ContentList c = selected_content ();
- FFmpegContentList sc;
-
- for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
- shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (*i);
- if (t) {
- sc.push_back (t);
- }
- }
-
- return sc;
-}
-
-void
-FilmEditor::content_timeline_clicked ()
-{
- if (_timeline_dialog) {
- _timeline_dialog->Destroy ();
- _timeline_dialog = 0;
- }
-
- _timeline_dialog = new TimelineDialog (this, _film);
- _timeline_dialog->Show ();
-}
-
-void
-FilmEditor::set_selection (weak_ptr<Content> wc)
-{
- ContentList content = _film->content ();
- for (size_t i = 0; i < content.size(); ++i) {
- if (content[i] == wc.lock ()) {
- _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
- } else {
- _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
- }
- }
-}
-
-void
-FilmEditor::sequence_video_changed ()
-{
- if (!_film) {
- return;
- }
-
- _film->set_sequence_video (_sequence_video->GetValue ());
-}
-
-void
-FilmEditor::content_right_click (wxListEvent& ev)
-{
- _menu.popup (_film, selected_content (), ev.GetPoint ());
-}
-
-void
FilmEditor::three_d_changed ()
{
if (!_film) {
@@ -1033,26 +685,6 @@ FilmEditor::three_d_changed ()
}
void
-FilmEditor::content_earlier_clicked ()
-{
- ContentList sel = selected_content ();
- if (sel.size() == 1) {
- _film->move_content_earlier (sel.front ());
- content_selection_changed ();
- }
-}
-
-void
-FilmEditor::content_later_clicked ()
-{
- ContentList sel = selected_content ();
- if (sel.size() == 1) {
- _film->move_content_later (sel.front ());
- content_selection_changed ();
- }
-}
-
-void
FilmEditor::config_changed ()
{
_j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index 6028a700d..aad2ad9f7 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -28,6 +28,7 @@
#include <boost/signals2.hpp>
#include "lib/film.h"
#include "content_menu.h"
+#include "content_panel.h"
class wxNotebook;
class wxListCtrl;
@@ -48,41 +49,27 @@ public:
FilmEditor (boost::shared_ptr<Film>, wxWindow *);
void set_film (boost::shared_ptr<Film>);
- void set_selection (boost::weak_ptr<Content>);
boost::signals2::signal<void (boost::filesystem::path)> FileChanged;
/* Stuff for panels */
-
- wxNotebook* content_notebook () const {
- return _content_notebook;
- }
+ ContentPanel* content_panel () const {
+ return _content_panel;
+ }
+
boost::shared_ptr<Film> film () const {
return _film;
}
- ContentList selected_content ();
- VideoContentList selected_video_content ();
- AudioContentList selected_audio_content ();
- SubtitleContentList selected_subtitle_content ();
- FFmpegContentList selected_ffmpeg_content ();
-
private:
void make_dcp_panel ();
- void make_content_panel ();
void connect_to_widgets ();
/* Handle changes to the view */
void name_changed ();
void use_isdcf_name_toggled ();
void edit_isdcf_button_clicked ();
- void content_selection_changed ();
- void content_add_file_clicked ();
- void content_add_folder_clicked ();
- void content_remove_clicked ();
- void content_earlier_clicked ();
- void content_later_clicked ();
void container_changed ();
void dcp_content_type_changed ();
void scaler_changed ();
@@ -93,8 +80,6 @@ private:
void content_timeline_clicked ();
void audio_channels_changed ();
void resolution_changed ();
- void sequence_video_changed ();
- void content_right_click (wxListEvent &);
void three_d_changed ();
void standard_changed ();
void signed_toggled ();
@@ -107,26 +92,16 @@ private:
void set_general_sensitivity (bool);
void setup_dcp_name ();
- void setup_content ();
void setup_container ();
- void setup_content_sensitivity ();
void setup_frame_rate_widget ();
void active_jobs_changed (bool);
void config_changed ();
- FilmEditorPanel* _video_panel;
- FilmEditorPanel* _audio_panel;
- FilmEditorPanel* _subtitle_panel;
- FilmEditorPanel* _timing_panel;
- std::list<FilmEditorPanel *> _panels;
-
wxNotebook* _main_notebook;
- wxNotebook* _content_notebook;
wxPanel* _dcp_panel;
wxSizer* _dcp_sizer;
- wxPanel* _content_panel;
- wxSizer* _content_sizer;
+ ContentPanel* _content_panel;
/** The film we are editing */
boost::shared_ptr<Film> _film;
@@ -134,14 +109,6 @@ private:
wxStaticText* _dcp_name;
wxCheckBox* _use_isdcf_name;
wxChoice* _container;
- wxListCtrl* _content;
- wxButton* _content_add_file;
- wxButton* _content_add_folder;
- wxButton* _content_remove;
- wxButton* _content_earlier;
- wxButton* _content_later;
- wxButton* _content_timeline;
- wxCheckBox* _sequence_video;
wxButton* _edit_isdcf_button;
wxChoice* _scaler;
wxSpinCtrl* _j2k_bandwidth;
@@ -158,10 +125,7 @@ private:
wxCheckBox* _burn_subtitles;
wxCheckBox* _encrypted;
- ContentMenu _menu;
-
std::vector<Ratio const *> _ratios;
bool _generally_sensitive;
- TimelineDialog* _timeline_dialog;
};
diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc
index 16c10f5ef..9025e5ddc 100644
--- a/src/wx/subtitle_panel.cc
+++ b/src/wx/subtitle_panel.cc
@@ -36,8 +36,8 @@ using boost::shared_ptr;
using boost::lexical_cast;
using boost::dynamic_pointer_cast;
-SubtitlePanel::SubtitlePanel (FilmEditor* e)
- : FilmEditorPanel (e, _("Subtitles"))
+SubtitlePanel::SubtitlePanel (ContentPanel* p)
+ : ContentSubPanel (p, _("Subtitles"))
, _view (0)
{
wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
@@ -105,8 +105,8 @@ SubtitlePanel::film_changed (Film::Property property)
void
SubtitlePanel::film_content_changed (int property)
{
- FFmpegContentList fc = _editor->selected_ffmpeg_content ();
- SubtitleContentList sc = _editor->selected_subtitle_content ();
+ FFmpegContentList fc = _parent->selected_ffmpeg ();
+ SubtitleContentList sc = _parent->selected_subtitle ();
shared_ptr<FFmpegContent> fcs;
if (fc.size() == 1) {
@@ -148,7 +148,7 @@ SubtitlePanel::film_content_changed (int property)
void
SubtitlePanel::use_toggled ()
{
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) {
(*i)->set_use_subtitles (_use->GetValue());
}
@@ -160,7 +160,7 @@ SubtitlePanel::setup_sensitivity ()
int any_subs = 0;
int ffmpeg_subs = 0;
int subrip_or_dcp_subs = 0;
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
for (SubtitleContentList::const_iterator i = c.begin(); i != c.end(); ++i) {
shared_ptr<const FFmpegContent> fc = boost::dynamic_pointer_cast<const FFmpegContent> (*i);
shared_ptr<const SubRipContent> sc = boost::dynamic_pointer_cast<const SubRipContent> (*i);
@@ -191,7 +191,7 @@ SubtitlePanel::setup_sensitivity ()
void
SubtitlePanel::stream_changed ()
{
- FFmpegContentList fc = _editor->selected_ffmpeg_content ();
+ FFmpegContentList fc = _parent->selected_ffmpeg ();
if (fc.size() != 1) {
return;
}
@@ -213,7 +213,7 @@ SubtitlePanel::stream_changed ()
void
SubtitlePanel::x_offset_changed ()
{
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) {
(*i)->set_subtitle_x_offset (_x_offset->GetValue() / 100.0);
}
@@ -222,7 +222,7 @@ SubtitlePanel::x_offset_changed ()
void
SubtitlePanel::y_offset_changed ()
{
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) {
(*i)->set_subtitle_y_offset (_y_offset->GetValue() / 100.0);
}
@@ -231,7 +231,7 @@ SubtitlePanel::y_offset_changed ()
void
SubtitlePanel::scale_changed ()
{
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
for (SubtitleContentList::iterator i = c.begin(); i != c.end(); ++i) {
(*i)->set_subtitle_scale (_scale->GetValue() / 100.0);
}
@@ -255,7 +255,7 @@ SubtitlePanel::view_clicked ()
_view = 0;
}
- SubtitleContentList c = _editor->selected_subtitle_content ();
+ SubtitleContentList c = _parent->selected_subtitle ();
assert (c.size() == 1);
shared_ptr<SubtitleDecoder> decoder;
@@ -271,7 +271,7 @@ SubtitlePanel::view_clicked ()
}
if (decoder) {
- _view = new SubtitleView (this, _editor->film(), decoder, c.front()->position ());
+ _view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ());
_view->Show ();
}
}
diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h
index c5665098b..9e60db34b 100644
--- a/src/wx/subtitle_panel.h
+++ b/src/wx/subtitle_panel.h
@@ -17,16 +17,16 @@
*/
-#include "film_editor_panel.h"
+#include "content_sub_panel.h"
class wxCheckBox;
class wxSpinCtrl;
class SubtitleView;
-class SubtitlePanel : public FilmEditorPanel
+class SubtitlePanel : public ContentSubPanel
{
public:
- SubtitlePanel (FilmEditor *);
+ SubtitlePanel (ContentPanel *);
void film_changed (Film::Property);
void film_content_changed (int);
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 6141c8eed..d728bd47c 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -394,9 +394,9 @@ private:
};
-Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
+Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
- , _film_editor (ed)
+ , _content_panel (cp)
, _film (film)
, _time_axis_view (new TimeAxisView (*this, 32))
, _tracks (0)
@@ -603,7 +603,7 @@ Timeline::left_down (wxMouseEvent& ev)
}
if (view == *i) {
- _film_editor->set_selection (cv->content ());
+ _content_panel->set_selection (cv->content ());
}
}
diff --git a/src/wx/timeline.h b/src/wx/timeline.h
index 8f23f6894..82d10afde 100644
--- a/src/wx/timeline.h
+++ b/src/wx/timeline.h
@@ -28,13 +28,13 @@
class Film;
class View;
class ContentView;
-class FilmEditor;
+class ContentPanel;
class TimeAxisView;
class Timeline : public wxPanel
{
public:
- Timeline (wxWindow *, FilmEditor *, boost::shared_ptr<Film>);
+ Timeline (wxWindow *, ContentPanel *, boost::shared_ptr<Film>);
boost::shared_ptr<const Film> film () const;
@@ -92,7 +92,7 @@ private:
ContentViewList selected_views () const;
ContentList selected_content () const;
- FilmEditor* _film_editor;
+ ContentPanel* _content_panel;
boost::weak_ptr<Film> _film;
ViewList _views;
boost::shared_ptr<TimeAxisView> _time_axis_view;
diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc
index dbf7ae232..2f7ade765 100644
--- a/src/wx/timeline_dialog.cc
+++ b/src/wx/timeline_dialog.cc
@@ -28,9 +28,9 @@ using std::list;
using std::cout;
using boost::shared_ptr;
-TimelineDialog::TimelineDialog (FilmEditor* ed, shared_ptr<Film> film)
- : wxDialog (ed, wxID_ANY, _("Timeline"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
- , _timeline (this, ed, film)
+TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film)
+ : wxDialog (cp->panel(), wxID_ANY, _("Timeline"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
+ , _timeline (this, cp, film)
{
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h
index 1e5955003..2f5fa5ec7 100644
--- a/src/wx/timeline_dialog.h
+++ b/src/wx/timeline_dialog.h
@@ -27,7 +27,7 @@ class Playlist;
class TimelineDialog : public wxDialog
{
public:
- TimelineDialog (FilmEditor *, boost::shared_ptr<Film>);
+ TimelineDialog (ContentPanel *, boost::shared_ptr<Film>);
private:
void snap_toggled ();
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index df77a2ef1..4345e7136 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -31,9 +31,9 @@ using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using dcp::raw_convert;
-TimingPanel::TimingPanel (FilmEditor* e)
+TimingPanel::TimingPanel (ContentPanel* p)
/* horrid hack for apparent lack of context support with wxWidgets i18n code */
- : FilmEditorPanel (e, S_("Timing|Timing"))
+ : ContentSubPanel (p, S_("Timing|Timing"))
{
wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
_sizer->Add (grid, 0, wxALL, 8);
@@ -77,13 +77,13 @@ TimingPanel::TimingPanel (FilmEditor* e)
void
TimingPanel::film_content_changed (int property)
{
- ContentList cl = _editor->selected_content ();
+ ContentList cl = _parent->selected ();
shared_ptr<Content> content;
if (cl.size() == 1) {
content = cl.front ();
}
- int const film_video_frame_rate = _editor->film()->video_frame_rate ();
+ int const film_video_frame_rate = _parent->film()->video_frame_rate ();
if (property == ContentProperty::POSITION) {
if (content) {
@@ -145,21 +145,21 @@ TimingPanel::film_content_changed (int property)
void
TimingPanel::position_changed ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
- c.front()->set_position (_position->get (_editor->film()->video_frame_rate ()));
+ c.front()->set_position (_position->get (_parent->film()->video_frame_rate ()));
}
}
void
TimingPanel::full_length_changed ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (c.front ());
if (ic && ic->still ()) {
/* XXX: No effective FRC here... is this right? */
- ic->set_video_length (ContentTime (_full_length->get (_editor->film()->video_frame_rate()), FrameRateChange (1, 1)));
+ ic->set_video_length (ContentTime (_full_length->get (_parent->film()->video_frame_rate()), FrameRateChange (1, 1)));
}
}
}
@@ -167,9 +167,9 @@ TimingPanel::full_length_changed ()
void
TimingPanel::trim_start_changed ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
- c.front()->set_trim_start (_trim_start->get (_editor->film()->video_frame_rate ()));
+ c.front()->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ()));
}
}
@@ -177,18 +177,18 @@ TimingPanel::trim_start_changed ()
void
TimingPanel::trim_end_changed ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
- c.front()->set_trim_end (_trim_end->get (_editor->film()->video_frame_rate ()));
+ c.front()->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ()));
}
}
void
TimingPanel::play_length_changed ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
- c.front()->set_trim_end (c.front()->full_length() - _play_length->get (_editor->film()->video_frame_rate()) - c.front()->trim_start());
+ c.front()->set_trim_end (c.front()->full_length() - _play_length->get (_parent->film()->video_frame_rate()) - c.front()->trim_start());
}
}
@@ -201,7 +201,7 @@ TimingPanel::video_frame_rate_changed ()
void
TimingPanel::set_video_frame_rate ()
{
- ContentList c = _editor->selected_content ();
+ ContentList c = _parent->selected ();
if (c.size() == 1) {
shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c.front ());
if (vc) {
@@ -214,7 +214,7 @@ TimingPanel::set_video_frame_rate ()
void
TimingPanel::content_selection_changed ()
{
- ContentList sel = _editor->selected_content ();
+ ContentList sel = _parent->selected ();
bool const single = sel.size() == 1;
/* Things that are only allowed with single selections */
diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h
index d9696a201..b531db551 100644
--- a/src/wx/timing_panel.h
+++ b/src/wx/timing_panel.h
@@ -17,14 +17,14 @@
*/
-#include "film_editor_panel.h"
+#include "content_sub_panel.h"
class Timecode;
-class TimingPanel : public FilmEditorPanel
+class TimingPanel : public ContentSubPanel
{
public:
- TimingPanel (FilmEditor *);
+ TimingPanel (ContentPanel *);
void film_content_changed (int);
void content_selection_changed ();
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc
index 2a5577bc1..d8fdf2d02 100644
--- a/src/wx/video_panel.cc
+++ b/src/wx/video_panel.cc
@@ -64,8 +64,8 @@ scale_to_index (VideoContentScale scale)
assert (false);
}
-VideoPanel::VideoPanel (FilmEditor* e)
- : FilmEditorPanel (e, _("Video"))
+VideoPanel::VideoPanel (ContentPanel* p)
+ : ContentSubPanel (p, _("Video"))
{
wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
_sizer->Add (grid, 0, wxALL, 8);
@@ -222,7 +222,7 @@ VideoPanel::film_changed (Film::Property property)
void
VideoPanel::film_content_changed (int property)
{
- VideoContentList vc = _editor->selected_video_content ();
+ VideoContentList vc = _parent->selected_video ();
shared_ptr<VideoContent> vcs;
shared_ptr<FFmpegContent> fcs;
if (!vc.empty ()) {
@@ -258,7 +258,7 @@ VideoPanel::film_content_changed (int property)
void
VideoPanel::edit_filters_clicked ()
{
- FFmpegContentList c = _editor->selected_ffmpeg_content ();
+ FFmpegContentList c = _parent->selected_ffmpeg ();
if (c.size() != 1) {
return;
}
@@ -272,7 +272,7 @@ VideoPanel::edit_filters_clicked ()
void
VideoPanel::setup_description ()
{
- VideoContentList vc = _editor->selected_video_content ();
+ VideoContentList vc = _parent->selected_video ();
if (vc.empty ()) {
_description->SetLabel ("");
return;
@@ -308,7 +308,7 @@ VideoPanel::setup_description ()
++lines;
}
- dcp::Size const container_size = _editor->film()->frame_size ();
+ dcp::Size const container_size = _parent->film()->frame_size ();
dcp::Size const scaled = vcs->scale().size (vcs, container_size, container_size);
if (scaled != vcs->video_size_after_crop ()) {
@@ -331,7 +331,7 @@ VideoPanel::setup_description ()
d << wxString::Format (_("Content frame rate %.4f\n"), vcs->video_frame_rate ());
++lines;
- FrameRateChange frc (vcs->video_frame_rate(), _editor->film()->video_frame_rate ());
+ FrameRateChange frc (vcs->video_frame_rate(), _parent->film()->video_frame_rate ());
d << std_to_wx (frc.description) << "\n";
++lines;
@@ -346,7 +346,7 @@ VideoPanel::setup_description ()
void
VideoPanel::edit_colour_conversion_clicked ()
{
- VideoContentList vc = _editor->selected_video_content ();
+ VideoContentList vc = _parent->selected_video ();
if (vc.size() != 1) {
return;
}
@@ -363,7 +363,7 @@ VideoPanel::edit_colour_conversion_clicked ()
void
VideoPanel::content_selection_changed ()
{
- VideoContentList sel = _editor->selected_video_content ();
+ VideoContentList sel = _parent->selected_video ();
bool const single = sel.size() == 1;
_left_crop->set_content (sel);
diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h
index 4331a9712..e17541cd3 100644
--- a/src/wx/video_panel.h
+++ b/src/wx/video_panel.h
@@ -22,7 +22,7 @@
*/
#include "lib/film.h"
-#include "film_editor_panel.h"
+#include "content_sub_panel.h"
#include "content_widget.h"
class wxChoice;
@@ -33,10 +33,10 @@ class wxButton;
/** @class VideoPanel
* @brief The video tab of the film editor.
*/
-class VideoPanel : public FilmEditorPanel
+class VideoPanel : public ContentSubPanel
{
public:
- VideoPanel (FilmEditor *);
+ VideoPanel (ContentPanel *);
void film_changed (Film::Property);
void film_content_changed (int);
diff --git a/src/wx/wscript b/src/wx/wscript
index bb5309894..26c8b9304 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -15,13 +15,14 @@ sources = """
config_dialog.cc
content_colour_conversion_dialog.cc
content_menu.cc
+ content_panel.cc
+ content_sub_panel.cc
isdcf_metadata_dialog.cc
dir_picker_ctrl.cc
dolby_certificate_dialog.cc
doremi_certificate_dialog.cc
download_certificate_dialog.cc
film_editor.cc
- film_editor_panel.cc
film_viewer.cc
filter_dialog.cc
filter_editor.cc