X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftimecode.h;h=45a421c4d71774d5ad76eb161f8a842e57a6efb5;hb=e60bb3e51bd1508b149e6b8f6608f09b5196ae26;hp=72b00ddeb4867065943d41b7ca41ad1295d632a8;hpb=22b9f3b2090d8bdfe52cda1e69d3acbe874f1ce5;p=dcpomatic.git diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 72b00ddeb..45a421c4d 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2015 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,27 +17,32 @@ */ -#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: + static wxSize size (wxWindow* parent); + +protected: void changed (); void set_clicked (); - + wxSizer* _sizer; wxPanel* _editable; wxTextCtrl* _hours; @@ -48,3 +53,46 @@ private: wxStaticText* _fixed; }; +template +class Timecode : public TimecodeBase +{ +public: + Timecode (wxWindow* parent) + : TimecodeBase (parent) + { + + } + + void set (T t, float 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)); + + checked_set (_fixed, 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