summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-11-14 23:58:40 +0000
committerCarl Hetherington <cth@carlh.net>2018-11-22 23:26:18 +0000
commita3f6e20d055cdf1697eab011622dc569010ad617 (patch)
tree9ad5e44636b2927750220002ccf456558a92bdfb /src/wx
parenta0cafafc73958b21db24dfed8693b27238361114 (diff)
swaroop: basic manipulation of content in playlist creator.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/content_view.cc147
-rw-r--r--src/wx/content_view.h42
-rw-r--r--src/wx/controls.cc84
-rw-r--r--src/wx/controls.h5
-rw-r--r--src/wx/wscript1
5 files changed, 199 insertions, 80 deletions
diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc
new file mode 100644
index 000000000..4eab80339
--- /dev/null
+++ b/src/wx/content_view.cc
@@ -0,0 +1,147 @@
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "content_view.h"
+#include "wx_util.h"
+#include "lib/dcpomatic_assert.h"
+#include "lib/config.h"
+#include "lib/dcp_content.h"
+#include "lib/content_factory.h"
+#include "lib/examine_content_job.h"
+#include "lib/job_manager.h"
+#include "lib/cross.h"
+#include <dcp/exceptions.h>
+#include <boost/filesystem.hpp>
+#include <boost/optional.hpp>
+#include <wx/progdlg.h>
+
+using boost::shared_ptr;
+using boost::weak_ptr;
+using boost::optional;
+using boost::dynamic_pointer_cast;
+
+ContentView::ContentView (wxWindow* parent, weak_ptr<Film> film)
+ : wxListCtrl (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER)
+ , _film (film)
+{
+ AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
+ /* type */
+ AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
+ /* annotation text */
+ AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
+}
+
+shared_ptr<Content>
+ContentView::selected () const
+{
+ long int s = GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s == -1) {
+ return shared_ptr<Content>();
+ }
+
+ DCPOMATIC_ASSERT (s < int(_content.size()));
+ return _content[s];
+}
+
+void
+ContentView::update ()
+{
+ if (!IsShown()) {
+ return;
+ }
+
+ shared_ptr<Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ using namespace boost::filesystem;
+
+ DeleteAllItems ();
+ _content.clear ();
+ optional<path> dir = Config::instance()->player_content_directory();
+ if (!dir) {
+ return;
+ }
+
+ wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory"));
+ JobManager* jm = JobManager::instance ();
+
+ for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
+ try {
+ shared_ptr<Content> content;
+ if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) {
+ content.reset (new DCPContent(film, *i));
+ } else if (i->path().extension() == ".mp4" || i->path().extension() == ".ecinema") {
+ content = content_factory(film, *i).front();
+ }
+
+ if (content) {
+ jm->add (shared_ptr<Job>(new ExamineContentJob(film, content)));
+ while (jm->work_to_do()) {
+ if (!progress.Pulse()) {
+ /* user pressed cancel */
+ BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
+ i->cancel();
+ }
+ return;
+ }
+ dcpomatic_sleep (1);
+ }
+ if (report_errors_from_last_job (this)) {
+ add (content);
+ _content.push_back (content);
+ }
+ }
+ } catch (boost::filesystem::filesystem_error& e) {
+ /* Never mind */
+ } catch (dcp::DCPReadError& e) {
+ /* Never mind */
+ }
+ }
+}
+
+void
+ContentView::add (shared_ptr<Content> content)
+{
+ int const N = GetItemCount();
+
+ wxListItem it;
+ it.SetId(N);
+ it.SetColumn(0);
+ DCPTime length = content->length_after_trim ();
+ int h, m, s, f;
+ length.split (24, h, m, s, f);
+ it.SetText(wxString::Format("%02d:%02d:%02d", h, m, s));
+ InsertItem(it);
+
+ shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent>(content);
+ if (dcp && dcp->content_kind()) {
+ it.SetId(N);
+ it.SetColumn(1);
+ it.SetText(std_to_wx(dcp::content_kind_to_string(*dcp->content_kind())));
+ SetItem(it);
+ }
+
+ it.SetId(N);
+ it.SetColumn(2);
+ it.SetText(std_to_wx(content->summary()));
+ SetItem(it);
+}
diff --git a/src/wx/content_view.h b/src/wx/content_view.h
new file mode 100644
index 000000000..0da53f636
--- /dev/null
+++ b/src/wx/content_view.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <wx/listctrl.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <vector>
+
+class Content;
+class Film;
+
+class ContentView : public wxListCtrl
+{
+public:
+ ContentView (wxWindow* parent, boost::weak_ptr<Film> film);
+
+ boost::shared_ptr<Content> selected () const;
+ void update ();
+
+private:
+ void add (boost::shared_ptr<Content> content);
+
+ boost::weak_ptr<Film> _film;
+ std::vector<boost::shared_ptr<Content> > _content;
+};
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index cc0ed25bb..8f1d5abda 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -23,6 +23,7 @@
#include "wx_util.h"
#include "playhead_to_timecode_dialog.h"
#include "playhead_to_frame_dialog.h"
+#include "content_view.h"
#include "lib/job_manager.h"
#include "lib/player_video.h"
#include "lib/dcp_content.h"
@@ -94,13 +95,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740);
left_sizer->Add (_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
- _content_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
- /* time */
- _content_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
- /* type */
- _content_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
- /* annotation text */
- _content_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
+ _content_view = new ContentView (this, _film);
left_sizer->Add (_content_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
wxBoxSizer* e_sizer = new wxBoxSizer (wxHORIZONTAL);
@@ -200,7 +195,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
film_changed ();
setup_sensitivity ();
- update_content_directory ();
+ _content_view->update ();
update_playlist_directory ();
JobManager::instance()->ActiveJobsChanged.connect (
@@ -214,7 +209,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
void
Controls::add_clicked ()
{
- shared_ptr<Content> sel = selected_content()->clone();
+ shared_ptr<Content> sel = _content_view->selected()->clone();
DCPOMATIC_ASSERT (sel);
_film->examine_and_add_content (sel);
bool const ok = display_progress (_("DCP-o-matic"), _("Loading DCP"));
@@ -265,7 +260,7 @@ void
Controls::config_changed (int property)
{
if (property == Config::PLAYER_CONTENT_DIRECTORY) {
- update_content_directory ();
+ _content_view->update ();
} else if (property == Config::PLAYER_PLAYLIST_DIRECTORY) {
update_playlist_directory ();
} else {
@@ -510,22 +505,10 @@ Controls::setup_sensitivity ()
_eye->Enable (c && _film->three_d ());
}
- _add_button->Enable (Config::instance()->allow_spl_editing() && static_cast<bool>(selected_content()));
+ _add_button->Enable (Config::instance()->allow_spl_editing() && static_cast<bool>(_content_view->selected()));
_save_button->Enable (Config::instance()->allow_spl_editing());
}
-shared_ptr<Content>
-Controls::selected_content () const
-{
- long int s = _content_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- if (s == -1) {
- return shared_ptr<Content>();
- }
-
- DCPOMATIC_ASSERT (s < int(_content.size()));
- return _content[s];
-}
-
void
Controls::timecode_clicked ()
{
@@ -585,7 +568,7 @@ Controls::show_extended_player_controls (bool s)
_content_view->Show (s);
_spl_view->Show (s);
if (s) {
- update_content_directory ();
+ _content_view->update ();
update_playlist_directory ();
}
_current_spl_view->Show (s);
@@ -637,59 +620,6 @@ Controls::add_playlist_to_list (shared_ptr<Film> film)
}
void
-Controls::update_content_directory ()
-{
- if (!_content_view->IsShown()) {
- return;
- }
-
- using namespace boost::filesystem;
-
- _content_view->DeleteAllItems ();
- _content.clear ();
- optional<path> dir = Config::instance()->player_content_directory();
- if (!dir) {
- return;
- }
-
- wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory"));
- JobManager* jm = JobManager::instance ();
-
- for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
- try {
- shared_ptr<Content> content;
- if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) {
- content.reset (new DCPContent(*i));
- } else if (i->path().extension() == ".mp4" || i->path().extension() == ".ecinema") {
- content = content_factory(*i).front();
- }
-
- if (content) {
- jm->add (shared_ptr<Job>(new ExamineContentJob(_film, content)));
- while (jm->work_to_do()) {
- if (!progress.Pulse()) {
- /* user pressed cancel */
- BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
- i->cancel();
- }
- return;
- }
- dcpomatic_sleep (1);
- }
- if (report_errors_from_last_job (this)) {
- add_content_to_list (content, _content_view);
- _content.push_back (content);
- }
- }
- } catch (boost::filesystem::filesystem_error& e) {
- /* Never mind */
- } catch (dcp::DCPReadError& e) {
- /* Never mind */
- }
- }
-}
-
-void
Controls::update_playlist_directory ()
{
if (!_spl_view->IsShown()) {
diff --git a/src/wx/controls.h b/src/wx/controls.h
index d916beaf8..59fe4e5d2 100644
--- a/src/wx/controls.h
+++ b/src/wx/controls.h
@@ -32,6 +32,7 @@ class Content;
class PlayerVideo;
class wxToggleButton;
class wxListCtrl;
+class ContentView;
namespace dcp {
class CPL;
@@ -85,7 +86,6 @@ private:
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
- boost::shared_ptr<Content> selected_content () const;
#ifdef DCPOMATIC_VARIANT_SWAROOP
void pause_clicked ();
void stop_clicked ();
@@ -106,14 +106,13 @@ private:
wxCheckBox* _outline_content;
wxChoice* _eye;
wxCheckBox* _jump_to_selected;
- wxListCtrl* _content_view;
+ ContentView* _content_view;
wxListCtrl* _spl_view;
wxListCtrl* _current_spl_view;
wxTextCtrl* _log;
wxButton* _add_button;
wxButton* _save_button;
wxButton* _load_button;
- std::vector<boost::shared_ptr<Content> > _content;
std::vector<boost::shared_ptr<Film> > _playlists;
wxSlider* _slider;
wxButton* _rewind_button;
diff --git a/src/wx/wscript b/src/wx/wscript
index 5c026284e..865122a69 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -47,6 +47,7 @@ sources = """
content_panel.cc
content_properties_dialog.cc
content_sub_panel.cc
+ content_view.cc
controls.cc
closed_captions_dialog.cc
dcp_panel.cc