2 Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "markers_dialog.h"
24 #include "static_text.h"
25 #include "dcpomatic_button.h"
26 #include "check_box.h"
27 #include "film_viewer.h"
29 #include <dcp/types.h>
30 #include <wx/gbsizer.h>
31 #include <boost/bind/bind.hpp>
35 using std::shared_ptr;
37 using std::make_shared;
38 using boost::optional;
40 using dcpomatic::DCPTime;
45 Marker (wxWindow* parent, wxGridBagSizer* grid, int row, weak_ptr<Film> film_, weak_ptr<FilmViewer> viewer_, wxString name, dcp::Marker type_)
50 checkbox = new CheckBox(parent, name);
51 grid->Add (checkbox, wxGBPosition(row, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
52 timecode = new Timecode<DCPTime> (parent);
53 grid->Add (timecode, wxGBPosition(row, 1));
54 set_button = new Button (parent, _("Set from current position"));
55 grid->Add (set_button, wxGBPosition(row, 2));
57 shared_ptr<Film> f = film.lock ();
60 optional<DCPTime> t = f->marker (type);
61 checkbox->SetValue (static_cast<bool>(t));
63 timecode->set (*t, f->video_frame_rate());
68 set_button->Bind (wxEVT_BUTTON, bind(&Marker::set, this));
69 checkbox->Bind (wxEVT_CHECKBOX, bind(&Marker::set_sensitivity, this));
70 timecode->Changed.connect (bind(&Marker::changed, this));
74 void set_sensitivity ()
76 timecode->Enable (checkbox->GetValue());
77 set_button->Enable (checkbox->GetValue());
82 shared_ptr<Film> f = film.lock ();
84 shared_ptr<FilmViewer> v = viewer.lock ();
86 timecode->set (v->position(), f->video_frame_rate());
92 shared_ptr<Film> f = film.lock ();
94 if (checkbox->GetValue()) {
95 f->set_marker (type, timecode->get(f->video_frame_rate()));
97 f->unset_marker (type);
102 weak_ptr<FilmViewer> viewer;
105 Timecode<dcpomatic::DCPTime>* timecode;
109 MarkersDialog::MarkersDialog (wxWindow* parent, weak_ptr<Film> film, weak_ptr<FilmViewer> viewer)
110 : wxDialog (parent, wxID_ANY, _("Markers"))
113 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
114 wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
117 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("First frame of composition"), dcp::Marker::FFOC));
118 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("Last frame of composition"), dcp::Marker::LFOC));
119 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("First frame of title credits"), dcp::Marker::FFTC));
120 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("Last frame of title credits"), dcp::Marker::LFTC));
121 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("First frame of intermission"), dcp::Marker::FFOI));
122 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("Last frame of intermission"), dcp::Marker::LFOI));
123 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("First frame of end credits"), dcp::Marker::FFEC));
124 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("Last frame of end credits"), dcp::Marker::LFEC));
125 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("First frame of moving credits"), dcp::Marker::FFMC));
126 _markers.push_back (make_shared<Marker>(this, grid, r++, film, viewer, _("Last frame of moving credits"), dcp::Marker::LFMC));
128 sizer->Add (grid, 0, wxALL, 8);
129 SetSizerAndFit (sizer);