Basic frame index and timecode (part of #68).
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Apr 2013 21:10:10 +0000 (22:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Apr 2013 21:10:10 +0000 (22:10 +0100)
ChangeLog
src/wx/film_viewer.cc
src/wx/film_viewer.h

index fb526efd192e0ff0db1b90b40c512cfa6a2f8671..12890135c94c5581a3c7ff66a8c1c2845f320167 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-04-19  Carl Hetherington  <cth@carlh.net>
 
+       * Add basic frame index and timecode to viewer (part of #68).
+
        * Version 0.84beta4 released.
 
 2013-04-19  Carl Hetherington  <cth@carlh.net>
index 40b74ac39f3eaf5595fae713045e204ff9b8c878..00f89528553ced676392fc8833dbd1b44349043b 100644 (file)
@@ -51,6 +51,8 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        : wxPanel (p)
        , _panel (new wxPanel (this))
        , _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096))
+       , _frame (new wxStaticText (this, wxID_ANY, wxT("")))
+       , _timecode (new wxStaticText (this, wxID_ANY, wxT("")))
        , _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
        , _display_frame_x (0)
        , _got_frame (false)
@@ -66,11 +68,19 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        _v_sizer->Add (_panel, 1, wxEXPAND);
 
        wxBoxSizer* h_sizer = new wxBoxSizer (wxHORIZONTAL);
+
+       wxBoxSizer* time_sizer = new wxBoxSizer (wxVERTICAL);
+       time_sizer->Add (_frame, 0, wxEXPAND);
+       time_sizer->Add (_timecode, 0, wxEXPAND);
+       
+       h_sizer->Add (time_sizer, 0, wxEXPAND);
        h_sizer->Add (_play_button, 0, wxEXPAND);
        h_sizer->Add (_slider, 1, wxEXPAND);
 
        _v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6);
 
+       _frame->SetMinSize (wxSize (84, -1));
+
        _panel->Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (FilmViewer::paint_panel), 0, this);
        _panel->Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (FilmViewer::panel_sized), 0, this);
        _slider->Connect (wxID_ANY, wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler (FilmViewer::slider_moved), 0, this);
@@ -390,6 +400,20 @@ FilmViewer::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle> s
        raw_to_display ();
 
        _got_frame = true;
+
+       double const t = _decoders.video->last_source_time ();
+       double const fps = _decoders.video->frames_per_second ();
+       _frame->SetLabel (wxString::Format ("%d", int (rint (t * fps))));
+
+       double w = t;
+       int const h = (w / 3600);
+       w -= h * 3600;
+       int const m = (w / 60);
+       w -= m * 60;
+       int const s = floor (w);
+       w -= s;
+       int const f = rint (w * fps);
+       _timecode->SetLabel (wxString::Format ("%02d:%02d:%02d:%02d", h, m, s, f));
 }
 
 void
index 784434f6b60c2a198ce4c29edbd97575eba5b475..859bf7edeb8939f2b8f042bcf9558996b679c700 100644 (file)
@@ -62,6 +62,8 @@ private:
        wxSizer* _v_sizer;
        wxPanel* _panel;
        wxSlider* _slider;
+       wxStaticText* _frame;
+       wxStaticText* _timecode;
        wxToggleButton* _play_button;
        wxTimer _timer;