Fixed \move drag. Note to self: std::vector != std::list, iterators are not preserved after a push_back().

Originally committed to SVN as r1344.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-04 01:22:10 +00:00
parent 7554bd373b
commit d6e9c3f730
3 changed files with 12 additions and 12 deletions

View File

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

View File

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

View File

@ -72,11 +72,11 @@ void VisualToolDrag::Draw() {
// Draw arrows
for (size_t i=0;i<features.size();i++) {
if (features[i].brother[0] != NULL && features[i].type == DRAG_BIG_SQUARE) {
if (features[i].brother[0] != -1 && features[i].type == DRAG_BIG_SQUARE) {
// Get features
VisualDraggableFeature *p1,*p2;
p1 = &features[i];
p2 = p1->brother[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));