Refactor time ctrl handling in SubsEditBox
This commit is contained in:
parent
1b6f122d12
commit
0b46fdff49
2 changed files with 7 additions and 22 deletions
|
@ -128,10 +128,10 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
|
||||||
MiddleSizer->Add(Layer, wxSizerFlags().Center());
|
MiddleSizer->Add(Layer, wxSizerFlags().Center());
|
||||||
MiddleSizer->AddSpacer(5);
|
MiddleSizer->AddSpacer(5);
|
||||||
|
|
||||||
StartTime = MakeTimeCtrl(false, _("Start time"), &SubsEditBox::OnStartTimeChange);
|
StartTime = MakeTimeCtrl(_("Start time"), TIME_START);
|
||||||
EndTime = MakeTimeCtrl(true, _("End time"), &SubsEditBox::OnEndTimeChange);
|
EndTime = MakeTimeCtrl(_("End time"), TIME_END);
|
||||||
MiddleSizer->AddSpacer(5);
|
MiddleSizer->AddSpacer(5);
|
||||||
Duration = MakeTimeCtrl(false, _("Line duration"), &SubsEditBox::OnDurationChange);
|
Duration = MakeTimeCtrl(_("Line duration"), TIME_DURATION);
|
||||||
MiddleSizer->AddSpacer(5);
|
MiddleSizer->AddSpacer(5);
|
||||||
|
|
||||||
MarginL = MakeMarginCtrl(_("Left Margin (0 = default)"), &SubsEditBox::OnMarginLChange);
|
MarginL = MakeMarginCtrl(_("Left Margin (0 = default)"), &SubsEditBox::OnMarginLChange);
|
||||||
|
@ -210,10 +210,10 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, void (SubsEditB
|
||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeEdit *SubsEditBox::MakeTimeCtrl(bool end, wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&)) {
|
TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) {
|
||||||
TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(75,-1), end);
|
TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(75,-1), field == TIME_END);
|
||||||
ctrl->SetToolTip(tooltip);
|
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);
|
ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook);
|
||||||
MiddleSizer->Add(ctrl, wxSizerFlags().Center());
|
MiddleSizer->Add(ctrl, wxSizerFlags().Center());
|
||||||
return ctrl;
|
return ctrl;
|
||||||
|
@ -499,18 +499,6 @@ void SubsEditBox::OnLayerEnter(wxCommandEvent &) {
|
||||||
SetSelectedRows(&AssDialogue::Layer, Layer->GetValue(), _("layer change"), AssFile::COMMIT_DIAG_META);
|
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 &) {
|
void SubsEditBox::OnMarginLChange(wxCommandEvent &) {
|
||||||
SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<0>), MarginL->GetValue(), _("MarginL change"), AssFile::COMMIT_DIAG_META);
|
SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<0>), MarginL->GetValue(), _("MarginL change"), AssFile::COMMIT_DIAG_META);
|
||||||
if (line) change_value(MarginL, line->GetMarginString(0, false));
|
if (line) change_value(MarginL, line->GetMarginString(0, false));
|
||||||
|
|
|
@ -138,7 +138,7 @@ class SubsEditBox : public wxPanel {
|
||||||
|
|
||||||
// Constructor helpers
|
// Constructor helpers
|
||||||
wxTextCtrl *MakeMarginCtrl(wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&));
|
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);
|
void MakeButton(const char *cmd_name);
|
||||||
wxComboBox *MakeComboBox(wxString const& initial_text, int style, void (SubsEditBox::*handler)(wxCommandEvent&), wxString const& tooltip);
|
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);
|
wxRadioButton *MakeRadio(wxString const& text, bool start, wxString const& tooltip);
|
||||||
|
@ -153,9 +153,6 @@ class SubsEditBox : public wxPanel {
|
||||||
void OnStyleChange(wxCommandEvent &event);
|
void OnStyleChange(wxCommandEvent &event);
|
||||||
void OnActorChange(wxCommandEvent &event);
|
void OnActorChange(wxCommandEvent &event);
|
||||||
void OnLayerEnter(wxCommandEvent &event);
|
void OnLayerEnter(wxCommandEvent &event);
|
||||||
void OnStartTimeChange(wxCommandEvent &);
|
|
||||||
void OnEndTimeChange(wxCommandEvent &);
|
|
||||||
void OnDurationChange(wxCommandEvent &);
|
|
||||||
void OnMarginLChange(wxCommandEvent &);
|
void OnMarginLChange(wxCommandEvent &);
|
||||||
void OnMarginRChange(wxCommandEvent &);
|
void OnMarginRChange(wxCommandEvent &);
|
||||||
void OnMarginVChange(wxCommandEvent &);
|
void OnMarginVChange(wxCommandEvent &);
|
||||||
|
|
Loading…
Reference in a new issue