summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-11-20 00:01:03 +0000
committerCarl Hetherington <cth@carlh.net>2018-11-22 23:26:27 +0000
commit8872a0a0028048e277a623fa08e8242dd43f4824 (patch)
treede2966cbfbd96033fcc2539a6e20bd146812a7c3 /src/wx
parent1e76e9d06cb86cc7a29e5603097d74ab0057057f (diff)
Separate out SPL/SPLEntry; start trying to make player read SPLs sensibly.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/content_view.h3
-rw-r--r--src/wx/controls.cc62
-rw-r--r--src/wx/controls.h8
3 files changed, 43 insertions, 30 deletions
diff --git a/src/wx/content_view.h b/src/wx/content_view.h
index 471dd054b..d27638c05 100644
--- a/src/wx/content_view.h
+++ b/src/wx/content_view.h
@@ -18,6 +18,7 @@
*/
+#include "lib/content_store.h"
#include <wx/listctrl.h>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
@@ -26,7 +27,7 @@
class Content;
class Film;
-class ContentView : public wxListCtrl
+class ContentView : public wxListCtrl, public ContentStore
{
public:
ContentView (wxWindow* parent, boost::weak_ptr<Film> film);
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index 5fa8d7176..cc9817b15 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -103,9 +103,8 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
e_sizer->Add (left_sizer, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
_current_spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
+ _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 500);
_current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
- _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
- _current_spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 580);
e_sizer->Add (_current_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
_v_sizer->Add (e_sizer, 1, wxEXPAND);
@@ -165,12 +164,12 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
_forward_button->Bind (wxEVT_LEFT_DOWN, boost::bind(&Controls::forward_clicked, this, _1));
_frame_number->Bind (wxEVT_LEFT_DOWN, boost::bind(&Controls::frame_number_clicked, this));
_timecode->Bind (wxEVT_LEFT_DOWN, boost::bind(&Controls::timecode_clicked, this));
- _content_view->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind(&Controls::setup_sensitivity, this));
- _content_view->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&Controls::setup_sensitivity, this));
if (_jump_to_selected) {
_jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::jump_to_selected_clicked, this));
_jump_to_selected->SetValue (Config::instance()->jump_to_selected ());
}
+ _spl_view->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind(&Controls::spl_selection_changed, this));
+ _spl_view->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&Controls::spl_selection_changed, this));
_viewer->PositionChanged.connect (boost::bind(&Controls::position_changed, this));
_viewer->Started.connect (boost::bind(&Controls::started, this));
@@ -192,6 +191,31 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
}
void
+Controls::spl_selection_changed ()
+{
+ long int selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (selected == -1) {
+ _current_spl_view->DeleteAllItems ();
+ return;
+ }
+
+ shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
+
+ int N = 0;
+ BOOST_FOREACH (SPLEntry i, _playlists[selected].get()) {
+ wxListItem it;
+ it.SetId (N);
+ it.SetColumn (0);
+ it.SetText (std_to_wx(i.name));
+ _current_spl_view->InsertItem (it);
+ film->add_content (i.content);
+ ++N;
+ }
+
+ _viewer->set_film (film);
+}
+
+void
Controls::config_changed (int property)
{
if (property == Config::PLAYER_CONTENT_DIRECTORY) {
@@ -248,18 +272,6 @@ Controls::outline_content_changed ()
_viewer->set_outline_content (_outline_content->GetValue());
}
-void
-Controls::film_change (ChangeType type, Film::Property p)
-{
- if (type != CHANGE_TYPE_DONE) {
- return;
- }
-
- if (p == Film::CONTENT || p == Film::THREE_D) {
- setup_sensitivity ();
- }
-}
-
/** @param page true if this was a PAGEUP/PAGEDOWN event for which we won't receive a THUMBRELEASE */
void
Controls::slider_moved (bool page)
@@ -483,10 +495,6 @@ Controls::film_changed ()
update_position_slider ();
update_position_label ();
- if (_film) {
- _film->Change.connect (boost::bind (&Controls::film_change, this, _1, _2));
- }
-
_content_view->set_film (film);
_content_view->update ();
}
@@ -512,14 +520,14 @@ Controls::show_extended_player_controls (bool s)
}
void
-Controls::add_playlist_to_list (shared_ptr<Film> film)
+Controls::add_playlist_to_list (SPL spl)
{
int const N = _spl_view->GetItemCount();
wxListItem it;
it.SetId(N);
it.SetColumn(0);
- it.SetText (std_to_wx(film->name()));
+ it.SetText (std_to_wx(spl.name()));
_spl_view->InsertItem (it);
}
@@ -540,10 +548,12 @@ Controls::update_playlist_directory ()
for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
try {
- shared_ptr<Film> film (new Film(optional<path>()));
- film->read_metadata (i->path());
- _playlists.push_back (film);
- add_playlist_to_list (film);
+ if (is_regular_file(i->path()) && i->path().extension() == ".xml") {
+ SPL spl;
+ spl.read (i->path(), _content_view);
+ _playlists.push_back (spl);
+ add_playlist_to_list (spl);
+ }
} catch (exception& e) {
/* Never mind */
}
diff --git a/src/wx/controls.h b/src/wx/controls.h
index 3bb963660..7cdd4a0d2 100644
--- a/src/wx/controls.h
+++ b/src/wx/controls.h
@@ -21,6 +21,7 @@
#include "lib/dcpomatic_time.h"
#include "lib/types.h"
#include "lib/film.h"
+#include "lib/spl.h"
#include <wx/wx.h>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
@@ -33,6 +34,7 @@ class PlayerVideo;
class wxToggleButton;
class wxListCtrl;
class ContentView;
+class SPL;
namespace dcp {
class CPL;
@@ -73,7 +75,6 @@ private:
void active_jobs_changed (boost::optional<std::string>);
DCPTime nudge_amount (wxKeyboardState& ev);
void image_changed (boost::weak_ptr<PlayerVideo>);
- void film_change (ChangeType type, Film::Property p);
void outline_content_changed ();
void eye_changed ();
void position_changed ();
@@ -83,6 +84,7 @@ private:
void update_content_directory ();
void update_playlist_directory ();
void config_changed (int property);
+ void spl_selection_changed ();
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
@@ -90,7 +92,7 @@ private:
void pause_clicked ();
void stop_clicked ();
#endif
- void add_playlist_to_list (boost::shared_ptr<Film> film);
+ void add_playlist_to_list (SPL spl);
boost::shared_ptr<Film> _film;
boost::shared_ptr<FilmViewer> _viewer;
@@ -106,7 +108,7 @@ private:
wxListCtrl* _spl_view;
wxListCtrl* _current_spl_view;
wxTextCtrl* _log;
- std::vector<boost::shared_ptr<Film> > _playlists;
+ std::vector<SPL> _playlists;
wxSlider* _slider;
wxButton* _rewind_button;
wxButton* _back_button;