From 40e113d3681befd0daf39d5a9aee9f284ca21a19 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 13 Jan 2007 22:33:02 +0000 Subject: [PATCH] Visual typesetting new strips relevant tags before applying changes. Originally committed to SVN as r787. --- aegisub/ass_dialogue.cpp | 31 +++++++++++++++++++++++++++++++ aegisub/ass_dialogue.h | 13 +++++++------ aegisub/video_display_visual.cpp | 13 +++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/aegisub/ass_dialogue.cpp b/aegisub/ass_dialogue.cpp index 8cf1789c2..9ae987d36 100644 --- a/aegisub/ass_dialogue.cpp +++ b/aegisub/ass_dialogue.cpp @@ -579,6 +579,37 @@ void AssDialogue::StripTags () { } +//////////////////////// +// Strip a specific tag +void AssDialogue::StripTag (wxString tagName) { + // Parse + using std::list; + using std::vector; + ParseASSTags(); + wxString final; + + // Look for blocks + for (vector::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) { + if ((*cur)->type == BLOCK_OVERRIDE) { + AssDialogueBlockOverride *over = AssDialogueBlock::GetAsOverride(*cur); + wxString temp; + for (size_t i=0;iTags.size();i++) { + if (over->Tags[i]->Name != tagName) temp += over->Tags[i]->ToString(); + } + + // Insert + if (!temp.IsEmpty()) final += _T("{") + temp + _T("}"); + } + else final += (*cur)->GetText(); + } + + // Update + ClearBlocks(); + Text = final; + UpdateData(); +} + + /////////////////////// // Convert tags to SRT // ------------------- diff --git a/aegisub/ass_dialogue.h b/aegisub/ass_dialogue.h index ccc414522..cfba97696 100644 --- a/aegisub/ass_dialogue.h +++ b/aegisub/ass_dialogue.h @@ -181,22 +181,23 @@ public: bool Parse(wxString data,int version=1); // Parses raw ASS data into everything else void ParseASSTags(); // Parses text to generate block information (doesn't update data) void ParseSRTTags(); // Converts tags to ass format and calls ParseASSTags+UpdateData + void ConvertTagsToSRT(); // Converts tags to SRT format + void StripTags(); // Strips all tags from the text + void StripTag(wxString tagName);// Strips a specific tag from the text + void ClearBlocks(); // Clear all blocks, ALWAYS call this after you're done processing tags + void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *userData),void *userData=NULL); // Callback to process parameters + wxString GetStrippedText(); // Gets text without tags void UpdateData(); // Updates raw data from current values + text void UpdateText(); // Generates text from the override tags const wxString GetEntryData(); void SetEntryData(wxString newData); - - void ConvertTagsToSRT(); // Converts tags to SRT format - void StripTags(); // Strips all tags from the text void Clear(); // Wipes all data + void SetMarginString(const wxString value,int which); // Set string to a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom) wxString GetMarginString(int which,bool pad=true); // Returns the string of a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom) - void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *userData),void *userData=NULL); // Callback to process parameters wxString GetSSAText(); bool CollidesWith(AssDialogue *target); // Checks if two lines collide - void ClearBlocks(); - wxString GetStrippedText(); AssEntry *Clone(); diff --git a/aegisub/video_display_visual.cpp b/aegisub/video_display_visual.cpp index c0ad3d233..148a19138 100644 --- a/aegisub/video_display_visual.cpp +++ b/aegisub/video_display_visual.cpp @@ -913,6 +913,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { if (mode == 1) { startX = x; startY = y; + curSelection->StripTag(_T("\\pos")); + curSelection->StripTag(_T("\\move")); } // Rotate Z @@ -921,6 +923,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { GetLineRotation(curSelection,rx,ry,rz); origAngle = rz; curAngle = rz; + curSelection->StripTag(_T("\\frz")); + curSelection->StripTag(_T("\\fr")); } // Rotate XY @@ -932,6 +936,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { origAngle2 = ry; curAngle = rx; curAngle2 = ry; + curSelection->StripTag(_T("\\frx")); + curSelection->StripTag(_T("\\fry")); } // Scale @@ -945,14 +951,21 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { origScaleY = scalY; curScaleX = scalX; curScaleY = scalY; + curSelection->StripTag(_T("\\fscx")); + curSelection->StripTag(_T("\\fscy")); } // Clip if (mode == 5) { startX = x; startY = y; + curSelection->StripTag(_T("\\clip")); } + // Commit changes to edit box + grid->editBox->TextEdit->SetTextTo(curSelection->Text); + grid->editBox->CommitText(true); + // Hold it holding = true; hold = mode;