X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftimecode.h;h=7a34b80fec949eecf69eb06dec2bcab319404f80;hb=c6c082c4a8016f85ba4207f4b8ccee1d5770e4a4;hp=b13e8c3c084b9c35514e805f59e752927fe46ae1;hpb=73f52e94953848c696725defd3d7f5c4c30707e2;p=dcpomatic.git diff --git a/src/wx/timecode.h b/src/wx/timecode.h index b13e8c3c0..7a34b80fe 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,27 @@ */ -#include -#include +#ifndef DCPOMATIC_WX_TIMECODE_H +#define DCPOMATIC_WX_TIMECODE_H + +#include "wx_util.h" #include "lib/types.h" +#include +#include +#include -class Timecode : public wxPanel +class TimecodeBase : public wxPanel { public: - Timecode (wxWindow *); + TimecodeBase (wxWindow *); - void set (DCPTime, int); - DCPTime get (int) const; + void clear (); void set_editable (bool); boost::signals2::signal Changed; -private: +protected: void changed (); void set_clicked (); @@ -47,3 +51,46 @@ private: wxStaticText* _fixed; }; +template +class Timecode : public TimecodeBase +{ +public: + Timecode (wxWindow* parent) + : TimecodeBase (parent) + { + + } + + void set (T t, int fps) + { + int h; + int m; + int s; + int f; + t.split (fps, h, m, s, f); + + checked_set (_hours, boost::lexical_cast (h)); + checked_set (_minutes, boost::lexical_cast (m)); + checked_set (_seconds, boost::lexical_cast (s)); + checked_set (_frames, boost::lexical_cast (f)); + + _fixed->SetLabel (std_to_wx (t.timecode (fps))); + } + + T get (int fps) const + { + T t; + std::string const h = wx_to_std (_hours->GetValue ()); + t += T::from_seconds (boost::lexical_cast (h.empty() ? "0" : h) * 3600); + std::string const m = wx_to_std (_minutes->GetValue()); + t += T::from_seconds (boost::lexical_cast (m.empty() ? "0" : m) * 60); + std::string const s = wx_to_std (_seconds->GetValue()); + t += T::from_seconds (boost::lexical_cast (s.empty() ? "0" : s)); + std::string const f = wx_to_std (_frames->GetValue()); + t += T::from_seconds (boost::lexical_cast (f.empty() ? "0" : f) / fps); + + return t; + } +}; + +#endif