Support shadow in subtitles (#911).
[dcpomatic.git] / src / wx / film_viewer.cc
index da980dafccda4500d12ffae24bf87f6a804182c5..8019e9214e4ad040c7715c8adc750d8b9820fc84 100644 (file)
  *  @brief A wx widget to view a preview of a Film.
  */
 
+#include "film_viewer.h"
+#include "playhead_to_timecode_dialog.h"
+#include "playhead_to_frame_dialog.h"
+#include "wx_util.h"
 #include "lib/film.h"
 #include "lib/ratio.h"
 #include "lib/util.h"
@@ -36,8 +40,6 @@
 #include "lib/video_decoder.h"
 #include "lib/timer.h"
 #include "lib/log.h"
-#include "film_viewer.h"
-#include "wx_util.h"
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
@@ -124,6 +126,8 @@ FilmViewer::FilmViewer (wxWindow* p)
        _timer.Bind           (wxEVT_TIMER,                        boost::bind (&FilmViewer::timer,           this));
        _back_button->Bind    (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::back_clicked,    this, _1));
        _forward_button->Bind (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::forward_clicked, this, _1));
+       _frame_number->Bind   (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::frame_number_clicked, this));
+       _timecode->Bind       (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::timecode_clicked, this));
 
        set_film (shared_ptr<Film> ());
 
@@ -465,32 +469,32 @@ FilmViewer::nudge_amount (wxMouseEvent& ev)
 }
 
 void
-FilmViewer::back_clicked (wxMouseEvent& ev)
+FilmViewer::go_to (DCPTime t)
 {
-       DCPTime p = _position - nudge_amount (ev);
-       if (p < DCPTime ()) {
-               p = DCPTime ();
+       if (t < DCPTime ()) {
+               t = DCPTime ();
+       }
+
+       if (t >= _film->length ()) {
+               t = _film->length ();
        }
 
-       get (p, true);
+       get (t, true);
        update_position_label ();
        update_position_slider ();
+}
 
+void
+FilmViewer::back_clicked (wxMouseEvent& ev)
+{
+       go_to (_position - nudge_amount (ev));
        ev.Skip ();
 }
 
 void
 FilmViewer::forward_clicked (wxMouseEvent& ev)
 {
-       DCPTime p = _position + nudge_amount (ev);
-       if (p >= _film->length ()) {
-               p = _position;
-       }
-
-       get (p, true);
-       update_position_label ();
-       update_position_slider ();
-
+       go_to (_position + nudge_amount (ev));
        ev.Skip ();
 }
 
@@ -566,3 +570,23 @@ FilmViewer::set_coalesce_player_changes (bool c)
                }
        }
 }
+
+void
+FilmViewer::timecode_clicked ()
+{
+       PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _film->video_frame_rate ());
+       if (dialog->ShowModal() == wxID_OK) {
+               go_to (dialog->get ());
+       }
+       dialog->Destroy ();
+}
+
+void
+FilmViewer::frame_number_clicked ()
+{
+       PlayheadToFrameDialog* dialog = new PlayheadToFrameDialog (this, _film->video_frame_rate ());
+       if (dialog->ShowModal() == wxID_OK) {
+               go_to (dialog->get ());
+       }
+       dialog->Destroy ();
+}