X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fmarkers_dialog.cc;h=821258a20ec8d874971be3c4a660d2228ddab84e;hb=31de5b1272d928557a7272977584f5dcc9876c75;hp=7f675f2150e6efdce66080609227800f5574cafa;hpb=cb6729aa79b555b219974207fbe2ff0510f9d3ea;p=dcpomatic.git diff --git a/src/wx/markers_dialog.cc b/src/wx/markers_dialog.cc index 7f675f215..821258a20 100644 --- a/src/wx/markers_dialog.cc +++ b/src/wx/markers_dialog.cc @@ -18,6 +18,7 @@ */ + #include "markers_dialog.h" #include "wx_util.h" #include "timecode.h" @@ -31,6 +32,7 @@ #include #include + using std::cout; using std::shared_ptr; using std::weak_ptr; @@ -39,6 +41,7 @@ using boost::optional; using boost::bind; using dcpomatic::DCPTime; + class Marker { public: @@ -54,10 +57,10 @@ public: set_button = new Button (parent, _("Set from current position")); grid->Add (set_button, wxGBPosition(row, 2)); - shared_ptr f = film.lock (); + auto f = film.lock (); DCPOMATIC_ASSERT (f); - optional t = f->marker (type); + auto t = f->marker (type); checkbox->SetValue (static_cast(t)); if (t) { timecode->set (*t, f->video_frame_rate()); @@ -79,9 +82,9 @@ private: void set () { - shared_ptr f = film.lock (); + auto f = film.lock (); DCPOMATIC_ASSERT (f); - shared_ptr v = viewer.lock (); + auto v = viewer.lock (); DCPOMATIC_ASSERT (v); timecode->set (v->position(), f->video_frame_rate()); changed (); @@ -89,10 +92,16 @@ private: void changed () { - shared_ptr f = film.lock (); + auto f = film.lock (); DCPOMATIC_ASSERT (f); + auto vfr = f->video_frame_rate(); + auto tc = timecode->get(vfr); + if (tc >= f->length()) { + tc = f->length() - DCPTime::from_frames(1, vfr); + timecode->set (tc, vfr); + } if (checkbox->GetValue()) { - f->set_marker (type, timecode->get(f->video_frame_rate())); + f->set_marker (type, tc); } else { f->unset_marker (type); } @@ -106,12 +115,13 @@ private: Button* set_button; }; + MarkersDialog::MarkersDialog (wxWindow* parent, weak_ptr film, weak_ptr viewer) : wxDialog (parent, wxID_ANY, _("Markers")) , _film (film) { - wxSizer* sizer = new wxBoxSizer (wxVERTICAL); - wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto sizer = new wxBoxSizer (wxVERTICAL); + auto grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); int r = 0; _markers.push_back (make_shared(this, grid, r++, film, viewer, _("First frame of composition"), dcp::Marker::FFOC));