+#include "lib/audio_content.h"
+#include "lib/content.h"
+#include "lib/dcp_content.h"
+#include "lib/dcp_subtitle_content.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/image_content.h"
+#include "lib/string_text_file_content.h"
+#include "lib/text_content.h"
+#include "lib/video_content.h"
+#include <dcp/locale_convert.h>
+#include <dcp/warnings.h>
+#if defined(__WXGTK20__) && !defined(__WXGTK3__)
+#define TIMING_PANEL_ALIGNMENT_HACK 1
+LIBDCP_DISABLE_WARNINGS
+#include <gtk/gtk.h>
+LIBDCP_ENABLE_WARNINGS
+#endif
+#include <set>
+
+
+using std::string;
+using std::set;
+using std::shared_ptr;
+using std::weak_ptr;
+using std::dynamic_pointer_cast;
+using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+using dcp::locale_convert;
+using namespace dcpomatic;
+
+
+TimingPanel::TimingPanel (ContentPanel* p, weak_ptr<FilmViewer> viewer)
+ /* horrid hack for apparent lack of context support with wxWidgets i18n code */
+ /// TRANSLATORS: translate the word "Timing" here; do not include the "Timing|" prefix
+ : ContentSubPanel (p, S_("Timing|Timing"))
+ , _viewer (viewer)
+ , _film_content_changed_suspender (boost::bind(&TimingPanel::film_content_changed, this, _1))
+{
+
+}
+
+
+void
+TimingPanel::create ()
+{
+ wxSize size = TimecodeBase::size (this);
+
+ for (int i = 0; i < 3; ++i) {
+ _colon[i] = create_label (this, wxT(":"), false);
+ }
+
+ //// TRANSLATORS: this is an abbreviation for "hours"
+ _h_label = new StaticText (this, _("h"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
+#ifdef TIMING_PANEL_ALIGNMENT_HACK
+ /* Hack to work around failure to centre text on GTK */
+ gtk_label_set_line_wrap (GTK_LABEL(_h_label->GetHandle()), FALSE);
+#endif
+ //// TRANSLATORS: this is an abbreviation for "minutes"
+ _m_label = new StaticText (this, _("m"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
+#ifdef TIMING_PANEL_ALIGNMENT_HACK
+ gtk_label_set_line_wrap (GTK_LABEL (_m_label->GetHandle()), FALSE);
+#endif
+ //// TRANSLATORS: this is an abbreviation for "seconds"
+ _s_label = new StaticText (this, _("s"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
+#ifdef TIMING_PANEL_ALIGNMENT_HACK
+ gtk_label_set_line_wrap (GTK_LABEL(_s_label->GetHandle()), FALSE);
+#endif
+ //// TRANSLATORS: this is an abbreviation for "frames"
+ _f_label = new StaticText (this, _("f"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
+#ifdef TIMING_PANEL_ALIGNMENT_HACK
+ gtk_label_set_line_wrap (GTK_LABEL(_f_label->GetHandle()), FALSE);
+#endif
+
+ _position_label = create_label (this, _("Position"), true);
+ _position = new Timecode<DCPTime> (this);
+ _move_to_start_of_reel = new Button (this, _("Move to start of reel"));
+ _full_length_label = create_label (this, _("Full length"), true);
+ _full_length = new Timecode<DCPTime> (this);
+ _trim_start_label = create_label (this, _("Trim from start"), true);
+ _trim_start = new Timecode<ContentTime> (this);
+ _trim_start_to_playhead = new Button (this, _("Trim up to current position"));
+ _trim_end_label = create_label (this, _("Trim from end"), true);
+ _trim_end = new Timecode<ContentTime> (this);
+ _trim_end_to_playhead = new Button (this, _("Trim from current position to end"));
+ _play_length_label = create_label (this, _("Play length"), true);
+ _play_length = new Timecode<DCPTime> (this);
+
+ _position->Changed.connect (boost::bind (&TimingPanel::position_changed, this));
+ _move_to_start_of_reel->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::move_to_start_of_reel_clicked, this));
+ _full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this));
+ _trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this));
+ _trim_start_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this));
+ _trim_end->Changed.connect (boost::bind (&TimingPanel::trim_end_changed, this));
+ _trim_end_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_end_to_playhead_clicked, this));
+ _play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this));
+
+ shared_ptr<FilmViewer> fv = _viewer.lock ();
+ DCPOMATIC_ASSERT (fv);
+ fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this));
+
+ setup_sensitivity ();
+ add_to_grid ();
+
+ _sizer->Layout ();
+}
+
+void
+TimingPanel::add_to_grid ()
+{
+ int r = 0;
+
+ wxSizer* labels = new wxBoxSizer (wxHORIZONTAL);
+ labels->Add (_h_label, 1, wxEXPAND);
+ add_label_to_sizer (labels, _colon[0], false);
+ labels->Add (_m_label, 1, wxEXPAND);
+ add_label_to_sizer (labels, _colon[1], false);
+ labels->Add (_s_label, 1, wxEXPAND);
+ add_label_to_sizer (labels, _colon[2], false);
+ labels->Add (_f_label, 1, wxEXPAND);
+ _grid->Add (labels, wxGBPosition(r, 1));
+ ++r;
+
+ add_label_to_sizer (_grid, _position_label, true, wxGBPosition(r, 0));
+ _grid->Add (_position, wxGBPosition(r, 1));
+ ++r;
+
+ _grid->Add (_move_to_start_of_reel, wxGBPosition(r, 1));
+ ++r;
+
+ add_label_to_sizer (_grid, _full_length_label, true, wxGBPosition(r, 0));
+ _grid->Add (_full_length, wxGBPosition(r, 1));
+ ++r;
+
+ add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0));
+ _grid->Add (_trim_start, wxGBPosition(r, 1));
+ ++r;
+
+ _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1));
+ ++r;
+
+ add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0));
+ _grid->Add (_trim_end, wxGBPosition(r, 1));
+ ++r;
+
+ _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1));
+ ++r;
+
+ add_label_to_sizer (_grid, _play_length_label, true, wxGBPosition(r, 0));
+ _grid->Add (_play_length, wxGBPosition(r, 1));
+ ++r;