*/
+
#include "markers_dialog.h"
#include "wx_util.h"
#include "timecode.h"
#include <boost/bind/bind.hpp>
#include <iostream>
+
using std::cout;
using std::shared_ptr;
using std::weak_ptr;
using boost::bind;
using dcpomatic::DCPTime;
+
class Marker
{
public:
set_button = new Button (parent, _("Set from current position"));
grid->Add (set_button, wxGBPosition(row, 2));
- shared_ptr<Film> f = film.lock ();
+ auto f = film.lock ();
DCPOMATIC_ASSERT (f);
- optional<DCPTime> t = f->marker (type);
+ auto t = f->marker (type);
checkbox->SetValue (static_cast<bool>(t));
if (t) {
timecode->set (*t, f->video_frame_rate());
void set ()
{
- shared_ptr<Film> f = film.lock ();
+ auto f = film.lock ();
DCPOMATIC_ASSERT (f);
- shared_ptr<FilmViewer> v = viewer.lock ();
+ auto v = viewer.lock ();
DCPOMATIC_ASSERT (v);
timecode->set (v->position(), f->video_frame_rate());
changed ();
void changed ()
{
- shared_ptr<Film> 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);
}
Button* set_button;
};
+
MarkersDialog::MarkersDialog (wxWindow* parent, weak_ptr<Film> film, weak_ptr<FilmViewer> 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<Marker>(this, grid, r++, film, viewer, _("First frame of composition"), dcp::Marker::FFOC));