diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index dc0d73180..6c9833a60 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -166,6 +166,8 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) , splitLineMode(false) , controlState(true) , c(context) +, commitId(-1) +, undoTimer(GetEventHandler()) { // Top controls wxArrayString styles; @@ -270,8 +272,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) MainSizer->Add(BottomSizer,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); // Set sizer - SetSizer(MainSizer); - MainSizer->SetSizeHints(this); + SetSizerAndFit(MainSizer); origBgColour = TextEdit->GetBackgroundColour(); disabledBgColour = GetBackgroundColour(); @@ -312,6 +313,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &SubsEditBox::OnCommentChange, this, CommentBox->GetId()); Bind(wxEVT_SIZE, &SubsEditBox::OnSize, this); + Bind(wxEVT_TIMER, &SubsEditBox::OnUndoTimer, this); for (int i = 0; i < 4; i++) { Bind(wxEVT_COMMAND_BUTTON_CLICKED, &SubsEditBox::OnFlagButton, this, BUTTON_FIRST + i); @@ -490,6 +492,10 @@ void SubsEditBox::OnChange(wxStyledTextEvent &event) { } } +void SubsEditBox::OnUndoTimer(wxTimerEvent&) { + commitId = -1; +} + template void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type, bool amend) { for_each(sel.begin(), sel.end(), bind(set, std::tr1::placeholders::_1, value)); @@ -498,6 +504,7 @@ void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type, commitId = c->ass->Commit(desc, type, (amend && desc == lastCommitType) ? commitId : -1, sel.size() == 1 ? *sel.begin() : 0); file_changed_slot.Unblock(); lastCommitType = desc; + undoTimer.Start(10000, wxTIMER_ONE_SHOT); } template diff --git a/aegisub/src/subs_edit_box.h b/aegisub/src/subs_edit_box.h index 844a9df7d..1893d03dc 100644 --- a/aegisub/src/subs_edit_box.h +++ b/aegisub/src/subs_edit_box.h @@ -38,6 +38,7 @@ #include #include +#include #endif #include @@ -130,6 +131,7 @@ class SubsEditBox : public wxPanel, protected SelectionListener { int timeCommitId[3]; int commitId; wxString lastCommitType; + wxTimer undoTimer; void OnChange(wxStyledTextEvent &event); void OnKeyDown(wxKeyEvent &event); @@ -151,6 +153,7 @@ class SubsEditBox : public wxPanel, protected SelectionListener { void OnCommentChange(wxCommandEvent &); void OnEffectChange(wxCommandEvent &); void OnSize(wxSizeEvent &event); + void OnUndoTimer(wxTimerEvent&); void OnFlagButton(wxCommandEvent &event); void OnColorButton(wxCommandEvent &event);