From 577295495e67ba22f1335e70de51c7d2bdb22d04 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Wed, 25 Apr 2007 04:31:36 +0000 Subject: [PATCH] Commiting text now commits times as well. Originally committed to SVN as r1141. --- aegisub/changelog.txt | 1 + aegisub/subs_edit_box.cpp | 33 ++++++++++++++++++++++----------- aegisub/subs_edit_box.h | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index 28d6c3b68..5b9901a2f 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -116,6 +116,7 @@ Please visit http://aegisub.net to download latest version - Fixed drawing of inactive lines in audio display to prevent it from being drawn over selection. (AMZ) - Style Editor dialog was redesigned to be more horizontal. (AMZ) - Style Editor dialog received a realtime styles preview box. (AMZ) +- Commiting text now commits times as well. (AMZ) = 1.10 beta - 2006.08.07 =========================== diff --git a/aegisub/subs_edit_box.cpp b/aegisub/subs_edit_box.cpp index 27e50af46..cb3fd9011 100644 --- a/aegisub/subs_edit_box.cpp +++ b/aegisub/subs_edit_box.cpp @@ -627,6 +627,7 @@ void SubsEditBox::OnStartTimeChange(wxCommandEvent &event) { if (StartTime->time > EndTime->time) StartTime->SetTime(EndTime->time.GetMS()); bool join = Options.AsBool(_T("Link Time Boxes Commit")) && EndTime->HasBeenModified(); StartTime->Update(); + Duration->Update(); if (join) EndTime->Update(); CommitTimes(true,join,true); } @@ -638,6 +639,7 @@ void SubsEditBox::OnEndTimeChange(wxCommandEvent &event) { if (StartTime->time > EndTime->time) EndTime->SetTime(StartTime->time.GetMS()); bool join = Options.AsBool(_T("Link Time Boxes Commit")) && StartTime->HasBeenModified(); EndTime->Update(); + Duration->Update(); if (join) StartTime->Update(); CommitTimes(join,true,false); } @@ -647,6 +649,8 @@ void SubsEditBox::OnEndTimeChange(wxCommandEvent &event) { // Duration changed void SubsEditBox::OnDurationChange(wxCommandEvent &event) { EndTime->SetTime(StartTime->time.GetMS() + Duration->time.GetMS()); + StartTime->Update(); + EndTime->Update(); Duration->Update(); CommitTimes(false,true,true); } @@ -654,10 +658,9 @@ void SubsEditBox::OnDurationChange(wxCommandEvent &event) { /////////////////////// // Commit time changes -void SubsEditBox::CommitTimes(bool start,bool end,bool fromStart) { +void SubsEditBox::CommitTimes(bool start,bool end,bool fromStart,bool commit) { // Get selection if (!start && !end) return; - grid->BeginBatch(); wxArrayInt sel = grid->GetSelection(); int n = sel.Count(); if (n == 0) return; @@ -677,18 +680,16 @@ void SubsEditBox::CommitTimes(bool start,bool end,bool fromStart) { if (fromStart) cur->End = cur->Start; else cur->Start = cur->End; } - - // Update - cur->UpdateData(); } } // Commit - grid->ass->FlagAsModified(_("commit times")); - grid->CommitChanges(); - grid->EndBatch(); - audio->SetDialogue(grid,grid->GetDialogue(sel[0]),sel[0]); - VideoContext::Get()->UpdateDisplays(false); + if (commit) { + grid->ass->FlagAsModified(_("modify times")); + grid->CommitChanges(); + audio->SetDialogue(grid,grid->GetDialogue(sel[0]),sel[0]); + VideoContext::Get()->UpdateDisplays(false); + } } @@ -866,8 +867,18 @@ void SubsEditBox::CommitText(bool weak) { // Update line if (cur) { + // Update text cur->Text = TextEdit->GetText(); - cur->UpdateData(); + + // Update times + cur->Start = StartTime->time; + cur->End = EndTime->time; + if (cur->Start > cur->End) cur->End = cur->Start; + StartTime->Update(); + EndTime->Update(); + Duration->Update(); + + // Update audio if (!weak) { grid->Refresh(false); audio->SetDialogue(grid,cur,linen); diff --git a/aegisub/subs_edit_box.h b/aegisub/subs_edit_box.h index 06d10ea62..6eba702a5 100644 --- a/aegisub/subs_edit_box.h +++ b/aegisub/subs_edit_box.h @@ -103,7 +103,7 @@ private: wxSizer *BottomSizer; void SetControlsState(bool state); - void CommitTimes(bool start,bool end,bool fromStart); + void CommitTimes(bool start,bool end,bool fromStart,bool commit=true); int BlockAtPos(int pos);