X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontrols.cc;h=b9eebade5317ad96ad488bbf763ca1bd9075ae3f;hb=a399d7c7b9239e055ba08a82b18eb68a511d1025;hp=29f4aeaa364e2416de48dda239f25e2ebbd8ee27;hpb=952084c4221c5708e02c783284cf0f7239c6b4c4;p=dcpomatic.git diff --git a/src/wx/controls.cc b/src/wx/controls.cc index 29f4aeaa3..b9eebade5 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -19,49 +19,56 @@ */ +#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_ptr.h" +#include "wx_util.h" #include "lib/content_factory.h" #include "lib/cross.h" -#include +#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 "lib/scope_guard.h" #include +#include #include #include -#include -#include +#include +LIBDCP_DISABLE_WARNINGS #include #include +#include +#include +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 using namespace dcpomatic; -Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor_controls) +Controls::Controls(wxWindow* parent, 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) @@ -100,14 +107,19 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor 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); @@ -127,7 +139,7 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor _eye->Bind (wxEVT_CHOICE, boost::bind (&Controls::eye_changed, this)); } if (_outline_content) { - _outline_content->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::outline_content_changed, this)); + _outline_content->bind(&Controls::outline_content_changed, this); } _slider->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind(&Controls::slider_moved, this, false)); @@ -140,17 +152,17 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor _frame_number->Bind (wxEVT_LEFT_DOWN, boost::bind(&Controls::frame_number_clicked, this)); _timecode->Bind (wxEVT_LEFT_DOWN, boost::bind(&Controls::timecode_clicked, this)); if (_jump_to_selected) { - _jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::jump_to_selected_clicked, this)); + _jump_to_selected->bind(&Controls::jump_to_selected_clicked, this); _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 (); @@ -186,12 +198,7 @@ Controls::stopped () void Controls::update_position () { - auto viewer = _viewer.lock (); - if (!viewer) { - return; - } - - if (!_slider_being_moved && !viewer->pending_idle_get()) { + if (!_slider_being_moved && !_viewer.pending_idle_get()) { update_position_label (); update_position_slider (); } @@ -201,24 +208,14 @@ Controls::update_position () void Controls::eye_changed () { - auto viewer = _viewer.lock (); - if (!viewer) { - return; - } - - viewer->set_eyes (_eye->GetSelection() == 0 ? Eyes::LEFT : Eyes::RIGHT); + _viewer.set_eyes(_eye->GetSelection() == 0 ? Eyes::LEFT : Eyes::RIGHT); } void Controls::outline_content_changed () { - auto viewer = _viewer.lock (); - if (!viewer) { - return; - } - - viewer->set_outline_content (_outline_content->GetValue()); + _viewer.set_outline_content(_outline_content->GetValue()); } @@ -226,14 +223,13 @@ Controls::outline_content_changed () void Controls::slider_moved (bool page) { - auto viewer = _viewer.lock (); - if (!_film || !viewer) { + if (!_film) { 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; } @@ -244,30 +240,19 @@ Controls::slider_moved (bool page) */ 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; } @@ -280,15 +265,10 @@ Controls::update_position_slider () 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); } @@ -305,15 +285,10 @@ Controls::update_position_label () 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)); } @@ -328,12 +303,7 @@ Controls::active_jobs_changed (optional j) DCPTime Controls::nudge_amount (wxKeyboardState& ev) { - auto viewer = _viewer.lock (); - if (!viewer) { - return {}; - } - - auto amount = viewer->one_video_frame (); + auto amount = _viewer.one_video_frame(); if (ev.ShiftDown() && !ev.ControlDown()) { amount = DCPTime::from_seconds (1); @@ -350,10 +320,7 @@ Controls::nudge_amount (wxKeyboardState& ev) void Controls::rewind_clicked (wxMouseEvent& ev) { - auto viewer = _viewer.lock (); - if (viewer) { - viewer->seek (DCPTime(), true); - } + _viewer.seek(DCPTime(), true); ev.Skip(); } @@ -361,40 +328,28 @@ Controls::rewind_clicked (wxMouseEvent& ev) void Controls::back_frame () { - auto viewer = _viewer.lock (); - if (viewer) { - viewer->seek_by (-viewer->one_video_frame(), true); - } + _viewer.seek_by(-_viewer.one_video_frame(), true); } void Controls::forward_frame () { - auto viewer = _viewer.lock (); - if (viewer) { - viewer->seek_by (viewer->one_video_frame(), true); - } + _viewer.seek_by(_viewer.one_video_frame(), true); } void Controls::back_clicked (wxKeyboardState& ev) { - auto viewer = _viewer.lock (); - if (viewer) { - viewer->seek_by (-nudge_amount(ev), true); - } + _viewer.seek_by(-nudge_amount(ev), true); } void Controls::forward_clicked (wxKeyboardState& ev) { - auto viewer = _viewer.lock (); - if (viewer) { - viewer->seek_by (nudge_amount(ev), true); - } + _viewer.seek_by(nudge_amount(ev), true); } @@ -427,32 +382,22 @@ Controls::setup_sensitivity () void Controls::timecode_clicked () { - auto viewer = _viewer.lock (); - if (!viewer) { - return; - } + auto dialog = make_wx(this, _viewer.position(), _film->video_frame_rate()); - 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 viewer = _viewer.lock (); - if (!viewer) { - return; - } + auto dialog = make_wx(this, _viewer.position(), _film->video_frame_rate()); - 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 (); } @@ -472,6 +417,8 @@ Controls::set_film (shared_ptr film) _film = film; + _markers->set_film (_film); + if (_film) { _film_change_connection = _film->Change.connect (boost::bind(&Controls::film_change, this, _1, _2)); }