+using boost::optional;
+using dcp::locale_convert;
+
+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))
+{
+ 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 DCPOMATIC_LINUX
+ /* 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 DCPOMATIC_LINUX
+ 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 DCPOMATIC_LINUX
+ 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 DCPOMATIC_LINUX
+ 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 after current position"));
+ _play_length_label = create_label (this, _("Play length"), true);
+ _play_length = new Timecode<DCPTime> (this);
+
+ _video_frame_rate_label = create_label (this, _("Video frame rate"), true);
+ _video_frame_rate = new wxTextCtrl (this, wxID_ANY);
+ _set_video_frame_rate = new Button (this, _("Set"));
+ _set_video_frame_rate->Enable (false);
+
+ /* We can't use Wrap() here as it doesn't work with markup:
+ * http://trac.wxwidgets.org/ticket/13389
+ */
+
+ wxString in = _("<i>Only change this if the content's frame rate has been read incorrectly.</i>");
+ wxString out;
+ int const width = 20;
+ int current = 0;
+ for (size_t i = 0; i < in.Length(); ++i) {
+ if (in[i] == ' ' && current >= width) {
+ out += '\n';
+ current = 0;
+ } else {
+ out += in[i];
+ ++current;
+ }
+ }
+
+ _tip = new StaticText (this, wxT (""));
+ _tip->SetLabelMarkup (out);
+#ifdef DCPOMATIC_OSX
+ /* Hack to stop hidden text on some versions of OS X */
+ _tip->SetMinSize (wxSize (-1, 256));
+#endif
+
+ _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));
+ _video_frame_rate->Bind (wxEVT_TEXT, boost::bind (&TimingPanel::video_frame_rate_changed, this));
+ _set_video_frame_rate->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::set_video_frame_rate, this));
+
+ shared_ptr<FilmViewer> fv = _viewer.lock ();
+ DCPOMATIC_ASSERT (fv);
+ fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this));
+
+ setup_sensitivity ();
+ add_to_grid ();
+}
+
+void
+TimingPanel::add_to_grid ()
+{
+ bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;