*/
+#include "check_box.h"
+#include "content_view.h"
#include "controls.h"
+#include "dcpomatic_button.h"
#include "film_viewer.h"
-#include "wx_util.h"
-#include "playhead_to_timecode_dialog.h"
+#include "markers_panel.h"
#include "playhead_to_frame_dialog.h"
-#include "content_view.h"
+#include "playhead_to_timecode_dialog.h"
#include "static_text.h"
-#include "check_box.h"
-#include "dcpomatic_button.h"
-#include "lib/job_manager.h"
-#include "lib/player_video.h"
-#include "lib/dcp_content.h"
-#include "lib/job.h"
-#include "lib/examine_content_job.h"
+#include "wx_util.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
-#include <dcp/dcp.h>
+#include "lib/dcp_content.h"
+#include "lib/examine_content_job.h"
+#include "lib/job.h"
+#include "lib/job_manager.h"
+#include "lib/player_video.h"
#include <dcp/cpl.h>
+#include <dcp/dcp.h>
#include <dcp/reel.h>
#include <dcp/reel_picture_asset.h>
-#include <wx/wx.h>
-#include <wx/tglbtn.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
#include <wx/progdlg.h>
+#include <wx/tglbtn.h>
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
-using std::string;
-using std::list;
using std::cout;
-using std::make_pair;
+using std::dynamic_pointer_cast;
using std::exception;
-using boost::optional;
+using std::list;
+using std::make_pair;
using std::shared_ptr;
+using std::string;
using std::weak_ptr;
-using std::dynamic_pointer_cast;
+using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls)
: wxPanel (parent)
+ , _markers (new MarkersPanel(this, viewer))
, _slider (new wxSlider(this, wxID_ANY, 0, 0, 4096))
, _viewer (viewer)
, _slider_being_moved (false)
time_sizer->Add (_timecode, 0, wxEXPAND);
h_sizer->Add (_rewind_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
- h_sizer->Add (time_sizer, 0, wxEXPAND);
+ h_sizer->Add (time_sizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
h_sizer->Add (_back_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
h_sizer->Add (_forward_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
_button_sizer = new wxBoxSizer (wxHORIZONTAL);
h_sizer->Add (_button_sizer, 0, wxEXPAND);
- h_sizer->Add (_slider, 1, wxEXPAND);
+ {
+ auto box = new wxBoxSizer (wxVERTICAL);
+ box->Add (_markers, 0, wxEXPAND);
+ box->Add (_slider, 0, wxEXPAND);
+ h_sizer->Add (box, 1, wxEXPAND);
+ }
_v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6);
_jump_to_selected->SetValue (Config::instance()->jump_to_selected ());
}
- _viewer->Started.connect (boost::bind(&Controls::started, this));
- _viewer->Stopped.connect (boost::bind(&Controls::stopped, this));
+ viewer->Started.connect (boost::bind(&Controls::started, this));
+ viewer->Stopped.connect (boost::bind(&Controls::stopped, this));
Bind (wxEVT_TIMER, boost::bind(&Controls::update_position, this));
_timer.Start (80, wxTIMER_CONTINUOUS);
- set_film (_viewer->film());
+ set_film (viewer->film());
setup_sensitivity ();
void
Controls::update_position ()
{
- if (!_slider_being_moved && !_viewer->pending_idle_get()) {
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
+ if (!_slider_being_moved && !viewer->pending_idle_get()) {
update_position_label ();
update_position_slider ();
}
void
Controls::eye_changed ()
{
- _viewer->set_eyes (_eye->GetSelection() == 0 ? Eyes::LEFT : Eyes::RIGHT);
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
+ viewer->set_eyes (_eye->GetSelection() == 0 ? Eyes::LEFT : Eyes::RIGHT);
}
void
Controls::outline_content_changed ()
{
- _viewer->set_outline_content (_outline_content->GetValue());
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
+ viewer->set_outline_content (_outline_content->GetValue());
}
void
Controls::slider_moved (bool page)
{
- if (!_film) {
+ auto viewer = _viewer.lock ();
+ if (!_film || !viewer) {
return;
}
if (!page && !_slider_being_moved) {
/* This is the first event of a drag; stop playback for the duration of the drag */
- _viewer->suspend ();
+ viewer->suspend ();
_slider_being_moved = true;
}
*/
bool accurate = false;
if (t >= _film->length ()) {
- t = _film->length() - _viewer->one_video_frame();
+ t = _film->length() - viewer->one_video_frame();
accurate = true;
}
- _viewer->seek (t, accurate);
+ viewer->seek (t, accurate);
update_position_label ();
-
- log (
- wxString::Format(
- "playback-seeked %s", t.timecode(_film->video_frame_rate()).c_str()
- )
- );
}
void
Controls::slider_released ()
{
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
/* Restart after a drag */
- _viewer->resume ();
+ viewer->resume ();
_slider_being_moved = false;
}
return;
}
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
auto const len = _film->length ();
if (len.get ()) {
- int const new_slider_position = 4096 * _viewer->position().get() / len.get();
+ int const new_slider_position = 4096 * viewer->position().get() / len.get();
if (new_slider_position != _slider->GetValue()) {
_slider->SetValue (new_slider_position);
}
return;
}
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
double const fps = _film->video_frame_rate ();
/* Count frame number from 1 ... not sure if this is the best idea */
- checked_set (_frame_number, wxString::Format (wxT("%ld"), lrint (_viewer->position().seconds() * fps) + 1));
- checked_set (_timecode, time_to_timecode (_viewer->position(), fps));
+ checked_set (_frame_number, wxString::Format (wxT("%ld"), lrint (viewer->position().seconds() * fps) + 1));
+ checked_set (_timecode, time_to_timecode (viewer->position(), fps));
}
DCPTime
Controls::nudge_amount (wxKeyboardState& ev)
{
- auto amount = _viewer->one_video_frame ();
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return {};
+ }
+
+ auto amount = viewer->one_video_frame ();
if (ev.ShiftDown() && !ev.ControlDown()) {
amount = DCPTime::from_seconds (1);
void
Controls::rewind_clicked (wxMouseEvent& ev)
{
- _viewer->seek (DCPTime(), true);
+ auto viewer = _viewer.lock ();
+ if (viewer) {
+ viewer->seek (DCPTime(), true);
+ }
ev.Skip();
}
void
Controls::back_frame ()
{
- _viewer->seek_by (-_viewer->one_video_frame(), true);
+ auto viewer = _viewer.lock ();
+ if (viewer) {
+ viewer->seek_by (-viewer->one_video_frame(), true);
+ }
}
void
Controls::forward_frame ()
{
- _viewer->seek_by (_viewer->one_video_frame(), true);
+ auto viewer = _viewer.lock ();
+ if (viewer) {
+ viewer->seek_by (viewer->one_video_frame(), true);
+ }
}
void
Controls::back_clicked (wxKeyboardState& ev)
{
- _viewer->seek_by (-nudge_amount(ev), true);
+ auto viewer = _viewer.lock ();
+ if (viewer) {
+ viewer->seek_by (-nudge_amount(ev), true);
+ }
}
void
Controls::forward_clicked (wxKeyboardState& ev)
{
- _viewer->seek_by (nudge_amount(ev), true);
+ auto viewer = _viewer.lock ();
+ if (viewer) {
+ viewer->seek_by (nudge_amount(ev), true);
+ }
}
void
Controls::timecode_clicked ()
{
- auto dialog = new PlayheadToTimecodeDialog (this, _viewer->position(), _film->video_frame_rate());
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
+ auto dialog = new PlayheadToTimecodeDialog (this, viewer->position(), _film->video_frame_rate());
if (dialog->ShowModal() == wxID_OK) {
- _viewer->seek (dialog->get(), true);
+ viewer->seek (dialog->get(), true);
}
dialog->Destroy ();
}
void
Controls::frame_number_clicked ()
{
- auto dialog = new PlayheadToFrameDialog (this, _viewer->position(), _film->video_frame_rate());
+ auto viewer = _viewer.lock ();
+ if (!viewer) {
+ return;
+ }
+
+ auto dialog = new PlayheadToFrameDialog (this, viewer->position(), _film->video_frame_rate());
if (dialog->ShowModal() == wxID_OK) {
- _viewer->seek (dialog->get(), true);
+ viewer->seek (dialog->get(), true);
}
dialog->Destroy ();
}
_film = film;
+ _markers->set_film (_film);
+
if (_film) {
_film_change_connection = _film->Change.connect (boost::bind(&Controls::film_change, this, _1, _2));
}