2 Copyright (C) 2019 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.hpp>
36 using boost::shared_ptr;
37 using boost::weak_ptr;
38 using boost::optional;
43 Marker (wxWindow* parent, wxGridBagSizer* grid, int row, weak_ptr<Film> film_, weak_ptr<FilmViewer> viewer_, wxString name, dcp::Marker type_)
48 checkbox = new CheckBox(parent, name);
49 grid->Add (checkbox, wxGBPosition(row, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
50 timecode = new Timecode<DCPTime> (parent);
51 grid->Add (timecode, wxGBPosition(row, 1));
52 set_button = new Button (parent, _("Set from current position"));
53 grid->Add (set_button, wxGBPosition(row, 2));
55 shared_ptr<Film> f = film.lock ();
58 optional<DCPTime> t = f->marker (type);
59 checkbox->SetValue (static_cast<bool>(t));
61 timecode->set (*t, f->video_frame_rate());
66 set_button->Bind (wxEVT_BUTTON, bind(&Marker::set, this));
67 checkbox->Bind (wxEVT_CHECKBOX, bind(&Marker::set_sensitivity, this));
68 timecode->Changed.connect (bind(&Marker::changed, this));
72 void set_sensitivity ()
74 timecode->Enable (checkbox->GetValue());
75 set_button->Enable (checkbox->GetValue());
80 shared_ptr<Film> f = film.lock ();
82 shared_ptr<FilmViewer> v = viewer.lock ();
84 timecode->set (v->position(), f->video_frame_rate());
90 shared_ptr<Film> f = film.lock ();
92 if (checkbox->GetValue()) {
93 f->set_marker (type, timecode->get(f->video_frame_rate()));
95 f->unset_marker (type);
100 weak_ptr<FilmViewer> viewer;
103 Timecode<DCPTime>* timecode;
107 MarkersDialog::MarkersDialog (wxWindow* parent, weak_ptr<Film> film, weak_ptr<FilmViewer> viewer)
108 : wxDialog (parent, wxID_ANY, _("Markers"))
111 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
112 wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
115 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("First frame of composition"), dcp::FFOC)));
116 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("Last frame of composition"), dcp::LFOC)));
117 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("First frame of title credits"), dcp::FFTC)));
118 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("Last frame of title credits"), dcp::LFTC)));
119 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("First frame of intermission"), dcp::FFOI)));
120 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("Last frame of intermission"), dcp::LFOI)));
121 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("First frame of end credits"), dcp::FFEC)));
122 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("Last frame of end credits"), dcp::LFEC)));
123 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("First frame of moving credits"), dcp::FFMC)));
124 _markers.push_back (shared_ptr<Marker>(new Marker(this, grid, r++, film, viewer, _("Last frame of moving credits"), dcp::LFMC)));
126 sizer->Add (grid, 0, wxALL, 8);
127 SetSizerAndFit (sizer);