+2016-06-16 Carl Hetherington <cth@carlh.net>
+
+ * Remove seconds from KDM time period specification (#819).
+
2016-06-14 c.hetherington <cth@carlh.net>
* Basic guessing of audio channels from filenames (#393).
#include "kdm_timing_panel.h"
#include "wx_util.h"
+#include "time_picker.h"
#include <wx/datectrl.h>
-#include <wx/timectrl.h>
#include <wx/dateevt.h>
+using std::cout;
using boost::bind;
KDMTimingPanel::KDMTimingPanel (wxWindow* parent)
from.SetToCurrent ();
_from_date = new wxDatePickerCtrl (this, wxID_ANY, from);
table->Add (_from_date, 1, wxEXPAND);
- _from_time = new wxTimePickerCtrl (this, wxID_ANY, from);
- table->Add (_from_time, 1, wxEXPAND);
+ _from_time = new TimePicker (this, from);
+ table->Add (_from_time, 0);
add_label_to_sizer (table, this, _("until"), true);
wxDateTime to = from;
to.Add (wxDateSpan (0, 0, 1, 0));
_until_date = new wxDatePickerCtrl (this, wxID_ANY, to);
table->Add (_until_date, 1, wxEXPAND);
- _until_time = new wxTimePickerCtrl (this, wxID_ANY, to);
- table->Add (_until_time, 1, wxEXPAND);
+ _until_time = new TimePicker (this, to);
+ table->Add (_until_time, 0);
overall_sizer->Add (table);
_from_date->Bind (wxEVT_DATE_CHANGED, bind (&KDMTimingPanel::changed, this));
_until_date->Bind (wxEVT_DATE_CHANGED, bind (&KDMTimingPanel::changed, this));
- _from_time->Bind (wxEVT_TIME_CHANGED, bind (&KDMTimingPanel::changed, this));
- _until_time->Bind (wxEVT_TIME_CHANGED, bind (&KDMTimingPanel::changed, this));
+ _from_time->Changed.connect (bind (&KDMTimingPanel::changed, this));
+ _until_time->Changed.connect (bind (&KDMTimingPanel::changed, this));
SetSizer (overall_sizer);
}
}
boost::posix_time::ptime
-KDMTimingPanel::posix_time (wxDatePickerCtrl* date_picker, wxTimePickerCtrl* time_picker)
+KDMTimingPanel::posix_time (wxDatePickerCtrl* date_picker, TimePicker* time_picker)
{
wxDateTime const date = date_picker->GetValue ();
- wxDateTime const time = time_picker->GetValue ();
return boost::posix_time::ptime (
boost::gregorian::date (date.GetYear(), date.GetMonth() + 1, date.GetDay()),
- boost::posix_time::time_duration (time.GetHour(), time.GetMinute(), time.GetSecond())
+ boost::posix_time::time_duration (time_picker->hours(), time_picker->minutes(), 0)
);
}
#include <boost/signals2.hpp>
class wxDatePickerCtrl;
-class wxTimePickerCtrl;
+class TimePicker;
class KDMTimingPanel : public wxPanel
{
private:
void changed () const;
- static boost::posix_time::ptime posix_time (wxDatePickerCtrl *, wxTimePickerCtrl *);
+ static boost::posix_time::ptime posix_time (wxDatePickerCtrl *, TimePicker *);
wxDatePickerCtrl* _from_date;
wxDatePickerCtrl* _until_date;
- wxTimePickerCtrl* _from_time;
- wxTimePickerCtrl* _until_time;
+ TimePicker* _from_time;
+ TimePicker* _until_time;
wxStaticText* _warning;
};
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "time_picker.h"
+#include "lib/raw_convert.h"
+#include <wx/spinctrl.h>
+#include <boost/bind.hpp>
+#include <iomanip>
+
+using std::setfill;
+using std::setw;
+using std::min;
+using std::max;
+using std::string;
+using std::cout;
+using boost::bind;
+
+TimePicker::TimePicker (wxWindow* parent, wxDateTime time)
+ : wxPanel (parent)
+ , _block_update (false)
+{
+ wxClientDC dc (parent);
+ wxSize size = dc.GetTextExtent (wxT ("9999"));
+ size.SetHeight (-1);
+
+ wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
+ _hours = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
+ _hours->SetMaxLength (2);
+ sizer->Add (_hours, 0);
+ _hours_spin = new wxSpinButton (this, wxID_ANY);
+ sizer->Add (_hours_spin, 0, wxLEFT | wxRIGHT, 2);
+ sizer->Add (new wxStaticText (this, wxID_ANY, wxT (":")), 0, wxALIGN_CENTER_VERTICAL);
+ _minutes = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, size);
+ _minutes->SetMaxLength (2);
+ sizer->Add (_minutes, 0);
+ _minutes_spin = new wxSpinButton (this, wxID_ANY);
+ sizer->Add (_minutes_spin, 0, wxLEFT | wxRIGHT, 2);
+
+ SetSizerAndFit (sizer);
+
+ _minutes->MoveAfterInTabOrder (_hours);
+
+ _hours_spin->SetValue (time.GetHour ());
+ _hours_spin->SetRange (0, 23);
+ _minutes_spin->SetValue (time.GetMinute ());
+ _minutes_spin->SetRange (0, 59);
+
+ update_text ();
+
+ _hours->Bind (wxEVT_COMMAND_TEXT_UPDATED, (bind (&TimePicker::update_spin, this)));
+ _minutes->Bind (wxEVT_COMMAND_TEXT_UPDATED, (bind (&TimePicker::update_spin, this)));
+ _hours_spin->Bind (wxEVT_SPIN, bind (&TimePicker::update_text, this));
+ _minutes_spin->Bind (wxEVT_SPIN, bind (&TimePicker::update_text, this));
+}
+
+void
+TimePicker::update_text ()
+{
+ if (_block_update) {
+ return;
+ }
+
+ _block_update = true;
+
+ _hours->SetValue (wxString (raw_convert<string> (_hours_spin->GetValue ())));
+
+ SafeStringStream m;
+ m << setfill('0') << setw(2) << _minutes_spin->GetValue();
+ _minutes->SetValue (wxString (m.str()));
+
+ _block_update = false;
+
+ Changed ();
+}
+
+void
+TimePicker::update_spin ()
+{
+ if (_block_update) {
+ return;
+ }
+
+ _block_update = true;
+ _hours_spin->SetValue (raw_convert<int> (_hours->GetValue().ToStdString()));
+ _minutes_spin->SetValue (raw_convert<int> (_minutes->GetValue().ToStdString()));
+ _block_update = false;
+
+ Changed ();
+}
+
+int
+TimePicker::hours () const
+{
+ return _hours_spin->GetValue();
+}
+
+int
+TimePicker::minutes () const
+{
+ return _minutes_spin->GetValue();
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <wx/wx.h>
+#include <boost/signals2.hpp>
+
+class wxTextCtrl;
+class wxSpinButton;
+
+class TimePicker : public wxPanel
+{
+public:
+ TimePicker (wxWindow* parent, wxDateTime time);
+
+ int hours () const;
+ int minutes () const;
+
+ boost::signals2::signal<void ()> Changed;
+
+private:
+ void update_spin ();
+ void update_text ();
+
+ wxTextCtrl* _hours;
+ wxSpinButton* _hours_spin;
+ wxTextCtrl* _minutes;
+ wxSpinButton* _minutes_spin;
+
+ bool _block_update;
+};
system_font_dialog.cc
table_dialog.cc
text_subtitle_appearance_dialog.cc
+ time_picker.cc
timecode.cc
timeline.cc
timeline_atmos_content_view.cc