Refactor time ctrl handling in SubsEditBox

This commit is contained in:
Thomas Goyne 2012-12-02 07:36:24 -08:00
parent 1b6f122d12
commit 0b46fdff49
2 changed files with 7 additions and 22 deletions

View File

@ -128,10 +128,10 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
MiddleSizer->Add(Layer, wxSizerFlags().Center());
MiddleSizer->AddSpacer(5);
StartTime = MakeTimeCtrl(false, _("Start time"), &SubsEditBox::OnStartTimeChange);
EndTime = MakeTimeCtrl(true, _("End time"), &SubsEditBox::OnEndTimeChange);
StartTime = MakeTimeCtrl(_("Start time"), TIME_START);
EndTime = MakeTimeCtrl(_("End time"), TIME_END);
MiddleSizer->AddSpacer(5);
Duration = MakeTimeCtrl(false, _("Line duration"), &SubsEditBox::OnDurationChange);
Duration = MakeTimeCtrl(_("Line duration"), TIME_DURATION);
MiddleSizer->AddSpacer(5);
MarginL = MakeMarginCtrl(_("Left Margin (0 = default)"), &SubsEditBox::OnMarginLChange);
@ -210,10 +210,10 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, void (SubsEditB
return ctrl;
}
TimeEdit *SubsEditBox::MakeTimeCtrl(bool end, wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&)) {
TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(75,-1), end);
TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) {
TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(75,-1), field == TIME_END);
ctrl->SetToolTip(tooltip);
Bind(wxEVT_COMMAND_TEXT_UPDATED, handler, this, ctrl->GetId());
Bind(wxEVT_COMMAND_TEXT_UPDATED, [=](wxCommandEvent&) { CommitTimes(field); }, ctrl->GetId());
ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook);
MiddleSizer->Add(ctrl, wxSizerFlags().Center());
return ctrl;
@ -499,18 +499,6 @@ void SubsEditBox::OnLayerEnter(wxCommandEvent &) {
SetSelectedRows(&AssDialogue::Layer, Layer->GetValue(), _("layer change"), AssFile::COMMIT_DIAG_META);
}
void SubsEditBox::OnStartTimeChange(wxCommandEvent &) {
CommitTimes(TIME_START);
}
void SubsEditBox::OnEndTimeChange(wxCommandEvent &) {
CommitTimes(TIME_END);
}
void SubsEditBox::OnDurationChange(wxCommandEvent &) {
CommitTimes(TIME_DURATION);
}
void SubsEditBox::OnMarginLChange(wxCommandEvent &) {
SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<0>), MarginL->GetValue(), _("MarginL change"), AssFile::COMMIT_DIAG_META);
if (line) change_value(MarginL, line->GetMarginString(0, false));

View File

@ -138,7 +138,7 @@ class SubsEditBox : public wxPanel {
// Constructor helpers
wxTextCtrl *MakeMarginCtrl(wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&));
TimeEdit *MakeTimeCtrl(bool end, wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&));
TimeEdit *MakeTimeCtrl(wxString const& tooltip, TimeField field);
void MakeButton(const char *cmd_name);
wxComboBox *MakeComboBox(wxString const& initial_text, int style, void (SubsEditBox::*handler)(wxCommandEvent&), wxString const& tooltip);
wxRadioButton *MakeRadio(wxString const& text, bool start, wxString const& tooltip);
@ -153,9 +153,6 @@ class SubsEditBox : public wxPanel {
void OnStyleChange(wxCommandEvent &event);
void OnActorChange(wxCommandEvent &event);
void OnLayerEnter(wxCommandEvent &event);
void OnStartTimeChange(wxCommandEvent &);
void OnEndTimeChange(wxCommandEvent &);
void OnDurationChange(wxCommandEvent &);
void OnMarginLChange(wxCommandEvent &);
void OnMarginRChange(wxCommandEvent &);
void OnMarginVChange(wxCommandEvent &);