From 582500e9e60286b11efab137ca76402b25c188fa Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 27 Jun 2006 04:13:34 +0000 Subject: [PATCH] - Text edit boxes in the subtitle editing area will now revert to unmodified if you restore the original text. (AMZ) - Re-arranged the controls in the subtitle editing area. (AMZ) Originally committed to SVN as r428. --- core/changelog.txt | 3 ++ core/hilimod_textctrl.cpp | 15 ++++++++- core/hilimod_textctrl.h | 2 ++ core/subs_edit_box.cpp | 68 +++++++++++++++++++++++++++------------ core/subs_edit_box.h | 3 ++ 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/core/changelog.txt b/core/changelog.txt index bfc41bf94..fda995ec3 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -80,6 +80,9 @@ Please visit http://aegisub.net to download latest version - Style editor now uses a dropdown for the encoding field. (AMZ) - Added 2.35 and custom aspect ratio support for video display. (AMZ) - The manual has been extensively re-written and extended to include documentation about a lot of new (and some not so new) features. It's reasonably complete... for the moment. (TheFluff, Motoko-chan, AMZ, others) +- Text edit boxes in the subtitle editing area will now revert to unmodified if you restore the original text. (AMZ) +- Re-arranged the controls in the subtitle editing area. (AMZ) + = 1.09 beta - 2006.01.16 =========================== diff --git a/core/hilimod_textctrl.cpp b/core/hilimod_textctrl.cpp index 83aa4d346..b85675d0e 100644 --- a/core/hilimod_textctrl.cpp +++ b/core/hilimod_textctrl.cpp @@ -47,6 +47,7 @@ wxTextCtrl(parent,id,value,pos,size,style,validator,name) { UpdateLocked = false; isModified = false; + orig = GetValue(); Connect(wxEVT_COMMAND_TEXT_UPDATED,wxCommandEventHandler(HiliModTextCtrl::OnModified)); } @@ -65,6 +66,7 @@ void HiliModTextCtrl::OnModified(wxCommandEvent &event) { // Commited event void HiliModTextCtrl::Commited() { if (isModified) { + orig = GetValue(); SetBackgroundColour(wxNullColour); Refresh(false); isModified = false; @@ -76,6 +78,7 @@ void HiliModTextCtrl::Commited() { // Set value void HiliModTextCtrl::SetValue(const wxString& value) { UpdateLocked = true; + orig = value; wxTextCtrl::SetValue(value); Commited(); UpdateLocked = false; @@ -85,9 +88,19 @@ void HiliModTextCtrl::SetValue(const wxString& value) { //////////////// // Was modified void HiliModTextCtrl::Modified() { - if (!isModified) { + bool match = GetValue() == orig; + + // Different from original + if (!isModified && !match) { isModified = true; SetBackgroundColour(Options.AsColour(_T("Edit Box Need Enter Background"))); Refresh(false); } + + // Same as original + if (isModified && match) { + SetBackgroundColour(wxNullColour); + Refresh(false); + isModified = false; + } } diff --git a/core/hilimod_textctrl.h b/core/hilimod_textctrl.h index d69b35c22..c0e2c1b56 100644 --- a/core/hilimod_textctrl.h +++ b/core/hilimod_textctrl.h @@ -50,6 +50,8 @@ private: bool UpdateLocked; bool isModified; + wxString orig; + void OnModified(wxCommandEvent &event); void OnKey(wxKeyEvent &event); diff --git a/core/subs_edit_box.cpp b/core/subs_edit_box.cpp index 61d00b8f9..bee5f58b9 100644 --- a/core/subs_edit_box.cpp +++ b/core/subs_edit_box.cpp @@ -109,25 +109,6 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren //SyntaxHighlight->SetToolTip(_("Enable syntax highlighting")); //SyntaxHighlight->SetValue(Options.AsBool(_T("Syntax Highlight Enabled"))); - // Top sizer - wxSizer *TopSizer = new wxBoxSizer(wxHORIZONTAL); - TopSizer->Add(CommentBox,0,wxRIGHT | wxALIGN_CENTER,5); - TopSizer->Add(StyleBox,0,wxRIGHT,5); - TopSizer->Add(ActorBox,0,wxRIGHT,5); - TopSizer->Add(MarginL,0,0,0); - TopSizer->Add(MarginR,0,0,0); - TopSizer->Add(MarginV,0,0,0); - - // Middle sizer - wxSizer *MiddleSizer = new wxBoxSizer(wxHORIZONTAL); - MiddleSizer->Add(Layer,0,wxRIGHT,5); - MiddleSizer->Add(StartTime,0,wxRIGHT,0); - MiddleSizer->Add(EndTime,0,wxRIGHT,5); - MiddleSizer->Add(Duration,0,wxRIGHT,5); - MiddleSizer->Add(ByTime,0,wxRIGHT | wxALIGN_CENTER,5); - MiddleSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER,5); - //MiddleSizer->Add(SyntaxHighlight,0,wxRIGHT | wxALIGN_CENTER,5); - // Middle-bottom controls Bold = new wxBitmapButton(this,BUTTON_BOLD,wxBITMAP(button_bold),wxDefaultPosition,wxSize(20,20)); Bold->SetToolTip(_("Bold")); @@ -147,6 +128,26 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren Color3->SetToolTip(_("Outline color")); Color4 = new wxBitmapButton(this,BUTTON_COLOR4,wxBITMAP(button_color4),wxDefaultPosition,wxSize(30,20)); Color4->SetToolTip(_("Shadow color")); + Effect = new HiliModTextCtrl(this,EFFECT_BOX,_T(""),wxDefaultPosition,wxSize(120,20),0); + Effect->SetToolTip(_("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); + + // Top sizer + wxSizer *TopSizer = new wxBoxSizer(wxHORIZONTAL); + TopSizer->Add(CommentBox,0,wxRIGHT | wxALIGN_CENTER,5); + TopSizer->Add(StyleBox,0,wxRIGHT,5); + TopSizer->Add(ActorBox,0,wxRIGHT,5); + TopSizer->Add(Effect,0,0,0); + + // Middle sizer + wxSizer *MiddleSizer = new wxBoxSizer(wxHORIZONTAL); + MiddleSizer->Add(Layer,0,wxRIGHT,5); + MiddleSizer->Add(StartTime,0,wxRIGHT,0); + MiddleSizer->Add(EndTime,0,wxRIGHT,5); + MiddleSizer->Add(Duration,0,wxRIGHT,5); + MiddleSizer->Add(MarginL,0,0,0); + MiddleSizer->Add(MarginR,0,0,0); + MiddleSizer->Add(MarginV,0,0,0); + //MiddleSizer->Add(SyntaxHighlight,0,wxRIGHT | wxALIGN_CENTER,5); // Middle-bottom sizer wxSizer *MiddleBotSizer = new wxBoxSizer(wxHORIZONTAL); @@ -159,7 +160,9 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren MiddleBotSizer->Add(Color1); MiddleBotSizer->Add(Color2); MiddleBotSizer->Add(Color3); - MiddleBotSizer->Add(Color4); + MiddleBotSizer->Add(Color4,0,wxRIGHT,10); + MiddleBotSizer->Add(ByTime,0,wxRIGHT | wxALIGN_CENTER,5); + MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER,5); // Text editor TextEdit = new SubsTextEditCtrl(this,EDIT_BOX,_T(""),wxDefaultPosition,wxSize(300,50),wxTE_MULTILINE | wxTE_RICH2 | wxTE_NOHIDESEL); @@ -205,6 +208,7 @@ void SubsEditBox::Update (bool timeOnly) { MarginL->SetValue(curdiag->GetMarginString(1)); MarginR->SetValue(curdiag->GetMarginString(2)); MarginV->SetValue(curdiag->GetMarginString(3)); + Effect->SetValue(curdiag->Effect); CommentBox->SetValue(curdiag->Comment); StyleBox->Select(StyleBox->FindString(curdiag->Style)); ActorBox->SetValue(curdiag->Actor); @@ -434,6 +438,7 @@ BEGIN_EVENT_TABLE(SubsEditBox, wxPanel) EVT_TEXT_ENTER(MARGINL_BOX, SubsEditBox::OnMarginLChange) EVT_TEXT_ENTER(MARGINR_BOX, SubsEditBox::OnMarginRChange) EVT_TEXT_ENTER(MARGINV_BOX, SubsEditBox::OnMarginVChange) + EVT_TEXT_ENTER(EFFECT_BOX, SubsEditBox::OnEffectChange) EVT_CHECKBOX(COMMENT_CHECKBOX, SubsEditBox::OnCommentChange) EVT_MENU(EDIT_MENU_SPLIT_PRESERVE,SubsEditBox::OnSplitLinePreserve) @@ -526,6 +531,7 @@ void SubsEditBox::SetControlsState (bool state) { MarginL->Enable(state); MarginR->Enable(state); MarginV->Enable(state); + Effect->Enable(state); CommentBox->Enable(state); StyleBox->Enable(state); ActorBox->Enable(state); @@ -552,6 +558,7 @@ void SubsEditBox::SetControlsState (bool state) { MarginL->SetValue(_T("")); MarginR->SetValue(_T("")); MarginV->SetValue(_T("")); + Effect->SetValue(_T("")); CommentBox->SetValue(false); } } @@ -782,6 +789,27 @@ void SubsEditBox::OnMarginVChange(wxCommandEvent &event) { } +////////////////// +// Effect changed +void SubsEditBox::OnEffectChange(wxCommandEvent &event) { + Effect->Commited(); + grid->BeginBatch(); + wxArrayInt sel = grid->GetSelection(); + int n = sel.Count(); + AssDialogue *cur; + for (int i=0;iGetDialogue(sel[i]); + if (cur) { + cur->Effect = Effect->GetValue(); + cur->UpdateData(); + } + } + grid->ass->FlagAsModified(); + grid->CommitChanges(); + grid->EndBatch(); +} + + ///////////////////////// // Comment state changed void SubsEditBox::OnCommentChange(wxCommandEvent &event) { diff --git a/core/subs_edit_box.h b/core/subs_edit_box.h index 9d6f3692b..03bee736d 100644 --- a/core/subs_edit_box.h +++ b/core/subs_edit_box.h @@ -87,6 +87,7 @@ private: HiliModTextCtrl *MarginL; HiliModTextCtrl *MarginR; HiliModTextCtrl *MarginV; + HiliModTextCtrl *Effect; wxRadioButton *ByTime; wxRadioButton *ByFrame; wxCheckBox *SyntaxHighlight; @@ -131,6 +132,7 @@ private: void OnMarginRChange(wxCommandEvent &event); void OnMarginVChange(wxCommandEvent &event); void OnCommentChange(wxCommandEvent &event); + void OnEffectChange(wxCommandEvent &event); void OnSplitLinePreserve(wxCommandEvent &event); void OnSplitLineEstimate(wxCommandEvent &event); @@ -192,6 +194,7 @@ enum { MARGINL_BOX, MARGINR_BOX, MARGINV_BOX, + EFFECT_BOX, COMMENT_CHECKBOX, EDIT_MENU_SPLIT_PRESERVE, EDIT_MENU_SPLIT_ESTIMATE,