From d6e9c3f7302328b6ba5c64727bc9719c8a761290 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Wed, 4 Jul 2007 01:22:10 +0000 Subject: [PATCH] Fixed \move drag. Note to self: std::vector != std::list, iterators are not preserved after a push_back(). Originally committed to SVN as r1344. --- aegisub/visual_feature.cpp | 2 +- aegisub/visual_feature.h | 2 +- aegisub/visual_tool_drag.cpp | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/aegisub/visual_feature.cpp b/aegisub/visual_feature.cpp index 6b06a0101..b0a00ec01 100644 --- a/aegisub/visual_feature.cpp +++ b/aegisub/visual_feature.cpp @@ -50,7 +50,7 @@ VisualDraggableFeature::VisualDraggableFeature() { layer = 0; lineN = -1; line = NULL; - for (int i=0;i<4;i++) brother[i] = NULL; + for (int i=0;i<4;i++) brother[i] = -1; } diff --git a/aegisub/visual_feature.h b/aegisub/visual_feature.h index 8da54b2c7..2c63baaf2 100644 --- a/aegisub/visual_feature.h +++ b/aegisub/visual_feature.h @@ -70,7 +70,7 @@ public: AssDialogue *line; int lineN; - VisualDraggableFeature *brother[4]; + int brother[4]; bool IsMouseOver(int x,int y); void Draw(OpenGLWrapper *gl); diff --git a/aegisub/visual_tool_drag.cpp b/aegisub/visual_tool_drag.cpp index 356c76265..095c98e0d 100644 --- a/aegisub/visual_tool_drag.cpp +++ b/aegisub/visual_tool_drag.cpp @@ -72,11 +72,11 @@ void VisualToolDrag::Draw() { // Draw arrows for (size_t i=0;ibrother[0]; + p2 = &features[p1->brother[0]]; // See if the distance between them is at least 30 pixels int dx = p2->x - p1->x; @@ -154,11 +154,12 @@ void VisualToolDrag::PopulateFeatureList() { feat.value = t2; feat.line = diag; feat.lineN = i; - - // Add each other as brothers. Yes, this looks weird. - feat.brother[0] = &features.back(); features.push_back(feat); - feat.brother[0]->brother[0] = &features.back(); + + // Add each other as brothers. + int n = features.size(); + features[n-1].brother[0] = n-2; + features[n-2].brother[0] = n-1; } } } @@ -176,7 +177,6 @@ void VisualToolDrag::InitializeDrag(VisualDraggableFeature &feature) { // Update drag void VisualToolDrag::UpdateDrag(VisualDraggableFeature &feature) { // Update "value" to reflect the time of the frame in which the feature is being dragged - int frame_n = VideoContext::Get()->GetFrameN(); int time = VFR_Output.GetTimeAtFrame(frame_n,true,true); feature.value = MID(0,time - feature.line->Start.GetMS(),feature.line->End.GetMS()-feature.line->Start.GetMS()); } @@ -186,7 +186,7 @@ void VisualToolDrag::UpdateDrag(VisualDraggableFeature &feature) { // Commit drag void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { // Position - if (feature.brother[0] == NULL) { + if (feature.brother[0] == -1) { SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),feature.x,feature.y)); } @@ -195,8 +195,8 @@ void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { // Get source on p1 and dest on p2 VisualDraggableFeature *p1,*p2; p1 = &feature; - if (p1->type == DRAG_BIG_CIRCLE) p1 = p1->brother[0]; - p2 = p1->brother[0]; + if (p1->type == DRAG_BIG_CIRCLE) p1 = &features[p1->brother[0]]; + p2 = &features[p1->brother[0]]; // Set override SetOverride(_T("\\move"),wxString::Format(_T("(%i,%i,%i,%i,%i,%i)"),p1->x,p1->y,p2->x,p2->y,p1->value,p2->value));