diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 24e3bf86f..edde076fa 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -414,11 +414,6 @@ void VisualTool::RemoveSelection(unsigned i) { } } -template -wxArrayInt VisualTool::GetSelection() { - return grid->GetSelection(); -} - template void VisualTool::ClearSelection() { selFeatures.clear(); diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 8a73109ed..8f440bb8d 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -192,8 +192,6 @@ protected: /// @brief Clear the selection void ClearSelection(); - /// @brief Get the currently selected lines - wxArrayInt GetSelection(); typedef typename std::vector::iterator feature_iterator; typedef typename std::vector::const_iterator feature_const_iterator; diff --git a/aegisub/src/visual_tool_cross.cpp b/aegisub/src/visual_tool_cross.cpp index 2d61f12a9..8ac04fe31 100644 --- a/aegisub/src/visual_tool_cross.cpp +++ b/aegisub/src/visual_tool_cross.cpp @@ -61,15 +61,12 @@ bool VisualToolCross::Update() { 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; + Selection sel = grid->GetSelectedSet(); + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { int x1, y1; - GetLinePosition(line, x1, y1); + GetLinePosition(*cur, x1, y1); parent->ToScriptCoords(&x1, &y1); - SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy)); + SetOverride(*cur, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy)); } Commit(true, _("positioning")); diff --git a/aegisub/src/visual_tool_drag.cpp b/aegisub/src/visual_tool_drag.cpp index 62f3cfd81..a199b9b07 100644 --- a/aegisub/src/visual_tool_drag.cpp +++ b/aegisub/src/visual_tool_drag.cpp @@ -93,16 +93,13 @@ void VisualToolDrag::UpdateToggleButtons() { /// @brief Toggle button pressed /// @param event void VisualToolDrag::OnSubTool(wxCommandEvent &) { - BaseGrid* grid = VideoContext::Get()->grid; - wxArrayInt sel = GetSelection(); + Selection sel = grid->GetSelectedSet(); // Toggle \move <-> \pos - for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + AssDialogue *line = *cur; int x1,y1,x2,y2,t1,t2; bool hasMove; - AssDialogue *line = grid->GetDialogue(*cur); - if (!line) continue; - GetLinePosition(line,x1,y1); GetLineMove(line,hasMove,x1,y1,x2,y2,t1,t2); parent->ToScriptCoords(&x1, &y1); @@ -335,31 +332,28 @@ bool VisualToolDrag::Update() { 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; + Selection sel = grid->GetSelectedSet(); + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { int x1 = 0, y1 = 0, x2 = 0, y2 = 0, t1 = INT_MIN, t2 = INT_MIN, orgx, orgy; bool isMove; - GetLinePosition(line, x1, y1, orgx, orgy); - GetLineMove(line, isMove, x1, y1, x2, y2, t1, t2); + GetLinePosition(*cur, x1, y1, orgx, orgy); + GetLineMove(*cur, isMove, x1, y1, x2, y2, t1, t2); parent->ToScriptCoords(&x1, &y1); parent->ToScriptCoords(&x2, &y2); parent->ToScriptCoords(&orgx, &orgy); if (isMove) { 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(*cur, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1 - dx, y1 - dy, x2 - dx, y2 - dy, t1, t2)); else - SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i)", x1, y1, x2, y2)); + SetOverride(*cur, L"\\move", wxString::Format(L"(%i,%i,%i,%i)", x1, y1, x2, y2)); } else { - SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy)); + SetOverride(*cur, 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)); + SetOverride(*cur, L"\\org", wxString::Format(L"(%i,%i)", orgx - dx, orgy - dy)); } } diff --git a/aegisub/src/visual_tool_rotatexy.cpp b/aegisub/src/visual_tool_rotatexy.cpp index 65fcbec90..15981bf76 100644 --- a/aegisub/src/visual_tool_rotatexy.cpp +++ b/aegisub/src/visual_tool_rotatexy.cpp @@ -186,12 +186,10 @@ void VisualToolRotateXY::UpdateHold() { } void VisualToolRotateXY::CommitHold() { - wxArrayInt sel = grid->GetSelection(); - for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { - AssDialogue* line = grid->GetDialogue(*cur); - assert(line); - SetOverride(line, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX)); - SetOverride(line, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY)); + Selection sel = grid->GetSelectedSet(); + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + SetOverride(*cur, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX)); + SetOverride(*cur, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY)); } } diff --git a/aegisub/src/visual_tool_rotatez.cpp b/aegisub/src/visual_tool_rotatez.cpp index 5d050264b..ba8c447ad 100644 --- a/aegisub/src/visual_tool_rotatez.cpp +++ b/aegisub/src/visual_tool_rotatez.cpp @@ -148,11 +148,9 @@ void VisualToolRotateZ::UpdateHold() { } void VisualToolRotateZ::CommitHold() { - wxArrayInt sel = grid->GetSelection(); - for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { - AssDialogue* line = grid->GetDialogue(*cur); - assert(line); - SetOverride(line, L"\\frz",wxString::Format(L"(%0.3g)",curAngle)); + Selection sel = grid->GetSelectedSet(); + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + SetOverride(*cur, L"\\frz",wxString::Format(L"(%0.3g)",curAngle)); } } diff --git a/aegisub/src/visual_tool_scale.cpp b/aegisub/src/visual_tool_scale.cpp index a1ecc9296..ec1d09548 100644 --- a/aegisub/src/visual_tool_scale.cpp +++ b/aegisub/src/visual_tool_scale.cpp @@ -147,12 +147,10 @@ void VisualToolScale::UpdateHold() { } void VisualToolScale::CommitHold() { - wxArrayInt sel = grid->GetSelection(); - for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { - AssDialogue* line = grid->GetDialogue(*cur); - assert(line); - SetOverride(line, L"\\fscx",wxString::Format(L"(%0.3g)",curScaleX)); - SetOverride(line, L"\\fscy",wxString::Format(L"(%0.3g)",curScaleY)); + Selection sel = grid->GetSelectedSet(); + for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { + SetOverride(*cur, L"\\fscx",wxString::Format(L"(%0.3g)",curScaleX)); + SetOverride(*cur, L"\\fscy",wxString::Format(L"(%0.3g)",curScaleY)); } }