Visual typesetting new strips relevant tags before applying changes.

Originally committed to SVN as r787.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-13 22:33:02 +00:00
parent 956d1d0842
commit 40e113d368
3 changed files with 51 additions and 6 deletions

View File

@ -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<AssDialogueBlock*>::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;i<over->Tags.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
// -------------------

View File

@ -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();

View File

@ -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;