From e593843da7fa03f02bae81f16964b7aec553b98c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 14 May 2014 12:42:44 -0700 Subject: [PATCH] Significantly speed up marker snapping with large selections --- src/audio_marker.cpp | 12 ++---------- src/audio_marker.h | 10 ---------- src/audio_timing_dialogue.cpp | 17 +++++++++++++---- src/audio_timing_karaoke.cpp | 1 - 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/audio_marker.cpp b/src/audio_marker.cpp index 967c28a83..dbf96f8c3 100644 --- a/src/audio_marker.cpp +++ b/src/audio_marker.cpp @@ -37,7 +37,6 @@ public: AudioMarkerKeyframe(Pen *style, int position) : style(style), position(position) { } int GetPosition() const override { return position; } FeetStyle GetFeet() const override { return Feet_None; } - bool CanSnap() const override { return true; } wxPen GetStyle() const override { return *style; } operator int() const { return position; } }; @@ -85,21 +84,14 @@ void AudioMarkerProviderKeyframes::GetMarkers(TimeRange const& range, AudioMarke } class VideoPositionMarker final : public AudioMarker { - Pen style; - int position; + Pen style{"Colour/Audio Display/Play Cursor"}; + int position = -1; public: - VideoPositionMarker() - : style("Colour/Audio Display/Play Cursor") - , position(-1) - { - } - void SetPosition(int new_pos) { position = new_pos; } int GetPosition() const override { return position; } FeetStyle GetFeet() const override { return Feet_None; } - bool CanSnap() const override { return true; } wxPen GetStyle() const override { return style; } operator int() const { return position; } }; diff --git a/src/audio_marker.h b/src/audio_marker.h index bc8f43514..f8ac06f3e 100644 --- a/src/audio_marker.h +++ b/src/audio_marker.h @@ -65,15 +65,6 @@ public: /// @brief Get the marker's feet style /// @return The marker's feet style virtual FeetStyle GetFeet() const = 0; - - /// @brief Retrieve whether this marker participates in snapping - /// @return True if this marker may snap to other snappable markers - /// - /// If a marker being dragged returns true from this method, and another - /// marker which also returns true from this method is within range, the - /// marker being dragged will be positioned at the position of the other - /// marker if it is released while it is inside snapping range. - virtual bool CanSnap() const = 0; }; typedef std::vector AudioMarkerVector; @@ -181,7 +172,6 @@ class SecondsMarkerProvider final : public AudioMarkerProvider { Marker(Pen *style) : style(style) { } int GetPosition() const override { return position; } FeetStyle GetFeet() const override { return Feet_None; } - bool CanSnap() const override { return false; } wxPen GetStyle() const override; operator int() const { return position; } }; diff --git a/src/audio_timing_dialogue.cpp b/src/audio_timing_dialogue.cpp index 1ad360e8b..410a82f81 100644 --- a/src/audio_timing_dialogue.cpp +++ b/src/audio_timing_dialogue.cpp @@ -77,7 +77,6 @@ public: int GetPosition() const override { return position; } wxPen GetStyle() const override { return *style; } FeetStyle GetFeet() const override { return feet; } - bool CanSnap() const override { return true; } /// Move the marker to a new position /// @param new_position The position to move the marker to, in milliseconds @@ -864,6 +863,11 @@ int AudioTimingControllerDialogue::SnapMarkers(int snap_range, std::vector