Also update origins when setting multiple lines with the drag tool. Updates #513

Originally committed to SVN as r4361.
This commit is contained in:
Thomas Goyne 2010-05-26 07:17:28 +00:00
parent 5283c1527b
commit acc1e93728

View file

@ -240,7 +240,7 @@ void VisualToolDrag::PopulateFeatureList() {
} }
} }
bool VisualToolDrag::InitializeDrag(VisualToolDragDraggableFeature *feature) { bool VisualToolDrag::InitializeDrag(VisualToolDragDraggableFeature *feature) {
if (feature->type != DRAG_ORIGIN) primary = feature; primary = feature;
return true; return true;
} }
@ -311,22 +311,27 @@ void VisualToolDrag::Update() {
for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
AssDialogue* line = grid->GetDialogue(*cur); AssDialogue* line = grid->GetDialogue(*cur);
if (!line) continue; if (!line) continue;
int x1, y1, x2, y2, t1 = INT_MIN, t2 = INT_MIN; int x1 = 0, y1 = 0, x2 = 0, y2 = 0, t1 = INT_MIN, t2 = INT_MIN, orgx, orgy;
bool isMove; bool isMove;
GetLinePosition(line, x1, y1, orgx, orgy);
GetLineMove(line, isMove, x1, y1, x2, y2, t1, t2); GetLineMove(line, isMove, x1, y1, x2, y2, t1, t2);
if (isMove) {
parent->ToScriptCoords(&x1, &y1); parent->ToScriptCoords(&x1, &y1);
parent->ToScriptCoords(&x2, &y2); parent->ToScriptCoords(&x2, &y2);
parent->ToScriptCoords(&orgx, &orgy);
if (isMove) {
if (t1 > INT_MIN && t2 > INT_MIN) if (t1 > INT_MIN && t2 > INT_MIN)
SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1 - dx, y1 - dy, x2 - dx, y2 - dy, t1, t2)); SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1 - dx, y1 - dy, x2 - dx, y2 - dy, t1, t2));
else else
SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i)", x1, y1, x2, y2)); SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i)", x1, y1, x2, y2));
} }
else { else {
GetLinePosition(line, x1, y1);
parent->ToScriptCoords(&x1, &y1);
SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy)); SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy));
} }
if (orgx != x1 || orgy != y1) {
SetOverride(line, L"\\org", wxString::Format(L"(%i,%i)", orgx - dx, orgy - dy));
}
} }
grid->ass->FlagAsModified(_("positioning")); grid->ass->FlagAsModified(_("positioning"));