From 845b5d81a9e5ce4046d0b4d0c9b0abe06787aeac Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 4 Dec 2021 19:38:26 -0700 Subject: [PATCH] add Drag::pixel_to_time() which reflects the Drag's _time_domain setting --- gtk2_ardour/editor_drag.cc | 11 +++++++++++ gtk2_ardour/editor_drag.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 90238e5eac..2b46f2b0ce 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -279,6 +279,17 @@ Drag::Drag (Editor* e, ArdourCanvas::Item* i, Temporal::TimeDomain td, bool trac { } +timepos_t +Drag::pixel_to_time (double x) const +{ + samplepos_t p = _editor->pixel_to_sample (x); + + if (_time_domain == Temporal::AudioTime) { + return timepos_t (p); + } + + return timepos_t (timepos_t (p).beats ()); +} void Drag::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t /*time*/) diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 6d1c1d3dff..0c51ef9d4a 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -252,6 +252,8 @@ protected: return _grab_y; } + Temporal::timepos_t pixel_to_time (double x) const; + Temporal::timepos_t raw_grab_time () const { return _raw_grab_time; }