From cb549e5aa97f07fc6ffdfedd62b1b4a3bd507a18 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 18 Sep 2013 16:18:38 -0700 Subject: [PATCH] Significantly speed up dragging lots of vector clip control points --- aegisub/src/visual_tool.h | 2 +- aegisub/src/visual_tool_vector_clip.cpp | 19 ++++++------------- aegisub/src/visual_tool_vector_clip.h | 1 + 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 4706e5502..0b3fbde9c 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -113,7 +113,7 @@ protected: /// @brief Commit the current file state /// @param message Description of changes for undo - void Commit(wxString message = wxString()); + virtual void Commit(wxString message = wxString()); bool IsDisplayed(AssDialogue *line) const; /// Get the line's position if it's set, or it's default based on style if not diff --git a/aegisub/src/visual_tool_vector_clip.cpp b/aegisub/src/visual_tool_vector_clip.cpp index 30281421d..c9c8f9a49 100644 --- a/aegisub/src/visual_tool_vector_clip.cpp +++ b/aegisub/src/visual_tool_vector_clip.cpp @@ -222,9 +222,13 @@ void VisualToolVectorClip::Save() { } } +void VisualToolVectorClip::Commit(wxString message) { + Save(); + VisualToolBase::Commit(message); +} + void VisualToolVectorClip::UpdateDrag(Feature *feature) { spline.MovePoint(feature->curve, feature->point, feature->pos); - Save(); } bool VisualToolVectorClip::InitializeDrag(Feature *feature) { @@ -251,7 +255,6 @@ bool VisualToolVectorClip::InitializeDrag(Feature *feature) { } active_feature = nullptr; - Save(); MakeFeatures(); Commit(_("delete control point")); @@ -329,7 +332,6 @@ bool VisualToolVectorClip::InitializeHold() { } } - Save(); MakeFeatures(); Commit(); return false; @@ -357,8 +359,6 @@ static bool in_box(Vector2D top_left, Vector2D bottom_right, Vector2D p) { } void VisualToolVectorClip::UpdateHold() { - bool needs_save = true; - // Box selection if (mode == 0) { std::set boxed_features; @@ -415,20 +415,13 @@ void VisualToolVectorClip::UpdateHold() { spline.emplace_back(last, mouse_pos); MakeFeature(--spline.end()); } - else - needs_save = false; } if (mode == 3 || mode == 4) return; // Smooth spline - if (!holding && mode == 7) { + if (!holding && mode == 7) spline.Smooth(); - needs_save = true; - } - - if (needs_save) - Save(); // End freedraw if (!holding && (mode == 6 || mode == 7)) { diff --git a/aegisub/src/visual_tool_vector_clip.h b/aegisub/src/visual_tool_vector_clip.h index 3fb1cdb92..1537acad6 100644 --- a/aegisub/src/visual_tool_vector_clip.h +++ b/aegisub/src/visual_tool_vector_clip.h @@ -53,6 +53,7 @@ class VisualToolVectorClip : public VisualTool