From 3c20facdbcb950b6b691ededb4813a5abedb605b Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 23 Feb 2018 18:21:28 +0200 Subject: [PATCH] Improve time selection dragging behavior --- Source/PluginEditor.cpp | 6 ++++-- Source/PluginEditor.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 028a24c..01e4623 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -596,6 +596,7 @@ void WaveformComponent::mouseDown(const MouseEvent & e) void WaveformComponent::mouseUp(const MouseEvent & /*e*/) { + m_is_dragging_selection = false; m_lock_timesel_set = false; m_mousedown = false; m_didseek = false; @@ -610,14 +611,15 @@ void WaveformComponent::mouseDrag(const MouseEvent & e) { if (m_didseek == true) return; - if (m_time_sel_drag_target == 0 && e.y>=50) + if (m_time_sel_drag_target == 0 && e.y>=50 && m_is_dragging_selection==false) { m_time_sel_start = m_drag_time_start; m_time_sel_end = viewXToNormalized(e.x); } double curlen = m_time_sel_end - m_time_sel_start; - if (m_time_sel_drag_target == 0 && e.y<50 && m_is_at_selection_drag_area) + if (m_time_sel_drag_target == 0 && m_is_at_selection_drag_area) { + m_is_dragging_selection = true; double diff = m_drag_time_start - viewXToNormalized(e.x); m_time_sel_start = jlimit(0.0, 1.0-curlen, m_time_sel_start - diff); m_time_sel_end = jlimit(curlen, 1.0, m_time_sel_end - diff); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index cde703c..0c1fc4a 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -168,6 +168,7 @@ private: bool m_lock_timesel_set = false; bool m_using_audio_buffer = false; bool m_is_at_selection_drag_area = false; + bool m_is_dragging_selection = false; void updateCachedImage(); double viewXToNormalized(double xcor) {