From 5283c1527be9bd352b78f4e6882d14177690fc47 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 26 May 2010 07:17:15 +0000 Subject: [PATCH] Add updating multiple lines at once to the cross visual tool and make it only happen if alt is held down in both cross and drag. Updates #513. Originally committed to SVN as r4360. --- aegisub/src/visual_tool.cpp | 1 + aegisub/src/visual_tool_cross.cpp | 38 +++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 6d8ccbb0a..44c15335e 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -250,6 +250,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { } // start hold else { + if (!altDown) ClearSelection(); curDiag = GetActiveDialogueLine(); if (curDiag && InitializeHold()) { holding = true; diff --git a/aegisub/src/visual_tool_cross.cpp b/aegisub/src/visual_tool_cross.cpp index 82b4d33a6..020530eff 100644 --- a/aegisub/src/visual_tool_cross.cpp +++ b/aegisub/src/visual_tool_cross.cpp @@ -53,17 +53,35 @@ VisualToolCross::~VisualToolCross() { } /// @brief Update void VisualToolCross::Update() { - // Position - if (leftDClick) { - int vx = video.x; - int vy = video.y; - parent->ToScriptCoords(&vx, &vy); - SubtitlesGrid *grid = VideoContext::Get()->grid; - SetOverride(GetActiveDialogueLine(), L"\\pos",wxString::Format(L"(%i,%i)",vx,vy)); - grid->ass->FlagAsModified(_("positioning")); - grid->CommitChanges(false,true); - grid->editBox->Update(false, true, false); + if (!leftDClick) return; + + AssDialogue* line = GetActiveDialogueLine(); + if (!line) return; + + + int dx, dy; + int vx = video.x; + int vy = video.y; + GetLinePosition(line, dx, dy); + parent->ToScriptCoords(&vx, &vy); + parent->ToScriptCoords(&dx, &dy); + dx -= vx; + dy -= vy; + + SubtitlesGrid *grid = VideoContext::Get()->grid; + wxArrayInt sel = grid->GetSelection(); + for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + AssDialogue* line = grid->GetDialogue(*cur); + if (!line) continue; + int x1, y1; + GetLinePosition(line, x1, y1); + parent->ToScriptCoords(&x1, &y1); + SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy)); } + + grid->ass->FlagAsModified(_("positioning")); + grid->CommitChanges(false,true); + grid->editBox->Update(false, true, false); } /// @brief Draw