Implemented delete point function to vector clip tool.

Originally committed to SVN as r1388.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-07 07:27:28 +00:00
parent d1d8302548
commit ee832d642d
3 changed files with 38 additions and 12 deletions

View File

@ -175,8 +175,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
if (realTime) {
// Commit
CommitDrag(features[curFeature]);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
Commit();
}
}
@ -188,9 +187,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
// Commit
dragging = false;
CommitDrag(features[curFeature]);
grid->editBox->CommitText();
grid->ass->FlagAsModified(_("visual typesetting"));
grid->CommitChanges(false);
Commit(true);
// Clean up
curFeature = -1;
@ -227,8 +224,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
if (realTime) {
// Commit
CommitHold();
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
Commit();
}
}
@ -240,9 +236,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
// Commit
holding = false;
CommitHold();
grid->editBox->CommitText();
grid->ass->FlagAsModified(_("visual typesetting"));
grid->CommitChanges(false);
Commit(true);
// Clean up
curDiag = NULL;
@ -257,6 +251,16 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
}
//////////
// Commit
void VisualTool::Commit(bool full) {
SubtitlesGrid *grid = VideoContext::Get()->grid;
if (full) grid->editBox->CommitText();
grid->ass->FlagAsModified(_("visual typesetting"));
grid->CommitChanges(false,!full);
}
////////////////////////////
// Get active dialogue line
AssDialogue* VisualTool::GetActiveDialogueLine() {

View File

@ -115,6 +115,7 @@ protected:
AssDialogue *GetActiveDialogueLine();
int GetHighlightedFeature();
void DrawAllFeatures();
void Commit(bool full=false);
void ConnectButton(wxButton *button);
virtual void OnButton(wxCommandEvent &event) {}

View File

@ -46,9 +46,9 @@ enum {
BUTTON_DRAG = VISUAL_SUB_TOOL_START,
BUTTON_LINE,
BUTTON_BICUBIC,
BUTTON_CONVERT,
BUTTON_INSERT,
BUTTON_REMOVE,
BUTTON_CONVERT,
BUTTON_FREEHAND,
BUTTON_FREEHAND_SMOOTH,
BUTTON_LAST // Leave this at the end and don't use it
@ -256,6 +256,27 @@ void VisualToolVectorClip::CommitDrag(VisualDraggableFeature &feature) {
/////////////////////
// Clicked a feature
void VisualToolVectorClip::ClickedFeature(VisualDraggableFeature &feature) {
// Delete a control point
if (mode == 5) {
int i = 0;
for (std::list<SplineCurve>::iterator cur=spline.curves.begin();cur!=spline.curves.end();i++,cur++) {
if (i == feature.value) {
// Update next
if (i != 0 || feature.value2 != 0) {
std::list<SplineCurve>::iterator next = cur;
next++;
if (next != spline.curves.end()) next->p1 = cur->p1;
}
// Erase and save changes
spline.curves.erase(cur);
SetOverride(_T("\\clip"),_T("(") + spline.EncodeToASS() + _T(")"));
curFeature = -1;
Commit(true);
return;
}
}
}
}
@ -375,7 +396,7 @@ void VisualToolVectorClip::DoRefresh() {
wxString vect;
int scale;
vect = GetLineVectorClip(line,scale);
if (vect.IsEmpty()) return;
//if (!vect.IsEmpty()) return;
spline.DecodeFromASS(vect);
PopulateFeatureList();
}