#include "playhead_to_timecode_dialog.h"
#include "playhead_to_frame_dialog.h"
#include "lib/job_manager.h"
+#include "lib/player_video.h"
+#include "lib/dcp_content.h"
+#include "lib/spl_entry.h"
#include <dcp/dcp.h>
#include <dcp/cpl.h>
#include <dcp/reel.h>
using boost::optional;
using boost::shared_ptr;
using boost::weak_ptr;
+using boost::dynamic_pointer_cast;
Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls)
: wxPanel (parent)
wxBoxSizer* buttons_sizer = new wxBoxSizer (wxVERTICAL);
_add_button = new wxButton(this, wxID_ANY, _("Add"));
buttons_sizer->Add (_add_button);
+ _save_button = new wxButton(this, wxID_ANY, _("Save..."));
+ buttons_sizer->Add (_save_button);
+ _load_button = new wxButton(this, wxID_ANY, _("Load..."));
+ buttons_sizer->Add (_load_button);
e_sizer->Add (buttons_sizer, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
_v_sizer->Add (e_sizer, 1, wxEXPAND);
_cpl->Show (false);
_spl_view->Show (false);
_add_button->Show (false);
+ _save_button->Show (false);
+ _load_button->Show (false);
_log->Show (false);
wxBoxSizer* h_sizer = new wxBoxSizer (wxHORIZONTAL);
_jump_to_selected->SetValue (Config::instance()->jump_to_selected ());
}
_add_button->Bind (wxEVT_BUTTON, boost::bind(&Controls::add_clicked, this));
+ _save_button->Bind (wxEVT_BUTTON, boost::bind(&Controls::save_clicked, this));
+ _load_button->Bind (wxEVT_BUTTON, boost::bind(&Controls::load_clicked, this));
_viewer->PositionChanged.connect (boost::bind(&Controls::position_changed, this));
_viewer->Started.connect (boost::bind(&Controls::started, this));
_viewer->Stopped.connect (boost::bind(&Controls::stopped, this));
_viewer->FilmChanged.connect (boost::bind(&Controls::film_changed, this));
+ _viewer->ImageChanged.connect (boost::bind(&Controls::image_changed, this, _1));
film_changed ();
);
_config_changed_connection = Config::instance()->Changed.connect (bind(&Controls::config_changed, this, _1));
+ config_changed (Config::OTHER);
}
void
{
optional<CPL> sel = selected_cpl ();
DCPOMATIC_ASSERT (sel);
- _spl.push_back (SPLEntry(sel->first, sel->second));
+ _spl.playlist.push_back (SPLEntry(sel->first, sel->second));
add_cpl_to_list (sel->first, _spl_view);
SPLChanged (_spl);
setup_sensitivity ();
}
+void
+Controls::save_clicked ()
+{
+ wxFileDialog* d = new wxFileDialog (
+ this, _("Select playlist file"), wxEmptyString, wxEmptyString, wxT ("XML files (*.xml)|*.xml"),
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+ );
+
+ if (d->ShowModal() == wxID_OK) {
+ _spl.as_xml (boost::filesystem::path(wx_to_std(d->GetPath())));
+ }
+
+ d->Destroy ();
+}
+
+void
+Controls::load_clicked ()
+{
+ wxFileDialog* d = new wxFileDialog (
+ this, _("Select playlist file"), wxEmptyString, wxEmptyString, wxT ("XML files (*.xml)|*.xml")
+ );
+
+ if (d->ShowModal() == wxID_OK) {
+ _spl = SPL (boost::filesystem::path(wx_to_std(d->GetPath())));
+ _spl_view->DeleteAllItems ();
+ BOOST_FOREACH (SPLEntry i, _spl.playlist) {
+ add_cpl_to_list (i.cpl, _spl_view);
+ }
+ SPLChanged (_spl);
+ }
+
+ d->Destroy ();
+}
+
void
Controls::config_changed (int property)
{
- if (property == Config::PLAYER_DCP_DIRECTORY) {
+ if (property == Config::PLAYER_CONTENT_DIRECTORY) {
update_dcp_directory ();
+ } else {
+ setup_sensitivity ();
}
}
{
/* examine content is the only job which stops the viewer working */
bool const active_job = _active_job && *_active_job != "examine_content";
- bool const c = ((_film && !_film->content().empty()) || !_spl.empty()) && !active_job;
+ bool const c = ((_film && !_film->content().empty()) || !_spl.playlist.empty()) && !active_job;
_slider->Enable (c);
_rewind_button->Enable (c);
_forward_button->Enable (c);
#ifdef DCPOMATIC_VARIANT_SWAROOP
_play_button->Enable (c && !_viewer->playing());
- _pause_button->Enable (c && _viewer->playing());
- _stop_button->Enable (c);
+ _pause_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && _viewer->playing());
+ _stop_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT));
+ _slider->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT));
#else
_play_button->Enable (c);
#endif
_eye->Enable (c && _film->three_d ());
}
- _add_button->Enable (static_cast<bool>(selected_cpl()));
+ _add_button->Enable (Config::instance()->allow_spl_editing() && static_cast<bool>(selected_cpl()));
+ _save_button->Enable (Config::instance()->allow_spl_editing());
}
optional<Controls::CPL>
Controls::show_extended_player_controls (bool s)
{
_cpl->Show (s);
+ if (s) {
+ update_dcp_directory ();
+ }
_spl_view->Show (s);
_log->Show (s);
_add_button->Show (s);
+ _save_button->Show (s);
+ _load_button->Show (s);
_v_sizer->Layout ();
}
void
Controls::update_dcp_directory ()
{
+ if (!_cpl->IsShown()) {
+ return;
+ }
+
using namespace boost::filesystem;
_cpl->DeleteAllItems ();
_cpls.clear ();
- optional<path> dir = Config::instance()->player_dcp_directory();
+ optional<path> dir = Config::instance()->player_content_directory();
if (!dir) {
return;
}
}
} catch (boost::filesystem::filesystem_error& e) {
/* Never mind */
+ } catch (dcp::DCPReadError& e) {
+ /* Never mind */
}
}
}
wxString ts = std_to_wx(string(buffer)) + N_(": ");
_log->SetValue(_log->GetValue() + ts + s + "\n");
}
+
+void
+Controls::image_changed (boost::weak_ptr<PlayerVideo> weak_pv)
+{
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ shared_ptr<PlayerVideo> pv = weak_pv.lock ();
+ if (!pv) {
+ return;
+ }
+
+ shared_ptr<Content> c = pv->content().lock();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (c);
+ if (!dc) {
+ return;
+ }
+
+ if (!_current_kind || *_current_kind != dc->content_kind()) {
+ _current_kind = dc->content_kind ();
+ setup_sensitivity ();
+ }
+#endif
+}